public abstract class StdSerializer<T> extends JsonSerializer<T> implements JsonFormatVisitable, SchemaAware, Serializable
SchemaAware
JsonSerializer.None
Modifier and Type | Field and Description |
---|---|
protected Class<T> |
_handledType
Nominal type supported, usually declared type of
property for which serializer is used.
|
Modifier | Constructor and Description |
---|---|
protected |
StdSerializer(Class<?> t,
boolean dummy)
Alternate constructor that is (alas!) needed to work
around kinks of generic type handling
|
protected |
StdSerializer(Class<T> t) |
protected |
StdSerializer(JavaType type) |
protected |
StdSerializer(StdSerializer<?> src) |
Modifier and Type | Method and Description |
---|---|
protected static boolean |
_neitherNull(Object a,
Object b) |
protected static boolean |
_nonEmpty(Collection<?> c) |
void |
acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,
JavaType typeHint)
Default implementation specifies no format.
|
protected ObjectNode |
createSchemaNode(String type) |
protected ObjectNode |
createSchemaNode(String type,
boolean isOptional) |
protected JsonSerializer<?> |
findAnnotatedContentSerializer(SerializerProvider serializers,
BeanProperty property)
Convenience method for finding out possibly configured content value serializer.
|
protected JsonSerializer<?> |
findContextualConvertingSerializer(SerializerProvider provider,
BeanProperty property,
JsonSerializer<?> existingSerializer)
Helper method that can be used to see if specified property has annotation
indicating that a converter is to be used for contained values (contents
of structured types; array/List/Map values)
|
protected JsonSerializer<?> |
findConvertingContentSerializer(SerializerProvider provider,
BeanProperty prop,
JsonSerializer<?> existingSerializer)
|
protected Boolean |
findFormatFeature(SerializerProvider provider,
BeanProperty prop,
Class<?> typeForDefaults,
com.fasterxml.jackson.annotation.JsonFormat.Feature feat)
Convenience method that uses
findFormatOverrides(com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.BeanProperty, java.lang.Class<?>) to find possible
defaults and/of overrides, and then calls JsonFormat.Value.getFeature(...)
to find whether that feature has been specifically marked as enabled or disabled. |
protected com.fasterxml.jackson.annotation.JsonFormat.Value |
findFormatOverrides(SerializerProvider provider,
BeanProperty prop,
Class<?> typeForDefaults)
Helper method that may be used to find if this deserializer has specific
JsonFormat settings, either via property, or through type-specific
defaulting. |
protected com.fasterxml.jackson.annotation.JsonInclude.Value |
findIncludeOverrides(SerializerProvider provider,
BeanProperty prop,
Class<?> typeForDefaults) |
protected PropertyFilter |
findPropertyFilter(SerializerProvider provider,
Object filterId,
Object valueToFilter)
Helper method used to locate filter that is needed, based on filter id
this serializer was constructed with.
|
JsonNode |
getSchema(SerializerProvider provider,
Type typeHint)
Default implementation simply claims type is "string"; usually
overriden by custom serializers.
|
JsonNode |
getSchema(SerializerProvider provider,
Type typeHint,
boolean isOptional)
Default implementation simply claims type is "string"; usually
overriden by custom serializers.
|
Class<T> |
handledType()
Method for accessing type of Objects this serializer can handle.
|
protected boolean |
isDefaultSerializer(JsonSerializer<?> serializer)
Method that can be called to determine if given serializer is the default
serializer Jackson uses; as opposed to a custom serializer installed by
a module or calling application.
|
abstract void |
serialize(T value,
com.fasterxml.jackson.core.JsonGenerator gen,
SerializerProvider provider)
Method that can be called to ask implementation to serialize
values of type this serializer handles.
|
protected void |
visitArrayFormat(JsonFormatVisitorWrapper visitor,
JavaType typeHint,
JsonFormatTypes itemType) |
protected void |
visitArrayFormat(JsonFormatVisitorWrapper visitor,
JavaType typeHint,
JsonSerializer<?> itemSerializer,
JavaType itemType) |
protected void |
visitFloatFormat(JsonFormatVisitorWrapper visitor,
JavaType typeHint,
com.fasterxml.jackson.core.JsonParser.NumberType numberType)
Helper method that calls necessary visit method(s) to indicate that the
underlying JSON type is a floating-point JSON number.
|
protected void |
visitIntFormat(JsonFormatVisitorWrapper visitor,
JavaType typeHint,
com.fasterxml.jackson.core.JsonParser.NumberType numberType)
Helper method that calls necessary visit method(s) to indicate that the
underlying JSON type is JSON Integer number.
|
protected void |
visitIntFormat(JsonFormatVisitorWrapper visitor,
JavaType typeHint,
com.fasterxml.jackson.core.JsonParser.NumberType numberType,
JsonValueFormat format)
Helper method that calls necessary visit method(s) to indicate that the
underlying JSON type is JSON Integer number, but that there is also a further
format restriction involved.
|
protected void |
visitStringFormat(JsonFormatVisitorWrapper visitor,
JavaType typeHint)
Helper method that calls necessary visit method(s) to indicate that the
underlying JSON type is JSON String.
|
protected void |
visitStringFormat(JsonFormatVisitorWrapper visitor,
JavaType typeHint,
JsonValueFormat format)
Helper method that calls necessary visit method(s) to indicate that the
underlying JSON type is JSON String, but that there is a more refined
logical type
|
void |
wrapAndThrow(SerializerProvider provider,
Throwable t,
Object bean,
int index) |
void |
wrapAndThrow(SerializerProvider provider,
Throwable t,
Object bean,
String fieldName)
Method that will modify caught exception (passed in as argument)
as necessary to include reference information, and to ensure it
is a subtype of
IOException , or an unchecked exception. |
getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, serializeWithType, unwrappingSerializer, usesObjectId, withFilterId
protected StdSerializer(JavaType type)
protected StdSerializer(Class<?> t, boolean dummy)
protected StdSerializer(StdSerializer<?> src)
public Class<T> handledType()
JsonSerializer
Default implementation will return null, which essentially means
same as returning Object.class
would; that is, that
nothing is known about handled type.
handledType
in class JsonSerializer<T>
public abstract void serialize(T value, com.fasterxml.jackson.core.JsonGenerator gen, SerializerProvider provider) throws IOException
JsonSerializer
serialize
in class JsonSerializer<T>
value
- Value to serialize; can not be null.gen
- 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 acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
acceptJsonFormatVisitor
in interface JsonFormatVisitable
acceptJsonFormatVisitor
in class JsonSerializer<T>
typeHint
- Type of element (entity like property) being visitedJsonMappingException
public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException
getSchema
in interface SchemaAware
provider
- The serializer provider.typeHint
- A hint about the type.JsonMappingException
public JsonNode getSchema(SerializerProvider provider, Type typeHint, boolean isOptional) throws JsonMappingException
getSchema
in interface SchemaAware
provider
- The serializer provider.typeHint
- A hint about the type.isOptional
- Is the type optionalJsonMappingException
protected ObjectNode createSchemaNode(String type)
protected ObjectNode createSchemaNode(String type, boolean isOptional)
protected void visitStringFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
JsonMappingException
protected void visitStringFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonValueFormat format) throws JsonMappingException
JsonMappingException
protected void visitIntFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, com.fasterxml.jackson.core.JsonParser.NumberType numberType) throws JsonMappingException
JsonMappingException
protected void visitIntFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, com.fasterxml.jackson.core.JsonParser.NumberType numberType, JsonValueFormat format) throws JsonMappingException
JsonMappingException
protected void visitFloatFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, com.fasterxml.jackson.core.JsonParser.NumberType numberType) throws JsonMappingException
JsonMappingException
protected void visitArrayFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonSerializer<?> itemSerializer, JavaType itemType) throws JsonMappingException
JsonMappingException
protected void visitArrayFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonFormatTypes itemType) throws JsonMappingException
JsonMappingException
public void wrapAndThrow(SerializerProvider provider, Throwable t, Object bean, String fieldName) throws IOException
IOException
, or an unchecked exception.
Rules for wrapping and unwrapping are bit complicated; essentially:
JsonMappingException
are to be passed as is
IOException
public void wrapAndThrow(SerializerProvider provider, Throwable t, Object bean, int index) throws IOException
IOException
protected JsonSerializer<?> findContextualConvertingSerializer(SerializerProvider provider, BeanProperty property, JsonSerializer<?> existingSerializer) throws JsonMappingException
existingSerializer
- (optional) configured content
serializer if one already exists.JsonMappingException
@Deprecated protected JsonSerializer<?> findConvertingContentSerializer(SerializerProvider provider, BeanProperty prop, JsonSerializer<?> existingSerializer) throws JsonMappingException
findContextualConvertingSerializer(com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.BeanProperty, com.fasterxml.jackson.databind.JsonSerializer<?>)
insteadJsonMappingException
protected PropertyFilter findPropertyFilter(SerializerProvider provider, Object filterId, Object valueToFilter) throws JsonMappingException
JsonMappingException
protected com.fasterxml.jackson.annotation.JsonFormat.Value findFormatOverrides(SerializerProvider provider, BeanProperty prop, Class<?> typeForDefaults)
JsonFormat
settings, either via property, or through type-specific
defaulting.typeForDefaults
- Type (erased) used for finding default format settings, if anyprotected Boolean findFormatFeature(SerializerProvider provider, BeanProperty prop, Class<?> typeForDefaults, com.fasterxml.jackson.annotation.JsonFormat.Feature feat)
findFormatOverrides(com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.BeanProperty, java.lang.Class<?>)
to find possible
defaults and/of overrides, and then calls JsonFormat.Value.getFeature(...)
to find whether that feature has been specifically marked as enabled or disabled.typeForDefaults
- Type (erased) used for finding default format settings, if anyprotected com.fasterxml.jackson.annotation.JsonInclude.Value findIncludeOverrides(SerializerProvider provider, BeanProperty prop, Class<?> typeForDefaults)
protected JsonSerializer<?> findAnnotatedContentSerializer(SerializerProvider serializers, BeanProperty property) throws JsonMappingException
JsonMappingException
protected boolean isDefaultSerializer(JsonSerializer<?> serializer)
JacksonStdImpl
annotation on serializer class.protected static final boolean _nonEmpty(Collection<?> c)
Copyright © 2008–2021 FasterXML. All rights reserved.