public class LocalDateSerializer extends StdSerializer<T>
LocalDate
s.JsonSerializer.None
Modifier and Type | Field and Description |
---|---|
protected DateTimeFormatter |
_formatter
Specific format to use, if not default format: non null value
also indicates that serialization is to be done as JSON String,
not numeric timestamp, unless
#_useTimestamp is true. |
protected JavaType |
_integerListType
Lazily constructed
JavaType representing type
List<Integer> . |
protected JsonFormat.Shape |
_shape |
protected Boolean |
_useNanoseconds
Flag that indicates that numeric timestamp values must be written using
nanosecond timestamps if the datatype supports such resolution,
regardless of other settings.
|
protected Boolean |
_useTimestamp
Flag that indicates that serialization must be done as the
Java timestamp, regardless of other settings.
|
static LocalDateSerializer |
INSTANCE |
_handledType
Modifier | Constructor and Description |
---|---|
protected |
LocalDateSerializer() |
|
LocalDateSerializer(DateTimeFormatter formatter) |
protected |
LocalDateSerializer(LocalDateSerializer base,
Boolean useTimestamp,
DateTimeFormatter dtf,
JsonFormat.Shape shape) |
Modifier and Type | Method and Description |
---|---|
protected void |
_acceptTimestampVisitor(JsonFormatVisitorWrapper visitor,
JavaType typeHint) |
protected JavaType |
_integerListType(SerializerProvider prov) |
protected void |
_serializeAsArrayContents(LocalDate value,
JsonGenerator g,
SerializerProvider provider) |
protected DateTimeFormatter |
_useDateTimeFormatter(SerializerProvider prov,
JsonFormat.Value format) |
protected boolean |
_useTimestampExplicitOnly(SerializerProvider provider) |
void |
acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,
JavaType typeHint)
Default implementation specifies no format.
|
JsonSerializer<?> |
createContextual(SerializerProvider prov,
BeanProperty property)
Method called to see if a different (or differently configured) serializer
is needed to serialize values of specified property.
|
JsonNode |
getSchema(SerializerProvider provider,
Type typeHint)
Default implementation simply claims type is "string"; usually
overriden by custom serializers.
|
protected SerializationFeature |
getTimestampsFeature()
Overridable method that determines
SerializationFeature that is used as
the global default in determining if date/time value serialized should use numeric
format ("timestamp") or not. |
protected JsonToken |
serializationShape(SerializerProvider provider)
Overridable helper method used from
serializeWithType(T, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer) , to indicate
shape of value during serialization; needed to know how type id is to be
serialized. |
void |
serialize(LocalDate date,
JsonGenerator g,
SerializerProvider provider)
Method that can be called to ask implementation to serialize
values of type this serializer handles.
|
void |
serializeWithType(LocalDate value,
JsonGenerator g,
SerializerProvider provider,
TypeSerializer typeSer)
Method that can be called to ask implementation to serialize
values of type this serializer handles, using specified type serializer
for embedding necessary type information.
|
protected boolean |
useNanoseconds(SerializerProvider provider) |
protected boolean |
useTimestamp(SerializerProvider provider) |
protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> |
withFeatures(Boolean writeZoneId)
Deprecated.
|
protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> |
withFeatures(Boolean writeZoneId,
Boolean writeNanoseconds) |
protected LocalDateSerializer |
withFormat(Boolean useTimestamp,
DateTimeFormatter dtf,
JsonFormat.Shape shape) |
_neitherNull, _nonEmpty, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findConvertingContentSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, getSchema, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrow
getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, unwrappingSerializer, usesObjectId, withFilterId
public static final LocalDateSerializer INSTANCE
protected final Boolean _useTimestamp
protected final Boolean _useNanoseconds
protected final DateTimeFormatter _formatter
#_useTimestamp
is true.protected final JsonFormat.Shape _shape
protected transient volatile JavaType _integerListType
JavaType
representing type
List<Integer>
.protected LocalDateSerializer()
protected LocalDateSerializer(LocalDateSerializer base, Boolean useTimestamp, DateTimeFormatter dtf, JsonFormat.Shape shape)
public LocalDateSerializer(DateTimeFormatter formatter)
protected LocalDateSerializer withFormat(Boolean useTimestamp, DateTimeFormatter dtf, JsonFormat.Shape shape)
public void serialize(LocalDate date, JsonGenerator g, SerializerProvider provider) throws IOException
JsonSerializer
serialize
in class StdSerializer<LocalDate>
date
- Value to serialize; can not be null.g
- Generator used to output resulting Json contentprovider
- Provider that can be used to get serializers for
serializing Objects value contains, if any.IOException
public void serializeWithType(LocalDate value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException
JsonSerializer
Default implementation will throw UnsupportedOperationException
to indicate that proper type handling needs to be implemented.
For simple datatypes written as a single scalar value (JSON String, Number, Boolean), implementation would look like:
// note: method to call depends on whether this type is serialized as JSON scalar, object or Array! typeSer.writeTypePrefixForScalar(value, gen); serialize(value, gen, provider); typeSer.writeTypeSuffixForScalar(value, gen);and implementations for type serialized as JSON Arrays or Objects would differ slightly, as
START-ARRAY
/END-ARRAY
and
START-OBJECT
/END-OBJECT
pairs
need to be properly handled with respect to serializing of contents.value
- Value to serialize; can not be null.g
- Generator used to output resulting Json contentprovider
- Provider that can be used to get serializers for
serializing Objects value contains, if any.typeSer
- Type serializer to use for including type informationIOException
protected void _serializeAsArrayContents(LocalDate value, JsonGenerator g, SerializerProvider provider) throws IOException
IOException
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
StdSerializer
acceptJsonFormatVisitor
in interface JsonFormatVisitable
typeHint
- Type of element (entity like property) being visitedJsonMappingException
protected JsonToken serializationShape(SerializerProvider provider)
serializeWithType(T, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer)
, to indicate
shape of value during serialization; needed to know how type id is to be
serialized.@Deprecated protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> withFeatures(Boolean writeZoneId)
protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> withFeatures(Boolean writeZoneId, Boolean writeNanoseconds)
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException
ContextualSerializer
createContextual
in interface ContextualSerializer
prov
- Serializer provider to use for accessing config, other serializersproperty
- Method or field that represents the property
(and is used to access value to serialize).
Should be available; but there may be cases where caller cannot provide it and
null is passed instead (in which case impls usually pass 'this' serializer as is)JsonMappingException
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
StdSerializer
getSchema
in interface SchemaAware
getSchema
in class StdSerializer<T>
provider
- The serializer provider.typeHint
- A hint about the type.protected void _acceptTimestampVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
JsonMappingException
protected JavaType _integerListType(SerializerProvider prov)
protected SerializationFeature getTimestampsFeature()
SerializationFeature
that is used as
the global default in determining if date/time value serialized should use numeric
format ("timestamp") or not.
Note that this feature is just the baseline setting and may be overridden on per-type or per-property basis.
protected boolean useTimestamp(SerializerProvider provider)
protected boolean _useTimestampExplicitOnly(SerializerProvider provider)
protected boolean useNanoseconds(SerializerProvider provider)
protected DateTimeFormatter _useDateTimeFormatter(SerializerProvider prov, JsonFormat.Value format)
Copyright © 2021 JBoss by Red Hat. All rights reserved.