Class AbstractElasticsearchJavaTimeFieldCodec<T extends TemporalAccessor>
- java.lang.Object
-
- 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 Object implements ElasticsearchFieldCodec<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected DateTimeFormatterformatter
-
Constructor Summary
Constructors Constructor Description AbstractElasticsearchJavaTimeFieldCodec(DateTimeFormatter delegate)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Tdecode(com.google.gson.JsonElement element)TdecodeAggregationKey(com.google.gson.JsonElement key, com.google.gson.JsonElement keyAsString)Decodes the key returned by a term aggregation.com.google.gson.JsonElementencode(T value)com.google.gson.JsonElementencodeForMissing(T value)A different encoding is required for provided missing Java time values.booleanisCompatibleWith(ElasticsearchFieldCodec<?> obj)Determine whether another codec is compatible with this one, i.e.protected StringnullUnsafeFormat(T value)protected abstract TnullUnsafeParse(String stringValue)protected abstract LongnullUnsafeScalar(T value)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.search.backend.elasticsearch.types.codec.impl.ElasticsearchFieldCodec
encodeForAggregation
-
-
-
-
Field Detail
-
formatter
protected final DateTimeFormatter formatter
-
-
Constructor Detail
-
AbstractElasticsearchJavaTimeFieldCodec
public AbstractElasticsearchJavaTimeFieldCodec(DateTimeFormatter delegate)
-
-
Method Detail
-
encode
public com.google.gson.JsonElement encode(T value)
- Specified by:
encodein interfaceElasticsearchFieldCodec<T extends TemporalAccessor>
-
encodeForMissing
public com.google.gson.JsonElement encodeForMissing(T value)
A different encoding is required for provided missing Java time values. See HSEARCH-3255.- Specified by:
encodeForMissingin interfaceElasticsearchFieldCodec<T extends TemporalAccessor>- Parameters:
value- to encode- Returns:
- a
JsonElementcontaining the long scalar value, ifvalueis not null.
-
decode
public T decode(com.google.gson.JsonElement element)
- Specified by:
decodein interfaceElasticsearchFieldCodec<T extends TemporalAccessor>
-
decodeAggregationKey
public T decodeAggregationKey(com.google.gson.JsonElement key, com.google.gson.JsonElement keyAsString)
Description copied from interface:ElasticsearchFieldCodecDecodes the key returned by a term aggregation.- Specified by:
decodeAggregationKeyin interfaceElasticsearchFieldCodec<T extends TemporalAccessor>- 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 aJsonPrimitivecontaining a string.- Returns:
- The decoded term.
-
isCompatibleWith
public boolean isCompatibleWith(ElasticsearchFieldCodec<?> obj)
Description copied from interface:ElasticsearchFieldCodecDetermine 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.- Specified by:
isCompatibleWithin interfaceElasticsearchFieldCodec<T extends TemporalAccessor>- Parameters:
obj- AnotherElasticsearchFieldCodec, nevernull.- Returns:
trueif the given codec is compatible.falseotherwise, or when in doubt.
-
-