public class BeanSerializer extends BeanSerializerBase
BeanPropertyWriter
s that will handle
access value to serialize and call appropriate serializers to
write out JSON.
Implementation note: we will post-process resulting serializer,
to figure out actual serializers for final types. This must be
done from BeanSerializerBase.resolve(com.fasterxml.jackson.databind.SerializerProvider)
method, and NOT from constructor;
otherwise we could end up with an infinite loop.
JsonSerializer.None
_anyGetterWriter, _beanType, _filteredProps, _objectIdWriter, _propertyFilterId, _props, _serializationShape, _typeId, NAME_FOR_OBJECT_REF, NO_PROPS
_handledType
Modifier | Constructor and Description |
---|---|
protected |
BeanSerializer(BeanSerializerBase src)
Alternate copy constructor that can be used to construct
standard
BeanSerializer passing an instance of
"compatible enough" source serializer. |
protected |
BeanSerializer(BeanSerializerBase src,
ObjectIdWriter objectIdWriter) |
protected |
BeanSerializer(BeanSerializerBase src,
ObjectIdWriter objectIdWriter,
Object filterId) |
protected |
BeanSerializer(BeanSerializerBase src,
Set<String> toIgnore) |
|
BeanSerializer(JavaType type,
BeanSerializerBuilder builder,
BeanPropertyWriter[] properties,
BeanPropertyWriter[] filteredProperties) |
Modifier and Type | Method and Description |
---|---|
protected BeanSerializerBase |
asArraySerializer()
Implementation has to check whether as-array serialization
is possible reliably; if (and only if) so, will construct
a
BeanAsArraySerializer , otherwise will return this
serializer as is. |
static BeanSerializer |
createDummy(JavaType forType)
Deprecated.
Since 2.10
|
static BeanSerializer |
createDummy(JavaType forType,
BeanSerializerBuilder builder)
Method for constructing dummy bean serializer; one that
never outputs any properties
|
void |
serialize(Object bean,
JsonGenerator gen,
SerializerProvider provider)
Main serialization method that will delegate actual output to
configured
BeanPropertyWriter instances. |
String |
toString() |
JsonSerializer<Object> |
unwrappingSerializer(NameTransformer unwrapper)
Method that will return serializer instance that produces
"unwrapped" serialization, if applicable for type being
serialized (which is the case for some serializers
that produce JSON Objects as output).
|
BeanSerializerBase |
withFilterId(Object filterId)
Mutant factory used for creating a new instance with different
filter id (used with
JsonFilter annotation) |
protected 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)
|
BeanSerializerBase |
withObjectIdWriter(ObjectIdWriter objectIdWriter)
Mutant factory used for creating a new instance with different
ObjectIdWriter . |
_customTypeId, _serializeObjectId, _serializeWithObjectId, _serializeWithObjectId, _typeIdDef, acceptJsonFormatVisitor, createContextual, findConvertingSerializer, getSchema, properties, resolve, serializeFields, serializeFieldsFiltered, serializeWithType, usesObjectId, withIgnorals
_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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getSchema
public BeanSerializer(JavaType type, BeanSerializerBuilder builder, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)
builder
- Builder object that contains collected information
that may be needed for serializerproperties
- Property writers used for actual serializationprotected BeanSerializer(BeanSerializerBase src)
BeanSerializer
passing an instance of
"compatible enough" source serializer.protected BeanSerializer(BeanSerializerBase src, ObjectIdWriter objectIdWriter)
protected BeanSerializer(BeanSerializerBase src, ObjectIdWriter objectIdWriter, Object filterId)
protected BeanSerializer(BeanSerializerBase src, Set<String> toIgnore)
@Deprecated public static BeanSerializer createDummy(JavaType forType)
public static BeanSerializer createDummy(JavaType forType, BeanSerializerBuilder builder)
public JsonSerializer<Object> unwrappingSerializer(NameTransformer unwrapper)
JsonSerializer
Default implementation just returns serializer as-is, indicating that no unwrapped variant exists
unwrappingSerializer
in class JsonSerializer<Object>
unwrapper
- Name transformation to use to convert between names
of unwrapper propertiespublic BeanSerializerBase withObjectIdWriter(ObjectIdWriter objectIdWriter)
BeanSerializerBase
ObjectIdWriter
.withObjectIdWriter
in class BeanSerializerBase
public BeanSerializerBase withFilterId(Object filterId)
BeanSerializerBase
JsonFilter
annotation)withFilterId
in class BeanSerializerBase
protected BeanSerializerBase withIgnorals(Set<String> toIgnore)
BeanSerializerBase
withIgnorals
in class BeanSerializerBase
protected BeanSerializerBase asArraySerializer()
BeanAsArraySerializer
, otherwise will return this
serializer as is.asArraySerializer
in class BeanSerializerBase
public final void serialize(Object bean, JsonGenerator gen, SerializerProvider provider) throws IOException
BeanPropertyWriter
instances.serialize
in class BeanSerializerBase
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
Copyright © 2008–2019 FasterXML. All rights reserved.