PropertyWriter
Date: 2016-12-04

com.fasterxml.jackson.databind.ser

## Class PropertyWriter

- java.lang.Object
- - com.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase
  - - com.fasterxml.jackson.databind.ser.PropertyWriter

- All Implemented Interfaces:
    BeanProperty, Named, java.io.Serializable
  Direct Known Subclasses:
    BeanPropertyWriter, MapProperty

      public abstract class PropertyWriter
      extends ConcreteBeanPropertyBase
      implements java.io.Serializable

  Base class for writers used to output property values (name-value pairs) as key/value pairs via streaming API. This is the most generic abstraction implemented by both POJO and `Map` serializers, and invoked by filtering functionality.
  Since:
    2.3
  See Also:
    Serialized Form

- - ### Nested Class Summary

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

      `BeanProperty.Std`

  - ### Field Summary

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

      `_metadata, _propertyFormat`

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

      `EMPTY_FORMAT, EMPTY_INCLUDE`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `PropertyWriter(BeanPropertyDefinition propDef)`
    `protected` | `PropertyWriter(PropertyMetadata md)`
    `protected` | `PropertyWriter(PropertyWriter base)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `depositSchemaProperty(JsonObjectFormatVisitor objectVisitor, SerializerProvider provider)` Traversal method used for things like JSON Schema generation, or POJO introspection.
    `abstract void` | `depositSchemaProperty(ObjectNode propertiesNode, SerializerProvider provider)` Deprecated. Since 2.2
    `<A extends java.lang.annotation.Annotation> A` | `findAnnotation(java.lang.Class<A> acls)` Convenience method for accessing annotation that may be associated either directly on property, or, if not, via enclosing class (context).
    `abstract <A extends java.lang.annotation.Annotation> A` | `getAnnotation(java.lang.Class<A> acls)` Method for accessing annotations directly declared for property that this writer is associated with.
    `abstract <A extends java.lang.annotation.Annotation> A` | `getContextAnnotation(java.lang.Class<A> acls)` Method for accessing annotations declared in context of the property that this writer is associated with; usually this means annotations on enclosing class for property.
    `abstract PropertyName` | `getFullName()` Method for getting full name definition, including possible format-specific additional properties (such as namespace when using XML backend).
    `abstract java.lang.String` | `getName()` Method to get logical name of the property
    `abstract void` | `serializeAsElement(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator jgen, SerializerProvider provider)` Serialization method called when output is to be done as an array, that is, not using property names.
    `abstract void` | `serializeAsField(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator jgen, SerializerProvider provider)` The main serialization method called by filter when property is to be written normally.
    `abstract void` | `serializeAsOmittedField(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator jgen, SerializerProvider provider)` Serialization method that filter needs to call in cases where property is to be filtered, but the underlying data format requires a placeholder of some kind.
    `abstract void` | `serializeAsPlaceholder(java.lang.Object value, com.fasterxml.jackson.core.JsonGenerator jgen, SerializerProvider provider)` Serialization method called when doing tabular (positional) output from databind, but then value is to be omitted.

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

      `findFormatOverrides, findPropertyFormat, findPropertyInclusion, getMetadata, isRequired, isVirtual`

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

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

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

      `getMember, getType, getWrapperName`

- - ### Constructor Detail

    - #### PropertyWriter

          protected PropertyWriter(PropertyMetadata md)

    - #### PropertyWriter

          protected PropertyWriter(BeanPropertyDefinition propDef)

    - #### PropertyWriter

          protected PropertyWriter(PropertyWriter base)

  - ### Method Detail

    - #### getName

          public abstract java.lang.String getName()

      Description copied from interface: `BeanProperty`
      Method to get logical name of the property
      Specified by:
        `getName` in interface `BeanProperty`
      Specified by:
        `getName` in interface `Named`

    - #### getFullName

          public abstract PropertyName getFullName()

      Description copied from interface: `BeanProperty`
      Method for getting full name definition, including possible format-specific additional properties (such as namespace when using XML backend).
      Specified by:
        `getFullName` in interface `BeanProperty`

    - #### findAnnotation

          public <A extends java.lang.annotation.Annotation> A findAnnotation(java.lang.Class<A> acls)

      Convenience method for accessing annotation that may be associated either directly on property, or, if not, via enclosing class (context). This allows adding baseline contextual annotations, for example, by adding an annotation for a given class and making that apply to all properties unless overridden by per-property annotations.

      This method is functionally equivalent to:

            MyAnnotation ann = propWriter.getAnnotation(MyAnnotation.class);
            if (ann == null) {
              ann = propWriter.getContextAnnotation(MyAnnotation.class);
            }

      that is, tries to find a property annotation first, but if one is not found, tries to find context-annotation (from enclosing class) of same type.
      Since:
        2.5

    - #### getAnnotation

          public abstract <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.Class<A> acls)

      Method for accessing annotations directly declared for property that this writer is associated with.
      Specified by:
        `getAnnotation` in interface `BeanProperty`
      Since:
        2.5

    - #### getContextAnnotation

          public abstract <A extends java.lang.annotation.Annotation> A getContextAnnotation(java.lang.Class<A> acls)

      Method for accessing annotations declared in context of the property that this writer is associated with; usually this means annotations on enclosing class for property.
      Specified by:
        `getContextAnnotation` in interface `BeanProperty`
      Since:
        2.5

    - #### serializeAsField

          public abstract void serializeAsField(java.lang.Object value,
                              com.fasterxml.jackson.core.JsonGenerator jgen,
                              SerializerProvider provider)
                                         throws java.lang.Exception

      The main serialization method called by filter when property is to be written normally.
      Throws:
        `java.lang.Exception`

    - #### serializeAsOmittedField

          public abstract void serializeAsOmittedField(java.lang.Object value,
                                     com.fasterxml.jackson.core.JsonGenerator jgen,
                                     SerializerProvider provider)
                                                throws java.lang.Exception

      Serialization method that filter needs to call in cases where property is to be filtered, but the underlying data format requires a placeholder of some kind. This is usually the case for tabular (positional) data formats such as CSV.
      Throws:
        `java.lang.Exception`

    - #### serializeAsElement

          public abstract void serializeAsElement(java.lang.Object value,
                                com.fasterxml.jackson.core.JsonGenerator jgen,
                                SerializerProvider provider)
                                           throws java.lang.Exception

      Serialization method called when output is to be done as an array, that is, not using property names. This is needed when serializing container (`Collection`, array) types, or POJOs using `tabular` ("as array") output format.

      Note that this mode of operation is independent of underlying data format; so it is typically NOT called for fully tabular formats such as CSV, where logical output is still as form of POJOs.

      Throws:
        `java.lang.Exception`

    - #### serializeAsPlaceholder

          public abstract void serializeAsPlaceholder(java.lang.Object value,
                                    com.fasterxml.jackson.core.JsonGenerator jgen,
                                    SerializerProvider provider)
                                               throws java.lang.Exception

      Serialization method called when doing tabular (positional) output from databind, but then value is to be omitted. This requires output of a placeholder value of some sort; often similar to `serializeAsOmittedField(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider)`.
      Throws:
        `java.lang.Exception`

    - #### depositSchemaProperty

          public abstract void depositSchemaProperty(JsonObjectFormatVisitor objectVisitor,
                                   SerializerProvider provider)
                                              throws JsonMappingException

      Traversal method used for things like JSON Schema generation, or POJO introspection.
      Specified by:
        `depositSchemaProperty` in interface `BeanProperty`
      Parameters:
        `objectVisitor` - Visitor to used as the callback handler
      Throws:
        `JsonMappingException`

    - #### depositSchemaProperty

          @Deprecated
          public abstract void depositSchemaProperty(ObjectNode propertiesNode,
                                              SerializerProvider provider)
                                              throws JsonMappingException

      Deprecated. Since 2.2
      Legacy method called for JSON Schema generation; should not be called by new code
      Throws:
        `JsonMappingException`