Class AbstractElasticsearchJavaTimeFieldCodec<T extends TemporalAccessor>

java.lang.Object
org.hibernate.search.backend.elasticsearch.types.codec.impl.AbstractElasticsearchFieldCodec<T>
org.hibernate.search.backend.elasticsearch.types.codec.impl.AbstractElasticsearchJavaTimeFieldCodec<T>
All Implemented Interfaces:
ElasticsearchFieldCodec<T>
Direct Known Subclasses:
ElasticsearchInstantFieldCodec, ElasticsearchLocalDateFieldCodec, ElasticsearchLocalDateTimeFieldCodec, ElasticsearchLocalTimeFieldCodec, ElasticsearchMonthDayFieldCodec, ElasticsearchOffsetDateTimeFieldCodec, ElasticsearchOffsetTimeFieldCodec, ElasticsearchYearFieldCodec, ElasticsearchYearMonthFieldCodec, ElasticsearchZonedDateTimeFieldCodec

public abstract class AbstractElasticsearchJavaTimeFieldCodec<T extends TemporalAccessor> extends AbstractElasticsearchFieldCodec<T>
  • Field Details

  • Constructor Details

    • AbstractElasticsearchJavaTimeFieldCodec

      public AbstractElasticsearchJavaTimeFieldCodec(com.google.gson.Gson gson, DateTimeFormatter delegate)
  • Method Details

    • encode

      public com.google.gson.JsonElement encode(T value)
    • encodeForMissing

      public com.google.gson.JsonElement encodeForMissing(T value)
      A different encoding is required for provided missing Java time values. See HSEARCH-3255.
      Parameters:
      value - to encode
      Returns:
      a JsonElement containing the long scalar value, if value is not null.
    • decode

      public T decode(com.google.gson.JsonElement element)
    • decodeAggregationKey

      public T decodeAggregationKey(com.google.gson.JsonElement key, com.google.gson.JsonElement keyAsString)
      Description copied from interface: ElasticsearchFieldCodec
      Decodes the key returned by a term aggregation.
      Parameters:
      key - The "key" property returned by the aggregation. May be a number, a string, ... depending on the field type.
      keyAsString - The "key_as_string" property returned by the term aggregation. Either null or a JsonPrimitive containing a string.
      Returns:
      The decoded term.
    • isCompatibleWith

      public boolean isCompatibleWith(ElasticsearchFieldCodec<?> obj)
      Description copied from interface: ElasticsearchFieldCodec
      Determine whether another codec is compatible with this one, i.e. whether it will encode/decode the information to/from the document in a compatible way.
      Parameters:
      obj - Another ElasticsearchFieldCodec, never null.
      Returns:
      true if the given codec is compatible. false otherwise, or when in doubt.
    • nullUnsafeFormat

      protected String nullUnsafeFormat(T value)
    • nullUnsafeParse

      protected abstract T nullUnsafeParse(String stringValue)
    • nullUnsafeScalar

      protected abstract Long nullUnsafeScalar(T value)