Class VirtualBeanPropertyWriter
java.lang.Object
com.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase
com.fasterxml.jackson.databind.ser.PropertyWriter
com.fasterxml.jackson.databind.ser.BeanPropertyWriter
com.fasterxml.jackson.databind.ser.VirtualBeanPropertyWriter
- All Implemented Interfaces:
BeanProperty, Named, Serializable
- Direct Known Subclasses:
AttributePropertyWriter
BeanPropertyWriter implementation used with
JsonAppend
to add "virtual" properties in addition to regular ones.- Since:
- 2.5
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface BeanProperty
BeanProperty.Bogus, BeanProperty.Std -
Field Summary
Fields inherited from class BeanPropertyWriter
_accessorMethod, _cfgSerializationType, _contextAnnotations, _declaredType, _dynamicSerializers, _field, _includeInViews, _internalSettings, _member, _name, _nonTrivialBaseType, _nullSerializer, _serializer, _suppressableValue, _suppressNulls, _typeSerializer, _wrapperName, MARKER_FOR_EMPTYFields inherited from class ConcreteBeanPropertyBase
_aliases, _metadataFields inherited from interface BeanProperty
EMPTY_FORMAT, EMPTY_INCLUDE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor that may be used by sub-classes for constructing a "blue-print" instance; one that will only become (or create) actual usable instance when itswithConfig(MapperConfig, AnnotatedClass, BeanPropertyDefinition, JavaType)method is called.protectedVirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType) Constructor used by most sub-types.protectedVirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, com.fasterxml.jackson.annotation.JsonInclude.Value inclusion) Deprecated.protectedVirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, com.fasterxml.jackson.annotation.JsonInclude.Value inclusion, Class<?>[] includeInViews) Pass-through constructor that may be used by sub-classes that want full control over implementation.protectedprotected -
Method Summary
Modifier and TypeMethodDescriptionprotected static Object_suppressableValue(com.fasterxml.jackson.annotation.JsonInclude.Value inclusion) protected static boolean_suppressNulls(com.fasterxml.jackson.annotation.JsonInclude.Value inclusion) booleanAccessor for checking whether there is an actual physical property behind this property abstraction or not.voidserializeAsElement(Object bean, com.fasterxml.jackson.core.JsonGenerator gen, SerializerProvider prov) Alternative toBeanPropertyWriter.serializeAsField(Object, JsonGenerator, SerializerProvider)that is used when a POJO is serialized as JSON Array; the difference is that no field names are written.voidserializeAsField(Object bean, com.fasterxml.jackson.core.JsonGenerator gen, SerializerProvider prov) Method called to access property that this bean stands for, from within given bean, and to serialize it as a JSON Object field using appropriate serializer.protected abstract Objectvalue(Object bean, com.fasterxml.jackson.core.JsonGenerator gen, SerializerProvider prov) Method called to figure out the value to serialize.abstract VirtualBeanPropertyWriterwithConfig(MapperConfig<?> config, AnnotatedClass declaringClass, BeanPropertyDefinition propDef, JavaType type) Contextualization method called on a newly constructed virtual bean property.Methods inherited from class BeanPropertyWriter
_depositSchemaProperty, _findAndAddDynamic, _handleSelfReference, _new, assignNullSerializer, assignSerializer, assignTypeSerializer, depositSchemaProperty, depositSchemaProperty, fixAccess, get, getAnnotation, getContextAnnotation, getFullName, getGenericPropertyType, getInternalSetting, getMember, getName, getPropertyType, getRawSerializationType, getSerializationType, getSerializedName, getSerializer, getType, getTypeSerializer, getViews, getWrapperName, hasNullSerializer, hasSerializer, isUnwrapping, removeInternalSetting, rename, serializeAsOmittedField, serializeAsPlaceholder, setInternalSetting, setNonTrivialBaseType, toString, unwrappingWriter, willSuppressNulls, wouldConflictWithNameMethods inherited from class PropertyWriter
findAnnotationMethods inherited from class ConcreteBeanPropertyBase
findAliases, findFormatOverrides, findPropertyFormat, findPropertyInclusion, getMetadata, isRequired
-
Constructor Details
-
VirtualBeanPropertyWriter
protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType) Constructor used by most sub-types. -
VirtualBeanPropertyWriter
protected VirtualBeanPropertyWriter()Constructor that may be used by sub-classes for constructing a "blue-print" instance; one that will only become (or create) actual usable instance when itswithConfig(MapperConfig, AnnotatedClass, BeanPropertyDefinition, JavaType)method is called. -
VirtualBeanPropertyWriter
protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, com.fasterxml.jackson.annotation.JsonInclude.Value inclusion, Class<?>[] includeInViews) Pass-through constructor that may be used by sub-classes that want full control over implementation. -
VirtualBeanPropertyWriter
@Deprecated protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, com.fasterxml.jackson.annotation.JsonInclude.Value inclusion) Deprecated. -
VirtualBeanPropertyWriter
-
VirtualBeanPropertyWriter
-
-
Method Details
-
_suppressNulls
protected static boolean _suppressNulls(com.fasterxml.jackson.annotation.JsonInclude.Value inclusion) -
_suppressableValue
protected static Object _suppressableValue(com.fasterxml.jackson.annotation.JsonInclude.Value inclusion) -
isVirtual
public boolean isVirtual()Description copied from interface:BeanPropertyAccessor for checking whether there is an actual physical property behind this property abstraction or not.- Specified by:
isVirtualin interfaceBeanProperty- Overrides:
isVirtualin classConcreteBeanPropertyBase
-
value
protected abstract Object value(Object bean, com.fasterxml.jackson.core.JsonGenerator gen, SerializerProvider prov) throws Exception Method called to figure out the value to serialize. For simple sub-types (such asAttributePropertyWriter) this may be one of few methods to define, although more advanced implementations may choose to not even use this method (by overridingserializeAsField(Object, JsonGenerator, SerializerProvider)) and define a bogus implementation.- Throws:
Exception
-
withConfig
public abstract VirtualBeanPropertyWriter withConfig(MapperConfig<?> config, AnnotatedClass declaringClass, BeanPropertyDefinition propDef, JavaType type) Contextualization method called on a newly constructed virtual bean property. Usually a new intance needs to be created due to finality of some of configuration members; otherwise while recommended, creating a new instance is not strictly-speaking mandatory because calls are made in thread-safe manner, as part of initialization before use.- Parameters:
config- Currenct configuration; guaranteed to beSerializationConfig(just not typed since caller does not have dependency to serialization-specific types)declaringClass- Class that contains this property writerpropDef- Nominal property definition to usetype- Declared type for the property
-
serializeAsField
public void serializeAsField(Object bean, com.fasterxml.jackson.core.JsonGenerator gen, SerializerProvider prov) throws Exception Description copied from class:BeanPropertyWriterMethod called to access property that this bean stands for, from within given bean, and to serialize it as a JSON Object field using appropriate serializer.- Overrides:
serializeAsFieldin classBeanPropertyWriter- Throws:
Exception
-
serializeAsElement
public void serializeAsElement(Object bean, com.fasterxml.jackson.core.JsonGenerator gen, SerializerProvider prov) throws Exception Description copied from class:BeanPropertyWriterAlternative toBeanPropertyWriter.serializeAsField(Object, JsonGenerator, SerializerProvider)that is used when a POJO is serialized as JSON Array; the difference is that no field names are written.- Overrides:
serializeAsElementin classBeanPropertyWriter- Throws:
Exception
-