public abstract class TypeSerializerBase extends TypeSerializer
Modifier and Type | Field and Description |
---|---|
protected TypeIdResolver |
_idResolver |
protected BeanProperty |
_property |
Modifier | Constructor and Description |
---|---|
protected |
TypeSerializerBase(TypeIdResolver idRes,
BeanProperty property) |
Modifier and Type | Method and Description |
---|---|
protected void |
_generateTypeId(WritableTypeId idMetadata)
Helper method that will generate type id to use, if not already passed.
|
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.
|
abstract JsonTypeInfo.As |
getTypeInclusion()
Accessor for type information inclusion method
that serializer uses; indicates how type information
is embedded in resulting JSON.
|
protected void |
handleMissingId(Object value) |
protected String |
idFromValue(Object value) |
protected String |
idFromValueAndType(Object value,
Class<?> type) |
WritableTypeId |
writeTypePrefix(JsonGenerator g,
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.
|
WritableTypeId |
writeTypeSuffix(JsonGenerator g,
WritableTypeId idMetadata)
Method that should be called after
TypeSerializer.writeTypePrefix(JsonGenerator, WritableTypeId)
and matching value write have been called, passing WritableTypeId returned. |
_writeLegacySuffix, forProperty, typeId, typeId, typeId, writeCustomTypePrefixForArray, writeCustomTypePrefixForObject, writeCustomTypePrefixForScalar, writeCustomTypeSuffixForArray, writeCustomTypeSuffixForObject, writeCustomTypeSuffixForScalar, writeTypePrefixForArray, writeTypePrefixForArray, writeTypePrefixForObject, writeTypePrefixForObject, writeTypePrefixForScalar, writeTypePrefixForScalar, writeTypeSuffixForArray, writeTypeSuffixForObject, writeTypeSuffixForScalar
protected final TypeIdResolver _idResolver
protected final BeanProperty _property
protected TypeSerializerBase(TypeIdResolver idRes, BeanProperty property)
public abstract JsonTypeInfo.As getTypeInclusion()
TypeSerializer
getTypeInclusion
in class TypeSerializer
public String getPropertyName()
TypeSerializer
getPropertyName
in class TypeSerializer
public TypeIdResolver getTypeIdResolver()
TypeSerializer
getTypeIdResolver
in class TypeSerializer
public WritableTypeId writeTypePrefix(JsonGenerator g, WritableTypeId idMetadata) throws IOException
TypeSerializer
See TypeSerializer.writeTypeSuffix(JsonGenerator, WritableTypeId)
for a complete
example of typical usage.
writeTypePrefix
in class TypeSerializer
g
- Generator to use for outputting type id and possible wrappingidMetadata
- Details of what type id is to be written, how.IOException
public WritableTypeId writeTypeSuffix(JsonGenerator g, WritableTypeId idMetadata) throws IOException
TypeSerializer
TypeSerializer.writeTypePrefix(JsonGenerator, WritableTypeId)
and matching value write have been called, passing WritableTypeId
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);
writeTypeSuffix
in class TypeSerializer
IOException
protected void _generateTypeId(WritableTypeId idMetadata)
protected void handleMissingId(Object value)
Copyright © 2019 JBoss by Red Hat. All rights reserved.