Class TypeSerializerBase
- java.lang.Object
-
- com.fasterxml.jackson.databind.jsontype.TypeSerializer
-
- com.fasterxml.jackson.databind.jsontype.impl.TypeSerializerBase
-
- Direct Known Subclasses:
AsArrayTypeSerializer,AsExternalTypeSerializer,AsWrapperTypeSerializer
public abstract class TypeSerializerBase extends TypeSerializer
-
-
Field Summary
Fields Modifier and Type Field Description protected TypeIdResolver_idResolverprotected BeanProperty_property
-
Constructor Summary
Constructors Modifier Constructor Description protectedTypeSerializerBase(TypeIdResolver idRes, BeanProperty property)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void_generateTypeId(com.fasterxml.jackson.core.type.WritableTypeId idMetadata)Helper method that will generate type id to use, if not already passed.StringgetPropertyName()Name of property that contains type information, if property-based inclusion is used.TypeIdResolvergetTypeIdResolver()Accessor for object that handles conversions between types and matching type ids.abstract com.fasterxml.jackson.annotation.JsonTypeInfo.AsgetTypeInclusion()Accessor for type information inclusion method that serializer uses; indicates how type information is embedded in resulting JSON.protected voidhandleMissingId(Object value)protected StringidFromValue(Object value)protected StringidFromValueAndType(Object value, Class<?> type)com.fasterxml.jackson.core.type.WritableTypeIdwriteTypePrefix(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.type.WritableTypeId idMetadata)Method called to write initial part of type information for given value, along with possible wrapping to use: details are specified by `typeId` argument.com.fasterxml.jackson.core.type.WritableTypeIdwriteTypeSuffix(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.type.WritableTypeId idMetadata)Method that should be called afterTypeSerializer.writeTypePrefix(JsonGenerator, WritableTypeId)and matching value write have been called, passingWritableTypeIdreturned.-
Methods inherited from class com.fasterxml.jackson.databind.jsontype.TypeSerializer
_writeLegacySuffix, forProperty, typeId, typeId, typeId, writeCustomTypePrefixForArray, writeCustomTypePrefixForObject, writeCustomTypePrefixForScalar, writeCustomTypeSuffixForArray, writeCustomTypeSuffixForObject, writeCustomTypeSuffixForScalar, writeTypePrefixForArray, writeTypePrefixForArray, writeTypePrefixForObject, writeTypePrefixForObject, writeTypePrefixForScalar, writeTypePrefixForScalar, writeTypeSuffixForArray, writeTypeSuffixForObject, writeTypeSuffixForScalar
-
-
-
-
Field Detail
-
_idResolver
protected final TypeIdResolver _idResolver
-
_property
protected final BeanProperty _property
-
-
Constructor Detail
-
TypeSerializerBase
protected TypeSerializerBase(TypeIdResolver idRes, BeanProperty property)
-
-
Method Detail
-
getTypeInclusion
public abstract com.fasterxml.jackson.annotation.JsonTypeInfo.As getTypeInclusion()
Description copied from class:TypeSerializerAccessor for type information inclusion method that serializer uses; indicates how type information is embedded in resulting JSON.- Specified by:
getTypeInclusionin classTypeSerializer
-
getPropertyName
public String getPropertyName()
Description copied from class:TypeSerializerName of property that contains type information, if property-based inclusion is used.- Specified by:
getPropertyNamein classTypeSerializer
-
getTypeIdResolver
public TypeIdResolver getTypeIdResolver()
Description copied from class:TypeSerializerAccessor for object that handles conversions between types and matching type ids.- Specified by:
getTypeIdResolverin classTypeSerializer
-
writeTypePrefix
public com.fasterxml.jackson.core.type.WritableTypeId writeTypePrefix(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.type.WritableTypeId idMetadata) throws IOExceptionDescription copied from class:TypeSerializerMethod called to write initial part of type information for given value, along with possible wrapping to use: details are specified by `typeId` argument. Note that for structured types (Object, Array), this call will add necessary start token so it should NOT be explicitly written, unlike with non-type-id value writes.See
TypeSerializer.writeTypeSuffix(JsonGenerator, WritableTypeId)for a complete example of typical usage.- Specified by:
writeTypePrefixin classTypeSerializer- Parameters:
g- Generator to use for outputting type id and possible wrappingidMetadata- Details of what type id is to be written, how.- Throws:
IOException
-
writeTypeSuffix
public com.fasterxml.jackson.core.type.WritableTypeId writeTypeSuffix(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.type.WritableTypeId idMetadata) throws IOExceptionDescription copied from class:TypeSerializerMethod that should be called afterTypeSerializer.writeTypePrefix(JsonGenerator, WritableTypeId)and matching value write have been called, passingWritableTypeIdreturned. Usual idiom is:// Indicator generator that type identifier may be needed; generator may write // one as suggested, modify information, or take some other action // NOTE! For Object/Array types, this will ALSO write start marker! WritableTypeId typeIdDef = typeSer.writeTypePrefix(gen, typeSer.typeId(value, JsonToken.START_OBJECT)); // serializing actual value for which TypeId may have been written... like // NOTE: do NOT write START_OBJECT before OR END_OBJECT after: g.writeStringField("message", "Hello, world!" // matching type suffix call to let generator chance to add suffix, if any // NOTE! For Object/Array types, this will ALSO write end marker! typeSer.writeTypeSuffix(gen, typeIdDef);- Specified by:
writeTypeSuffixin classTypeSerializer- Throws:
IOException
-
_generateTypeId
protected void _generateTypeId(com.fasterxml.jackson.core.type.WritableTypeId idMetadata)
Helper method that will generate type id to use, if not already passed.- Since:
- 2.9
-
handleMissingId
protected void handleMissingId(Object value)
-
-