public abstract class BeanSerializerBase extends StdSerializer<Object> implements ContextualSerializer, ResolvableSerializer, JsonFormatVisitable, SchemaAware
JsonSerializer.None
Modifier and Type | Field and Description |
---|---|
protected AnyGetterWriter |
_anyGetterWriter
Handler for
JsonAnyGetter
annotated properties |
protected JavaType |
_beanType |
protected BeanPropertyWriter[] |
_filteredProps
Optional filters used to suppress output of properties that
are only to be included in certain views
|
protected ObjectIdWriter |
_objectIdWriter
If this POJO can be alternatively serialized using just an object id
to denote a reference to previously serialized object,
this Object will handle details.
|
protected Object |
_propertyFilterId
Id of the bean property filter to use, if any; null if none.
|
protected BeanPropertyWriter[] |
_props
Writers used for outputting actual property values
|
protected JsonFormat.Shape |
_serializationShape
Requested shape from bean class annotations.
|
protected AnnotatedMember |
_typeId
If using custom type ids (usually via getter, or field), this is the
reference to that member.
|
protected static PropertyName |
NAME_FOR_OBJECT_REF |
protected static BeanPropertyWriter[] |
NO_PROPS |
_handledType
Modifier | Constructor and Description |
---|---|
protected |
BeanSerializerBase(BeanSerializerBase src)
Copy-constructor that is useful for sub-classes that just want to
copy all super-class properties without modifications.
|
|
BeanSerializerBase(BeanSerializerBase src,
BeanPropertyWriter[] properties,
BeanPropertyWriter[] filteredProperties) |
protected |
BeanSerializerBase(BeanSerializerBase src,
NameTransformer unwrapper)
Copy-constructor that will also rename properties with given prefix
(if it's non-empty)
|
protected |
BeanSerializerBase(BeanSerializerBase src,
ObjectIdWriter objectIdWriter) |
protected |
BeanSerializerBase(BeanSerializerBase src,
ObjectIdWriter objectIdWriter,
Object filterId) |
protected |
BeanSerializerBase(BeanSerializerBase src,
Set<String> toIgnore) |
protected |
BeanSerializerBase(BeanSerializerBase src,
String[] toIgnore)
Deprecated.
|
protected |
BeanSerializerBase(JavaType type,
BeanSerializerBuilder builder,
BeanPropertyWriter[] properties,
BeanPropertyWriter[] filteredProperties)
Constructor used by
BeanSerializerBuilder to create an
instance |
Modifier and Type | Method and Description |
---|---|
protected String |
_customTypeId(Object bean)
Deprecated.
|
protected void |
_serializeObjectId(Object bean,
JsonGenerator g,
SerializerProvider provider,
TypeSerializer typeSer,
WritableObjectId objectId) |
protected void |
_serializeWithObjectId(Object bean,
JsonGenerator gen,
SerializerProvider provider,
boolean startEndObject) |
protected void |
_serializeWithObjectId(Object bean,
JsonGenerator gen,
SerializerProvider provider,
TypeSerializer typeSer) |
protected WritableTypeId |
_typeIdDef(TypeSerializer typeSer,
Object bean,
JsonToken valueShape) |
void |
acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,
JavaType typeHint)
Default implementation specifies no format.
|
protected abstract BeanSerializerBase |
asArraySerializer()
Mutant factory for creating a variant that output POJO as a
JSON Array.
|
JsonSerializer<?> |
createContextual(SerializerProvider provider,
BeanProperty property)
Method called to see if a different (or differently configured) serializer
is needed to serialize values of specified property.
|
protected JsonSerializer<Object> |
findConvertingSerializer(SerializerProvider provider,
BeanPropertyWriter prop)
Helper method that can be used to see if specified property is annotated
to indicate use of a converter for property value (in case of container types,
it is container type itself, not key or content type).
|
JsonNode |
getSchema(SerializerProvider provider,
Type typeHint)
Deprecated.
|
Iterator<PropertyWriter> |
properties()
Accessor for iterating over logical properties that the type
handled by this serializer has, from serialization perspective.
|
void |
resolve(SerializerProvider provider)
We need to implement
ResolvableSerializer to be able to
properly handle cyclic type references. |
abstract void |
serialize(Object bean,
JsonGenerator gen,
SerializerProvider provider)
Method that can be called to ask implementation to serialize
values of type this serializer handles.
|
protected void |
serializeFields(Object bean,
JsonGenerator gen,
SerializerProvider provider) |
protected void |
serializeFieldsFiltered(Object bean,
JsonGenerator gen,
SerializerProvider provider)
Alternative serialization method that gets called when there is a
PropertyFilter that needs to be called to determine
which properties are to be serialized (and possibly how) |
void |
serializeWithType(Object bean,
JsonGenerator gen,
SerializerProvider provider,
TypeSerializer typeSer)
Method that can be called to ask implementation to serialize
values of type this serializer handles, using specified type serializer
for embedding necessary type information.
|
boolean |
usesObjectId()
Method that can be called to see whether this serializer instance
will use Object Id to handle cyclic references.
|
abstract BeanSerializerBase |
withFilterId(Object filterId)
Mutant factory used for creating a new instance with different
filter id (used with
JsonFilter annotation) |
protected abstract BeanSerializerBase |
withIgnorals(Set<String> toIgnore)
Mutant factory used for creating a new instance with additional
set of properties to ignore (from properties this instance otherwise has)
|
protected BeanSerializerBase |
withIgnorals(String[] toIgnore)
Deprecated.
since 2.8
|
abstract BeanSerializerBase |
withObjectIdWriter(ObjectIdWriter objectIdWriter)
Mutant factory used for creating a new instance with different
ObjectIdWriter . |
_neitherNull, _nonEmpty, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findConvertingContentSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, getSchema, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrow
getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, replaceDelegatee, unwrappingSerializer
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSchema
protected static final PropertyName NAME_FOR_OBJECT_REF
protected static final BeanPropertyWriter[] NO_PROPS
protected final JavaType _beanType
protected final BeanPropertyWriter[] _props
protected final BeanPropertyWriter[] _filteredProps
protected final AnyGetterWriter _anyGetterWriter
JsonAnyGetter
annotated propertiesprotected final Object _propertyFilterId
protected final AnnotatedMember _typeId
protected final ObjectIdWriter _objectIdWriter
protected final JsonFormat.Shape _serializationShape
protected BeanSerializerBase(JavaType type, BeanSerializerBuilder builder, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)
BeanSerializerBuilder
to create an
instancetype
- Nominal type of values handled by this serializerbuilder
- Builder for accessing other collected informationpublic BeanSerializerBase(BeanSerializerBase src, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)
protected BeanSerializerBase(BeanSerializerBase src, ObjectIdWriter objectIdWriter)
protected BeanSerializerBase(BeanSerializerBase src, ObjectIdWriter objectIdWriter, Object filterId)
@Deprecated protected BeanSerializerBase(BeanSerializerBase src, String[] toIgnore)
protected BeanSerializerBase(BeanSerializerBase src, Set<String> toIgnore)
protected BeanSerializerBase(BeanSerializerBase src)
protected BeanSerializerBase(BeanSerializerBase src, NameTransformer unwrapper)
public abstract BeanSerializerBase withObjectIdWriter(ObjectIdWriter objectIdWriter)
ObjectIdWriter
.protected abstract BeanSerializerBase withIgnorals(Set<String> toIgnore)
@Deprecated protected BeanSerializerBase withIgnorals(String[] toIgnore)
protected abstract BeanSerializerBase asArraySerializer()
public abstract BeanSerializerBase withFilterId(Object filterId)
JsonFilter
annotation)withFilterId
in class JsonSerializer<Object>
public void resolve(SerializerProvider provider) throws JsonMappingException
ResolvableSerializer
to be able to
properly handle cyclic type references.resolve
in interface ResolvableSerializer
provider
- Provider that has constructed serializer this method
is called on.JsonMappingException
protected JsonSerializer<Object> findConvertingSerializer(SerializerProvider provider, BeanPropertyWriter prop) throws JsonMappingException
JsonMappingException
public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException
ContextualSerializer
createContextual
in interface ContextualSerializer
provider
- Serializer provider to use for accessing config, other serializersproperty
- Method or field that represents the property
(and is used to access value to serialize).
Should be available; but there may be cases where caller cannot provide it and
null is passed instead (in which case impls usually pass 'this' serializer as is)JsonMappingException
public Iterator<PropertyWriter> properties()
JsonSerializer
BeanPropertyWriter
.
Of standard Jackson serializers, only BeanSerializer
exposes properties.properties
in class JsonSerializer<Object>
public boolean usesObjectId()
JsonSerializer
usesObjectId
in class JsonSerializer<Object>
public abstract void serialize(Object bean, JsonGenerator gen, SerializerProvider provider) throws IOException
JsonSerializer
serialize
in class StdSerializer<Object>
bean
- Value to serialize; can not be null.gen
- Generator used to output resulting Json contentprovider
- Provider that can be used to get serializers for
serializing Objects value contains, if any.IOException
public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException
JsonSerializer
Default implementation will throw UnsupportedOperationException
to indicate that proper type handling needs to be implemented.
For simple datatypes written as a single scalar value (JSON String, Number, Boolean), implementation would look like:
// note: method to call depends on whether this type is serialized as JSON scalar, object or Array! typeSer.writeTypePrefixForScalar(value, gen); serialize(value, gen, provider); typeSer.writeTypeSuffixForScalar(value, gen);and implementations for type serialized as JSON Arrays or Objects would differ slightly, as
START-ARRAY
/END-ARRAY
and
START-OBJECT
/END-OBJECT
pairs
need to be properly handled with respect to serializing of contents.serializeWithType
in class JsonSerializer<Object>
bean
- Value to serialize; can not be null.gen
- Generator used to output resulting Json contentprovider
- Provider that can be used to get serializers for
serializing Objects value contains, if any.typeSer
- Type serializer to use for including type informationIOException
protected final void _serializeWithObjectId(Object bean, JsonGenerator gen, SerializerProvider provider, boolean startEndObject) throws IOException
IOException
protected final void _serializeWithObjectId(Object bean, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException
IOException
protected void _serializeObjectId(Object bean, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer, WritableObjectId objectId) throws IOException
IOException
protected final WritableTypeId _typeIdDef(TypeSerializer typeSer, Object bean, JsonToken valueShape)
@Deprecated protected final String _customTypeId(Object bean)
protected void serializeFields(Object bean, JsonGenerator gen, SerializerProvider provider) throws IOException
IOException
protected void serializeFieldsFiltered(Object bean, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonGenerationException
PropertyFilter
that needs to be called to determine
which properties are to be serialized (and possibly how)IOException
JsonGenerationException
@Deprecated public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException
StdSerializer
getSchema
in interface SchemaAware
getSchema
in class StdSerializer<Object>
provider
- The serializer provider.typeHint
- A hint about the type.JsonMappingException
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
StdSerializer
acceptJsonFormatVisitor
in interface JsonFormatVisitable
acceptJsonFormatVisitor
in class StdSerializer<Object>
typeHint
- Type of element (entity like property) being visitedJsonMappingException
Copyright © 2018 JBoss by Red Hat. All rights reserved.