java.lang.Object
tools.jackson.databind.introspect.ConcreteBeanPropertyBase
tools.jackson.databind.ser.PropertyWriter
tools.jackson.databind.ser.BeanPropertyWriter
tools.jackson.databind.ser.VirtualBeanPropertyWriter
- All Implemented Interfaces:
Named,BeanProperty,FullyNamed
- Direct Known Subclasses:
AttributePropertyWriter
BeanPropertyWriter implementation used with
JsonAppend
to add "virtual" properties in addition to regular ones.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface tools.jackson.databind.BeanProperty
BeanProperty.Bogus, BeanProperty.StdNested classes/interfaces inherited from interface tools.jackson.core.util.Named
Named.StringAsNamed -
Field Summary
Fields inherited from class tools.jackson.databind.ser.BeanPropertyWriter
_accessor, _cfgSerializationType, _contextAnnotations, _declaredType, _dynamicSerializers, _includeInViews, _internalSettings, _member, _name, _nonTrivialBaseType, _nullSerializer, _serializer, _suppressableValue, _suppressNulls, _typeSerializer, _wrapperName, MARKER_FOR_EMPTYFields inherited from class tools.jackson.databind.introspect.ConcreteBeanPropertyBase
_aliases, _metadataFields inherited from interface tools.jackson.databind.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(tools.jackson.databind.cfg.MapperConfig<?>, tools.jackson.databind.introspect.AnnotatedClass, tools.jackson.databind.introspect.BeanPropertyDefinition, tools.jackson.databind.JavaType)method is called.protectedVirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType) Constructor used by most sub-types.protectedVirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, ValueSerializer<?> ser, TypeSerializer typeSer, JavaType serType, 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(JsonInclude.Value inclusion) protected static boolean_suppressNulls(JsonInclude.Value inclusion) booleanAccessor for checking whether there is an actual physical property behind this property abstraction or not.voidserializeAsElement(Object bean, JsonGenerator g, SerializationContext prov) Alternative toBeanPropertyWriter.serializeAsProperty(java.lang.Object, tools.jackson.core.JsonGenerator, tools.jackson.databind.SerializationContext)that is used when a POJO is serialized as JSON Array (usually when "Shape" is forced as 'Array'): the difference is that no property names are written.voidserializeAsProperty(Object bean, JsonGenerator g, SerializationContext 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, JsonGenerator g, SerializationContext 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 tools.jackson.databind.ser.BeanPropertyWriter
_depositSchemaProperty, _findAndAddDynamic, _handleSelfReference, _new, assignNullSerializer, assignSerializer, assignTypeSerializer, depositSchemaProperty, fixAccess, get, getAnnotation, getContextAnnotation, getFullName, getInternalSetting, getMember, getName, getSerializationType, getSerializedName, getSerializer, getType, getTypeSerializer, getViews, getWrapperName, hasNullSerializer, hasSerializer, isUnwrapping, removeInternalSetting, rename, serializeAsOmittedElement, serializeAsOmittedProperty, setInternalSetting, setNonTrivialBaseType, toString, unwrappingWriter, willSuppressNulls, wouldConflictWithNameMethods inherited from class tools.jackson.databind.ser.PropertyWriter
findAnnotationMethods inherited from class tools.jackson.databind.introspect.ConcreteBeanPropertyBase
findAliases, findFormatOverrides, findPropertyFormat, findPropertyInclusion, getMetadata, isRequiredMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface tools.jackson.databind.util.FullyNamed
hasName
-
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(tools.jackson.databind.cfg.MapperConfig<?>, tools.jackson.databind.introspect.AnnotatedClass, tools.jackson.databind.introspect.BeanPropertyDefinition, tools.jackson.databind.JavaType)method is called. -
VirtualBeanPropertyWriter
protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, ValueSerializer<?> ser, TypeSerializer typeSer, JavaType serType, JsonInclude.Value inclusion, Class<?>[] includeInViews) Pass-through constructor that may be used by sub-classes that want full control over implementation. -
VirtualBeanPropertyWriter
-
VirtualBeanPropertyWriter
-
-
Method Details
-
_suppressNulls
-
_suppressableValue
-
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, JsonGenerator g, SerializationContext 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 overridingserializeAsProperty(java.lang.Object, tools.jackson.core.JsonGenerator, tools.jackson.databind.SerializationContext)) 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
-
serializeAsProperty
public void serializeAsProperty(Object bean, JsonGenerator g, SerializationContext 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:
serializeAsPropertyin classBeanPropertyWriter- Throws:
Exception
-
serializeAsElement
public void serializeAsElement(Object bean, JsonGenerator g, SerializationContext prov) throws Exception Description copied from class:BeanPropertyWriterAlternative toBeanPropertyWriter.serializeAsProperty(java.lang.Object, tools.jackson.core.JsonGenerator, tools.jackson.databind.SerializationContext)that is used when a POJO is serialized as JSON Array (usually when "Shape" is forced as 'Array'): the difference is that no property names are written.- Overrides:
serializeAsElementin classBeanPropertyWriter- Throws:
Exception
-