com.fasterxml.jackson.databind.ser

## 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

      public abstract class VirtualBeanPropertyWriter
      extends BeanPropertyWriter
      implements Serializable

  `BeanPropertyWriter` implementation used with `JsonAppend` to add "virtual" properties in addition to regular ones.
  Since:
    2.5
  See Also:
    `AttributePropertyWriter`, Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.BeanProperty

      `BeanProperty.Bogus, BeanProperty.Std`

  - ### Field Summary

    - ### Fields inherited from class com.fasterxml.jackson.databind.ser.BeanPropertyWriter

      `_accessorMethod, _cfgSerializationType, _contextAnnotations, _declaredType, _dynamicSerializers, _field, _includeInViews, _internalSettings, _member, _name, _nonTrivialBaseType, _nullSerializer, _serializer, _suppressableValue, _suppressNulls, _typeSerializer, _wrapperName, MARKER_FOR_EMPTY`

    - ### Fields inherited from class com.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase

      `_aliases, _metadata, _propertyFormat`

    - ### Fields inherited from interface com.fasterxml.jackson.databind.BeanProperty

      `EMPTY_FORMAT, EMPTY_INCLUDE`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `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 its `withConfig(com.fasterxml.jackson.databind.cfg.MapperConfig<?>, com.fasterxml.jackson.databind.introspect.AnnotatedClass, com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition, com.fasterxml.jackson.databind.JavaType)` method is called.
    `protected` | `VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType)` Constructor used by most sub-types.
    `protected` | `VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, JsonInclude.Value inclusion)` Deprecated.
    `protected` | `VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> 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.
    `protected` | `VirtualBeanPropertyWriter(VirtualBeanPropertyWriter base)`
    `protected` | `VirtualBeanPropertyWriter(VirtualBeanPropertyWriter base, PropertyName name)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static Object` | `_suppressableValue(JsonInclude.Value inclusion)`
    `protected static boolean` | `_suppressNulls(JsonInclude.Value inclusion)`
    `boolean` | `isVirtual()` Accessor for checking whether there is an actual physical property behind this property abstraction or not.
    `void` | `serializeAsElement(Object bean, JsonGenerator gen, SerializerProvider prov)` Alternative to `BeanPropertyWriter.serializeAsField(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider)` that is used when a POJO is serialized as JSON Array; the difference is that no field names are written.
    `void` | `serializeAsField(Object bean, 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 Object` | `value(Object bean, JsonGenerator gen, SerializerProvider prov)` Method called to figure out the value to serialize.
    `abstract VirtualBeanPropertyWriter` | `withConfig(MapperConfig<?> config, AnnotatedClass declaringClass, BeanPropertyDefinition propDef, JavaType type)` Contextualization method called on a newly constructed virtual bean property.

    - ### Methods inherited from class com.fasterxml.jackson.databind.ser.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, wouldConflictWithName`

    - ### Methods inherited from class com.fasterxml.jackson.databind.ser.PropertyWriter

      `findAnnotation`

    - ### Methods inherited from class com.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase

      `findAliases, findFormatOverrides, findPropertyFormat, findPropertyInclusion, getMetadata, isRequired`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### 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 its `withConfig(com.fasterxml.jackson.databind.cfg.MapperConfig<?>, com.fasterxml.jackson.databind.introspect.AnnotatedClass, com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition, com.fasterxml.jackson.databind.JavaType)` method is called.

    - #### VirtualBeanPropertyWriter

          protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef,
                                              Annotations contextAnnotations,
                                              JavaType declaredType,
                                              JsonSerializer<?> 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

          @Deprecated
          protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef,
                                                          Annotations contextAnnotations,
                                                          JavaType declaredType,
                                                          JsonSerializer<?> ser,
                                                          TypeSerializer typeSer,
                                                          JavaType serType,
                                                          JsonInclude.Value inclusion)

      Deprecated.

    - #### VirtualBeanPropertyWriter

          protected VirtualBeanPropertyWriter(VirtualBeanPropertyWriter base)

    - #### VirtualBeanPropertyWriter

          protected VirtualBeanPropertyWriter(VirtualBeanPropertyWriter base,
                                              PropertyName name)

  - ### Method Detail

    - #### _suppressNulls

          protected static boolean _suppressNulls(JsonInclude.Value inclusion)

    - #### _suppressableValue

          protected static Object _suppressableValue(JsonInclude.Value inclusion)

    - #### isVirtual

          public boolean isVirtual()

      Description copied from interface: `BeanProperty`
      Accessor for checking whether there is an actual physical property behind this property abstraction or not.
      Specified by:
        `isVirtual` in interface `BeanProperty`
      Overrides:
        `isVirtual` in class `ConcreteBeanPropertyBase`

    - #### value

          protected abstract Object value(Object bean,
                                          JsonGenerator gen,
                                          SerializerProvider prov)
                                   throws Exception

      Method called to figure out the value to serialize. For simple sub-types (such as `AttributePropertyWriter`) this may be one of few methods to define, although more advanced implementations may choose to not even use this method (by overriding `serializeAsField(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.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 be `SerializationConfig` (just not typed since caller does not have dependency to serialization-specific types)
        `declaringClass` - Class that contains this property writer
        `propDef` - Nominal property definition to use
        `type` - Declared type for the property

    - #### serializeAsField

          public void serializeAsField(Object bean,
                                       JsonGenerator gen,
                                       SerializerProvider prov)
                                throws Exception

      Description copied from class: `BeanPropertyWriter`
      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.
      Overrides:
        `serializeAsField` in class `BeanPropertyWriter`
      Throws:
        `Exception`

    - #### serializeAsElement

          public void serializeAsElement(Object bean,
                                         JsonGenerator gen,
                                         SerializerProvider prov)
                                  throws Exception

      Description copied from class: `BeanPropertyWriter`
      Alternative to `BeanPropertyWriter.serializeAsField(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider)` that is used when a POJO is serialized as JSON Array; the difference is that no field names are written.
      Overrides:
        `serializeAsElement` in class `BeanPropertyWriter`
      Throws:
        `Exception`

Copyright © 2008–2018 FasterXML. All rights reserved.