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
_forObject
protected 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 TypeSerializer
forProperty(BeanProperty prop)
Method called to create contextual version, to be used for values of given property.java.lang.String
getPropertyName()
Name of property that contains type information, if property-based inclusion is used.TypeIdResolver
getTypeIdResolver()
Accessor for object that handles conversions between types and matching type ids.com.fasterxml.jackson.annotation.JsonTypeInfo.As
getTypeInclusion()
Accessor for type information inclusion method that serializer uses; indicates how type information is embedded in resulting JSON.void
writeCustomTypePrefixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)
Deprecated.void
writeCustomTypePrefixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)
Deprecated.void
writeCustomTypePrefixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)
Deprecated.void
writeCustomTypeSuffixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)
Deprecated.void
writeCustomTypeSuffixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)
Deprecated.void
writeCustomTypeSuffixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.String typeId)
Deprecated.com.fasterxml.jackson.core.type.WritableTypeId
writeTypePrefix(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.void
writeTypePrefixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen)
Deprecated.void
writeTypePrefixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.Class<?> type)
Deprecated.void
writeTypePrefixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen)
Deprecated.void
writeTypePrefixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.Class<?> type)
Deprecated.void
writeTypePrefixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen)
Deprecated.void
writeTypePrefixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen, java.lang.Class<?> type)
Deprecated.com.fasterxml.jackson.core.type.WritableTypeId
writeTypeSuffix(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, passingWritableTypeId
returned.void
writeTypeSuffixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen)
Deprecated.void
writeTypeSuffixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen)
Deprecated.void
writeTypeSuffixForScalar(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:TypeSerializer
Method 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 (forCollection
orMap
valued properties).- Specified by:
forProperty
in classTypeSerializer
-
getTypeInclusion
public com.fasterxml.jackson.annotation.JsonTypeInfo.As getTypeInclusion()
Description copied from class:TypeSerializer
Accessor for type information inclusion method that serializer uses; indicates how type information is embedded in resulting JSON.- Specified by:
getTypeInclusion
in classTypeSerializer
-
getPropertyName
public java.lang.String getPropertyName()
Description copied from class:TypeSerializer
Name of property that contains type information, if property-based inclusion is used.- Specified by:
getPropertyName
in classTypeSerializer
-
getTypeIdResolver
public TypeIdResolver getTypeIdResolver()
Description copied from class:TypeSerializer
Accessor for object that handles conversions between types and matching type ids.- Specified by:
getTypeIdResolver
in 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.IOException
Description copied from class:TypeSerializer
Method 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:
writeTypePrefix
in 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.IOException
Description copied from class:TypeSerializer
Method that should be called afterTypeSerializer.writeTypePrefix(JsonGenerator, WritableTypeId)
and matching value write have been called, passingWritableTypeId
returned. 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:
writeTypeSuffix
in classTypeSerializer
- Throws:
java.io.IOException
-
writeTypePrefixForScalar
@Deprecated public void writeTypePrefixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeTypePrefixForScalar
in classTypeSerializer
- Throws:
java.io.IOException
-
writeTypePrefixForObject
@Deprecated public void writeTypePrefixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeTypePrefixForObject
in classTypeSerializer
- Throws:
java.io.IOException
-
writeTypePrefixForArray
@Deprecated public void writeTypePrefixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeTypePrefixForArray
in classTypeSerializer
- Throws:
java.io.IOException
-
writeTypeSuffixForScalar
@Deprecated public void writeTypeSuffixForScalar(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeTypeSuffixForScalar
in classTypeSerializer
- Throws:
java.io.IOException
-
writeTypeSuffixForObject
@Deprecated public void writeTypeSuffixForObject(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeTypeSuffixForObject
in classTypeSerializer
- Throws:
java.io.IOException
-
writeTypeSuffixForArray
@Deprecated public void writeTypeSuffixForArray(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeTypeSuffixForArray
in 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.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeTypePrefixForScalar
in 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.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeTypePrefixForObject
in 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.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeTypePrefixForArray
in 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.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeCustomTypePrefixForScalar
in 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.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeCustomTypePrefixForObject
in 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.IOException
Deprecated.Description copied from class:TypeSerializer
DEPRECATED: 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:
writeCustomTypePrefixForArray
in 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.IOException
Deprecated.- Overrides:
writeCustomTypeSuffixForScalar
in 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.IOException
Deprecated.- Overrides:
writeCustomTypeSuffixForObject
in 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.IOException
Deprecated.- Overrides:
writeCustomTypeSuffixForArray
in classTypeSerializer
- Throws:
java.io.IOException
-
-