public abstract class DefaultSerializerProvider extends SerializerProvider implements java.io.Serializable
ObjectMapper
:
adds methods only exposed to ObjectMapper
,
as well as constructors.
Note that class is abstract just because it does not
define createInstance(com.fasterxml.jackson.databind.SerializationConfig, com.fasterxml.jackson.databind.ser.SerializerFactory)
method.
Also note that all custom SerializerProvider
implementations must sub-class this class: ObjectMapper
requires this type, not basic provider type.
Modifier and Type | Class and Description |
---|---|
static class |
DefaultSerializerProvider.Impl
Concrete implementation that defines factory method(s),
defined as final.
|
DEFAULT_NULL_KEY_SERIALIZER
Modifier and Type | Method and Description |
---|---|
void |
acceptJsonFormatVisitor(JavaType javaType,
JsonFormatVisitorWrapper visitor)
The method to be called by
ObjectMapper and ObjectWriter
to to expose the format of the given to to the given visitor |
int |
cachedSerializersCount()
Method that can be used to determine how many serializers this
provider is caching currently
(if it does caching: default implementation does)
Exact count depends on what kind of serializers get cached;
default implementation caches all serializers, including ones that
are eagerly constructed (for optimal access speed)
|
DefaultSerializerProvider |
copy()
Method needed to ensure that
ObjectMapper.copy() will work
properly; specifically, that caches are cleared, but settings
will otherwise remain identical; and that no sharing of state
occurs. |
abstract DefaultSerializerProvider |
createInstance(SerializationConfig config,
SerializerFactory jsf)
Method that sub-classes need to implement: used to create a non-blueprint instances
from the blueprint.
|
WritableObjectId |
findObjectId(java.lang.Object forPojo,
ObjectIdGenerator<?> generatorType)
Method called to find the Object Id for given POJO, if one
has been generated.
|
void |
flushCachedSerializers()
Method that will drop all serializers currently cached by this provider.
|
JsonSchema |
generateJsonSchema(java.lang.Class<?> type)
Deprecated.
Should not be used any more
|
JsonGenerator |
getGenerator()
Accessor for the
JsonGenerator currently in use for serializing
content. |
boolean |
hasSerializerFor(java.lang.Class<?> cls,
java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> cause)
Method that can be called to see if this serializer provider
can find a serializer for an instance of given class.
|
java.lang.Object |
includeFilterInstance(BeanPropertyDefinition forProperty,
java.lang.Class<?> filterClass)
Method that can be called to construct and configure
JsonInclude
filter instance,
given a Class to instantiate (with default constructor, by default). |
boolean |
includeFilterSuppressNulls(java.lang.Object filter)
Follow-up method that may be called after calling
SerializerProvider.includeFilterInstance(com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition, java.lang.Class<?>) ,
to check handling of `null` values by the filter. |
void |
serializePolymorphic(JsonGenerator gen,
java.lang.Object value,
JavaType rootType,
JsonSerializer<java.lang.Object> valueSer,
TypeSerializer typeSer)
Alternate serialization call used for polymorphic types, when
TypeSerializer
is already known, but the actual serializer may or may not be. |
JsonSerializer<java.lang.Object> |
serializerInstance(Annotated annotated,
java.lang.Object serDef)
Method that can be called to construct and configure serializer instance,
either given a
Class to instantiate (with default constructor),
or an uninitialized serializer instance. |
void |
serializeValue(JsonGenerator gen,
java.lang.Object value)
The method to be called by
ObjectMapper and ObjectWriter
for serializing given value, using serializers that
this provider has access to (via caching and/or creating new serializers
as need be). |
void |
serializeValue(JsonGenerator gen,
java.lang.Object value,
JavaType rootType)
The method to be called by
ObjectMapper and ObjectWriter
for serializing given value (assumed to be of specified root type,
instead of runtime type of value),
using serializers that
this provider has access to (via caching and/or creating new serializers
as need be), |
void |
serializeValue(JsonGenerator gen,
java.lang.Object value,
JavaType rootType,
JsonSerializer<java.lang.Object> ser)
The method to be called by
ObjectWriter
for serializing given value (assumed to be of specified root type,
instead of runtime type of value), when it may know specific
JsonSerializer to use. |
canOverrideAccessModifiers, defaultSerializeDateKey, defaultSerializeDateKey, defaultSerializeDateValue, defaultSerializeDateValue, defaultSerializeField, defaultSerializeNull, defaultSerializeValue, findKeySerializer, findKeySerializer, findNullKeySerializer, findNullValueSerializer, findPrimaryPropertySerializer, findPrimaryPropertySerializer, findTypedValueSerializer, findTypedValueSerializer, findTypeSerializer, findValueSerializer, findValueSerializer, findValueSerializer, findValueSerializer, getActiveView, getAnnotationIntrospector, getAttribute, getConfig, getDefaultNullKeySerializer, getDefaultNullValueSerializer, getDefaultPropertyFormat, getDefaultPropertyInclusion, getFilterProvider, getLocale, getSerializationView, getTimeZone, getTypeFactory, getUnknownTypeSerializer, handlePrimaryContextualization, handleSecondaryContextualization, hasSerializationFeatures, invalidTypeIdException, isEnabled, isEnabled, isUnknownTypeSerializer, mappingException, reportBadDefinition, reportBadDefinition, reportBadDefinition, reportBadPropertyDefinition, reportBadTypeDefinition, reportMappingProblem, reportMappingProblem, setAttribute, setDefaultKeySerializer, setNullKeySerializer, setNullValueSerializer
constructSpecializedType, constructType, converterInstance, objectIdGeneratorInstance, objectIdResolverInstance, reportBadDefinition, resolveAndValidateSubType, resolveSubType
public abstract DefaultSerializerProvider createInstance(SerializationConfig config, SerializerFactory jsf)
public DefaultSerializerProvider copy()
ObjectMapper.copy()
will work
properly; specifically, that caches are cleared, but settings
will otherwise remain identical; and that no sharing of state
occurs.public JsonSerializer<java.lang.Object> serializerInstance(Annotated annotated, java.lang.Object serDef) throws JsonMappingException
SerializerProvider
Class
to instantiate (with default constructor),
or an uninitialized serializer instance.
Either way, serialize will be properly resolved
(via ResolvableSerializer
) and/or contextualized
(via ContextualSerializer
) as necessary.serializerInstance
in class SerializerProvider
annotated
- Annotated entity that contained definitionserDef
- Serializer definition: either an instance or classJsonMappingException
public java.lang.Object includeFilterInstance(BeanPropertyDefinition forProperty, java.lang.Class<?> filterClass)
SerializerProvider
JsonInclude
filter instance,
given a Class
to instantiate (with default constructor, by default).includeFilterInstance
in class SerializerProvider
forProperty
- (optional) If filter is created for a property, that property;
`null` if filter created via defaulting, global or per-type.public boolean includeFilterSuppressNulls(java.lang.Object filter) throws JsonMappingException
SerializerProvider
SerializerProvider.includeFilterInstance(com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition, java.lang.Class<?>)
,
to check handling of `null` values by the filter.includeFilterSuppressNulls
in class SerializerProvider
JsonMappingException
public WritableObjectId findObjectId(java.lang.Object forPojo, ObjectIdGenerator<?> generatorType)
SerializerProvider
findObjectId
in class SerializerProvider
public boolean hasSerializerFor(java.lang.Class<?> cls, java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> cause)
Note that no Exceptions are thrown, including unchecked ones: implementations are to swallow exceptions if necessary.
public JsonGenerator getGenerator()
JsonGenerator
currently in use for serializing
content. Null for blueprint instances; non-null for actual active
provider instances.getGenerator
in class SerializerProvider
public void serializeValue(JsonGenerator gen, java.lang.Object value) throws java.io.IOException
ObjectMapper
and ObjectWriter
for serializing given value, using serializers that
this provider has access to (via caching and/or creating new serializers
as need be).java.io.IOException
public void serializeValue(JsonGenerator gen, java.lang.Object value, JavaType rootType) throws java.io.IOException
ObjectMapper
and ObjectWriter
for serializing given value (assumed to be of specified root type,
instead of runtime type of value),
using serializers that
this provider has access to (via caching and/or creating new serializers
as need be),rootType
- Type to use for locating serializer to use, instead of actual
runtime type. Must be actual type, or one of its super typesjava.io.IOException
public void serializeValue(JsonGenerator gen, java.lang.Object value, JavaType rootType, JsonSerializer<java.lang.Object> ser) throws java.io.IOException
ObjectWriter
for serializing given value (assumed to be of specified root type,
instead of runtime type of value), when it may know specific
JsonSerializer
to use.rootType
- Type to use for locating serializer to use, instead of actual
runtime type, if no serializer is passedser
- Root Serializer to use, if not nulljava.io.IOException
public void serializePolymorphic(JsonGenerator gen, java.lang.Object value, JavaType rootType, JsonSerializer<java.lang.Object> valueSer, TypeSerializer typeSer) throws java.io.IOException
TypeSerializer
is already known, but the actual serializer may or may not be.java.io.IOException
public int cachedSerializersCount()
The main use case for this method is to allow conditional flushing of serializer cache, if certain number of entries is reached.
public void flushCachedSerializers()
public void acceptJsonFormatVisitor(JavaType javaType, JsonFormatVisitorWrapper visitor) throws JsonMappingException
ObjectMapper
and ObjectWriter
to to expose the format of the given to to the given visitorjavaType
- The type for which to generate formatvisitor
- the visitor to accept the formatJsonMappingException
@Deprecated public JsonSchema generateJsonSchema(java.lang.Class<?> type) throws JsonMappingException
ObjectMapper
to generate JSON schema for
given type.type
- The type for which to generate schemaJsonMappingException
Copyright © 2010 - 2020 Adobe. All Rights Reserved