Class JsonValueSerializer.TypeSerializerRerouter
- java.lang.Object
-
- com.fasterxml.jackson.databind.jsontype.TypeSerializer
-
- com.fasterxml.jackson.databind.ser.std.JsonValueSerializer.TypeSerializerRerouter
-
- Enclosing class:
- JsonValueSerializer
static class JsonValueSerializer.TypeSerializerRerouter extends TypeSerializer
Silly little wrapper class we need to re-route type serialization so that we can override Object to use for type id (logical type) even when asking serialization of something else (delegate type)
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object_forObjectprotected TypeSerializer_typeSerializer
-
Constructor Summary
Constructors Constructor Description TypeSerializerRerouter(TypeSerializer ts, java.lang.Object ob)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description TypeSerializerforProperty(BeanProperty prop)Method called to create contextual version, to be used for values of given property.java.lang.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.com.fasterxml.jackson.annotation.JsonTypeInfo.AsgetTypeInclusion()Accessor for type information inclusion method that serializer uses; indicates how type information is embedded in resulting JSON.voidwriteCustomTypePrefixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)Deprecated.voidwriteCustomTypePrefixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)Deprecated.voidwriteCustomTypePrefixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)Deprecated.voidwriteCustomTypeSuffixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)Deprecated.voidwriteCustomTypeSuffixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)Deprecated.voidwriteCustomTypeSuffixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)Deprecated.com.fasterxml.jackson.core.type.WritableTypeIdwriteTypePrefix(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.type.WritableTypeId typeId)Method called to write initial part of type information for given value, along with possible wrapping to use: details are specified by `typeId` argument.voidwriteTypePrefixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen)Deprecated.voidwriteTypePrefixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.Class<?> type)Deprecated.voidwriteTypePrefixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen)Deprecated.voidwriteTypePrefixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.Class<?> type)Deprecated.voidwriteTypePrefixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen)Deprecated.voidwriteTypePrefixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.Class<?> type)Deprecated.com.fasterxml.jackson.core.type.WritableTypeIdwriteTypeSuffix(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.type.WritableTypeId typeId)Method that should be called afterTypeSerializer.writeTypePrefix(JsonGenerator, WritableTypeId)and matching value write have been called, passingWritableTypeIdreturned.voidwriteTypeSuffixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen)Deprecated.voidwriteTypeSuffixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen)Deprecated.voidwriteTypeSuffixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen)Deprecated.-
Methods inherited from class com.fasterxml.jackson.databind.jsontype.TypeSerializer
_writeLegacySuffix, typeId, typeId, typeId
-
-
-
-
Field Detail
-
_typeSerializer
protected final TypeSerializer _typeSerializer
-
_forObject
protected final java.lang.Object _forObject
-
-
Constructor Detail
-
TypeSerializerRerouter
public TypeSerializerRerouter(TypeSerializer ts, java.lang.Object ob)
-
-
Method Detail
-
forProperty
public TypeSerializer forProperty(BeanProperty prop)
Description copied from class:TypeSerializerMethod called to create contextual version, to be used for values of given property. This may be the type itself (as is the case for bean properties), or values contained (forCollectionorMapvalued properties).- Specified by:
forPropertyin classTypeSerializer
-
getTypeInclusion
public 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 java.lang.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 typeId) throws java.io.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 wrappingtypeId- Details of what type id is to be written, how.- Throws:
java.io.IOException
-
writeTypeSuffix
public com.fasterxml.jackson.core.type.WritableTypeId writeTypeSuffix(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.type.WritableTypeId typeId) throws java.io.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:
java.io.IOException
-
writeTypePrefixForScalar
@Deprecated public void writeTypePrefixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypePrefix(g, typeId(value, JsonToken.VALUE_STRING));. SeeTypeSerializer.writeTypePrefix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeTypePrefixForScalarin classTypeSerializer- Throws:
java.io.IOException
-
writeTypePrefixForObject
@Deprecated public void writeTypePrefixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypePrefix(g, typeId(value, JsonToken.START_OBJECT));. SeeTypeSerializer.writeTypePrefix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeTypePrefixForObjectin classTypeSerializer- Throws:
java.io.IOException
-
writeTypePrefixForArray
@Deprecated public void writeTypePrefixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypePrefix(g, typeId(value, JsonToken.START_ARRAY));. SeeTypeSerializer.writeTypePrefix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeTypePrefixForArrayin classTypeSerializer- Throws:
java.io.IOException
-
writeTypeSuffixForScalar
@Deprecated public void writeTypeSuffixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypeSuffix(g, typeId(value, JsonToken.VALUE_STRING));. SeeTypeSerializer.writeTypeSuffix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeTypeSuffixForScalarin classTypeSerializer- Throws:
java.io.IOException
-
writeTypeSuffixForObject
@Deprecated public void writeTypeSuffixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypeSuffix(g, typeId(value, JsonToken.START_OBJECT));. SeeTypeSerializer.writeTypeSuffix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeTypeSuffixForObjectin classTypeSerializer- Throws:
java.io.IOException
-
writeTypeSuffixForArray
@Deprecated public void writeTypeSuffixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypeSuffix(g, typeId(value, JsonToken.START_ARRAY));. SeeTypeSerializer.writeTypeSuffix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeTypeSuffixForArrayin classTypeSerializer- Throws:
java.io.IOException
-
writeTypePrefixForScalar
@Deprecated public void writeTypePrefixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.Class<?> type) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypePrefix(g, typeId(value, type, JsonToken.VALUE_STRING));. SeeTypeSerializer.writeTypePrefix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeTypePrefixForScalarin classTypeSerializer- Throws:
java.io.IOException
-
writeTypePrefixForObject
@Deprecated public void writeTypePrefixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.Class<?> type) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypePrefix(g, typeId(value, type, JsonToken.START_OBJECT));. SeeTypeSerializer.writeTypePrefix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeTypePrefixForObjectin classTypeSerializer- Throws:
java.io.IOException
-
writeTypePrefixForArray
@Deprecated public void writeTypePrefixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.Class<?> type) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypePrefix(g, typeId(value, type, JsonToken.START_ARRAY));. SeeTypeSerializer.writeTypePrefix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeTypePrefixForArrayin classTypeSerializer- Throws:
java.io.IOException
-
writeCustomTypePrefixForScalar
@Deprecated public void writeCustomTypePrefixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypePrefix(g, typeId(value, JsonToken.VALUE_STRING, typeId));. SeeTypeSerializer.writeTypePrefix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeCustomTypePrefixForScalarin classTypeSerializer- Throws:
java.io.IOException
-
writeCustomTypePrefixForObject
@Deprecated public void writeCustomTypePrefixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypePrefix(g, typeId(value, JsonToken.START_OBJECT, typeId));. SeeTypeSerializer.writeTypePrefix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeCustomTypePrefixForObjectin classTypeSerializer- Throws:
java.io.IOException
-
writeCustomTypePrefixForArray
@Deprecated public void writeCustomTypePrefixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId) throws java.io.IOExceptionDeprecated.Description copied from class:TypeSerializerDEPRECATED: now equivalent to:writeTypePrefix(g, typeId(value, JsonToken.START_ARRAY, typeId));. SeeTypeSerializer.writeTypePrefix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)for more info.- Overrides:
writeCustomTypePrefixForArrayin classTypeSerializer- Throws:
java.io.IOException
-
writeCustomTypeSuffixForScalar
@Deprecated public void writeCustomTypeSuffixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId) throws java.io.IOExceptionDeprecated.- Overrides:
writeCustomTypeSuffixForScalarin classTypeSerializer- Throws:
java.io.IOException
-
writeCustomTypeSuffixForObject
@Deprecated public void writeCustomTypeSuffixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId) throws java.io.IOExceptionDeprecated.- Overrides:
writeCustomTypeSuffixForObjectin classTypeSerializer- Throws:
java.io.IOException
-
writeCustomTypeSuffixForArray
@Deprecated public void writeCustomTypeSuffixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId) throws java.io.IOExceptionDeprecated.- Overrides:
writeCustomTypeSuffixForArrayin classTypeSerializer- Throws:
java.io.IOException
-
-