public class MonthDaySerializer extends StdSerializer<T>
MonthDay
s.
NOTE: unlike many other date/time type serializers, this serializer will only
use Array notation if explicitly instructed to do so with JsonFormat
(either directly or through per-type defaults) and NOT with global defaults.
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 Boolean |
_useTimestamp
Flag that indicates that serialization must be done as the
Java timestamp, regardless of other settings.
|
static MonthDaySerializer |
INSTANCE |
_handledType
Constructor and Description |
---|
MonthDaySerializer(DateTimeFormatter formatter) |
Modifier and Type | Method and Description |
---|---|
protected void |
_acceptTimestampVisitor(JsonFormatVisitorWrapper visitor,
JavaType typeHint) |
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.
|
void |
serialize(MonthDay value,
JsonGenerator generator,
SerializerProvider provider)
Method that can be called to ask implementation to serialize
values of type this serializer handles.
|
void |
serializeWithType(T value,
JsonGenerator generator,
SerializerProvider provider,
TypeSerializer serializer)
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 |
useTimestamp(SerializerProvider provider) |
protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> |
withFeatures(Boolean writeZoneId) |
protected MonthDaySerializer |
withFormat(Boolean useTimestamp,
DateTimeFormatter formatter) |
createObjectNode, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, 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 MonthDaySerializer INSTANCE
protected final Boolean _useTimestamp
protected final DateTimeFormatter _formatter
_useTimestamp
is true.public MonthDaySerializer(DateTimeFormatter formatter)
protected MonthDaySerializer withFormat(Boolean useTimestamp, DateTimeFormatter formatter)
public void serialize(MonthDay value, JsonGenerator generator, SerializerProvider provider) throws IOException
JsonSerializer
serialize
in class StdSerializer<MonthDay>
value
- Value to serialize; can not be null.generator
- Generator used to output resulting Json contentprovider
- Provider that can be used to get serializers for
serializing Objects value contains, if any.IOException
protected void _acceptTimestampVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
JsonMappingException
protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> withFeatures(Boolean writeZoneId)
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 can not 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.public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
StdSerializer
acceptJsonFormatVisitor
in interface JsonFormatVisitable
acceptJsonFormatVisitor
in class StdSerializer<T>
typeHint
- Type of element (entity like property) being visitedJsonMappingException
protected boolean useTimestamp(SerializerProvider provider)
protected boolean _useTimestampExplicitOnly(SerializerProvider provider)
public void serializeWithType(T value, JsonGenerator generator, SerializerProvider provider, TypeSerializer serializer) 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.serializeWithType
in class JsonSerializer<T>
value
- Value to serialize; can not be null.generator
- Generator used to output resulting Json contentprovider
- Provider that can be used to get serializers for
serializing Objects value contains, if any.serializer
- Type serializer to use for including type informationIOException
Copyright © 2017 JBoss by Red Hat. All rights reserved.