Class POJOPropertyBuilder

java.lang.Object
tools.jackson.databind.introspect.BeanPropertyDefinition
tools.jackson.databind.introspect.POJOPropertyBuilder
All Implemented Interfaces:
Comparable<POJOPropertyBuilder>, Named, FullyNamed

public class POJOPropertyBuilder extends BeanPropertyDefinition implements Comparable<POJOPropertyBuilder>
Helper class used for aggregating information about a single potential POJO property.
  • Field Details

    • _forSerialization

      protected final boolean _forSerialization
      Whether property is being composed for serialization (true) or deserialization (false)
    • _config

      protected final MapperConfig<?> _config
    • _annotationIntrospector

      protected final AnnotationIntrospector _annotationIntrospector
    • _name

      protected final PropertyName _name
      External name of logical property; may change with renaming (by new instance being constructed using a new name)
    • _internalName

      protected final PropertyName _internalName
      Original internal name, derived from accessor, of this property. Will not be changed by renaming.
    • _fields

    • _ctorParameters

      protected POJOPropertyBuilder.Linked<AnnotatedParameter> _ctorParameters
    • _getters

    • _setters

    • _metadata

      protected transient PropertyMetadata _metadata
    • _referenceInfo

      protected transient AnnotationIntrospector.ReferenceProperty _referenceInfo
      Lazily accessed information about this property iff it is a forward or back reference.
      Since:
      2.9
    • _unwrapped

      protected boolean _unwrapped
      Flag that indicates this property is marked with @JsonUnwrapped. When set on a creator (constructor) parameter, the property uses a placeholder as its external name to avoid conflicts during deserialization, while _internalName holds the actual implicit parameter name used for declaration-order sorting.
      Since:
      3.1.1
  • Constructor Details

  • Method Details

    • withName

      public POJOPropertyBuilder withName(PropertyName newName)
      Description copied from class: BeanPropertyDefinition
      Method that can be used to create a definition with same settings as this one, but with different (external) name; that is, one for which Named.getName() would return newName.
      Specified by:
      withName in class BeanPropertyDefinition
    • withSimpleName

      public POJOPropertyBuilder withSimpleName(String newSimpleName)
      Description copied from class: BeanPropertyDefinition
      Alternate "mutant factory" that will only change simple name, but leave other optional parts (like namespace) as is.
      Specified by:
      withSimpleName in class BeanPropertyDefinition
    • markAsUnwrapped

      protected void markAsUnwrapped()
    • compareTo

      public int compareTo(POJOPropertyBuilder other)
      Specified by:
      compareTo in interface Comparable<POJOPropertyBuilder>
    • getName

      public String getName()
      Specified by:
      getName in interface Named
    • getFullName

      public PropertyName getFullName()
      Specified by:
      getFullName in interface FullyNamed
    • hasName

      public boolean hasName(PropertyName name)
      Specified by:
      hasName in interface FullyNamed
    • getInternalName

      public String getInternalName()
      Description copied from class: BeanPropertyDefinition
      Accessor that can be used to determine implicit name from underlying element(s) before possible renaming. This is the "internal" name derived from accessor ("x" from "getX"), and is not based on annotations or naming strategy.
      Specified by:
      getInternalName in class BeanPropertyDefinition
    • getWrapperName

      public PropertyName getWrapperName()
      Description copied from class: BeanPropertyDefinition
      Accessor for finding wrapper name to use for property (if any).
      Specified by:
      getWrapperName in class BeanPropertyDefinition
    • isExplicitlyIncluded

      public boolean isExplicitlyIncluded()
      Description copied from class: BeanPropertyDefinition
      Accessor that can be called to check whether property was included due to an explicit marker (usually annotation), or just by naming convention.
      Specified by:
      isExplicitlyIncluded in class BeanPropertyDefinition
      Returns:
      True if property was explicitly included (usually by having one of components being annotated); false if inclusion was purely due to naming or visibility definitions (that is, implicit)
    • isExplicitlyNamed

      public boolean isExplicitlyNamed()
      Description copied from class: BeanPropertyDefinition
      Accessor that can be called to check whether property name was due to an explicit marker (usually annotation), or just by naming convention or use of "use-default-name" marker (annotation).

      Note that entries that return true from this method will always return true for BeanPropertyDefinition.isExplicitlyIncluded(), but not necessarily vice versa.

      Overrides:
      isExplicitlyNamed in class BeanPropertyDefinition
    • getMetadata

      public PropertyMetadata getMetadata()
      Description copied from class: BeanPropertyDefinition
      Method for accessing additional metadata. NOTE: will never return null, so de-referencing return value is safe.
      Specified by:
      getMetadata in class BeanPropertyDefinition
    • _getSetterInfo

      protected PropertyMetadata _getSetterInfo(PropertyMetadata metadata, AnnotatedMember primary)
      Helper method that contains logic for accessing and merging all setter information that we needed, regarding things like possible merging of property value, and handling of incoming nulls. Only called for deserialization purposes.
    • getPrimaryType

      public JavaType getPrimaryType()
      Type determined from the primary member for the property being built, considering precedence according to whether we are processing serialization or deserialization.
      Specified by:
      getPrimaryType in class BeanPropertyDefinition
    • getRawPrimaryType

      public Class<?> getRawPrimaryType()
      Specified by:
      getRawPrimaryType in class BeanPropertyDefinition
    • hasGetter

      public boolean hasGetter()
      Specified by:
      hasGetter in class BeanPropertyDefinition
    • hasSetter

      public boolean hasSetter()
      Specified by:
      hasSetter in class BeanPropertyDefinition
    • hasField

      public boolean hasField()
      Specified by:
      hasField in class BeanPropertyDefinition
    • hasFieldAndNothingElse

      public boolean hasFieldAndNothingElse()
    • hasConstructorParameter

      public boolean hasConstructorParameter()
      Specified by:
      hasConstructorParameter in class BeanPropertyDefinition
    • isUnwrapped

      public boolean isUnwrapped()
      Returns true if this property is marked with @JsonUnwrapped.
      Since:
      3.1
    • couldDeserialize

      public boolean couldDeserialize()
      Overrides:
      couldDeserialize in class BeanPropertyDefinition
    • couldSerialize

      public boolean couldSerialize()
      Overrides:
      couldSerialize in class BeanPropertyDefinition
    • getGetter

      public AnnotatedMethod getGetter()
      Specified by:
      getGetter in class BeanPropertyDefinition
    • getGetterUnchecked

      protected AnnotatedMethod getGetterUnchecked()
      Variant of getGetter() that does NOT trigger pruning of getter candidates.
    • getSetter

      public AnnotatedMethod getSetter()
      Specified by:
      getSetter in class BeanPropertyDefinition
    • getSetterUnchecked

      protected AnnotatedMethod getSetterUnchecked()
      Variant of getSetter() that does NOT trigger pruning of setter candidates.
    • _selectSetterFromMultiple

      Helper method called in cases where we have encountered two setter methods that have same precedence and cannot be resolved. This does not yet necessarily mean a failure since it is possible something with a higher precedence could still be found; handling is just separated into separate method for convenience.
      Parameters:
      curr -
      next -
      Returns:
      Chosen setter method, if any
      Throws:
      IllegalArgumentException - If conflict could not be resolved
      Since:
      2.13
    • _selectSetter

      protected AnnotatedMethod _selectSetter(AnnotatedMethod currM, AnnotatedMethod nextM)
    • getField

      public AnnotatedField getField()
      Specified by:
      getField in class BeanPropertyDefinition
    • getFieldUnchecked

      protected AnnotatedField getFieldUnchecked()
      Variant of getField() that does NOT trigger pruning of Field candidates.
    • getConstructorParameter

      public AnnotatedParameter getConstructorParameter()
      Specified by:
      getConstructorParameter in class BeanPropertyDefinition
    • getConstructorParameters

      public Iterator<AnnotatedParameter> getConstructorParameters()
      Description copied from class: BeanPropertyDefinition
      Additional method that may be called instead of BeanPropertyDefinition.getConstructorParameter() to get access to all constructor parameters, not just the highest priority one.
      Overrides:
      getConstructorParameters in class BeanPropertyDefinition
    • getPrimaryMember

      public AnnotatedMember getPrimaryMember()
      Description copied from class: BeanPropertyDefinition
      Method used to find the property member (getter, setter, field) that has the highest precedence in current context (getter method when serializing, if available, and so forth), if any.

      Note: may throw IllegalArgumentException in case problems are found trying to getter or setter info.

      Note: abstract since 2.5

      Specified by:
      getPrimaryMember in class BeanPropertyDefinition
    • getPrimaryMemberUnchecked

      protected AnnotatedMember getPrimaryMemberUnchecked()
    • _getterPriority

      protected int _getterPriority(AnnotatedMethod m)
    • _setterPriority

      protected int _setterPriority(AnnotatedMethod m)
    • hasFieldOrGetter

      public boolean hasFieldOrGetter(AnnotatedMember member)
    • findViews

      public Class<?>[] findViews()
      Description copied from class: BeanPropertyDefinition
      Method used to find View-inclusion definitions for the property.
      Overrides:
      findViews in class BeanPropertyDefinition
    • findApplyView

      public Class<?> findApplyView()
      Description copied from class: BeanPropertyDefinition
      Method used to find an override view that should be activated when processing this property's value (and any nested values reached through it), as configured by @JsonApplyView.

      Unlike BeanPropertyDefinition.findViews() (which lists views in which the property itself is included), this returns the view to make active while the value is being serialized. Special marker JsonApplyView.NONE indicates that view processing should be disabled (active view set to null) for the property and its subtree.

      Overrides:
      findApplyView in class BeanPropertyDefinition
      Returns:
      Override view to apply, or null if no override is configured
    • findReferenceType

      public AnnotationIntrospector.ReferenceProperty findReferenceType()
      Description copied from class: BeanPropertyDefinition
      Method used to find whether property is part of a bi-directional reference.
      Overrides:
      findReferenceType in class BeanPropertyDefinition
    • isTypeId

      public boolean isTypeId()
      Description copied from class: BeanPropertyDefinition
      Method used to check whether this logical property has a marker to indicate it should be used as the type id for polymorphic type handling.
      Overrides:
      isTypeId in class BeanPropertyDefinition
    • findObjectIdInfo

      public ObjectIdInfo findObjectIdInfo()
      Description copied from class: BeanPropertyDefinition
      Method used to check whether this logical property indicates that value POJOs should be written using additional Object Identifier (or, when multiple references exist, all but first AS Object Identifier).
      Overrides:
      findObjectIdInfo in class BeanPropertyDefinition
    • findInclusion

      public JsonInclude.Value findInclusion()
      Description copied from class: BeanPropertyDefinition
      Method used to check if this property has specific inclusion override associated with it or not. It should NOT check for any default settings (global, per-type, or containing POJO settings)
      Specified by:
      findInclusion in class BeanPropertyDefinition
    • findAliases

      public List<PropertyName> findAliases()
      Description copied from class: BeanPropertyDefinition
      Method for finding all aliases of the property, if any.
      Specified by:
      findAliases in class BeanPropertyDefinition
      Returns:
      List of aliases, if any; never null (empty list if no aliases found)
    • findAccess

      public JsonProperty.Access findAccess()
    • addField

      public void addField(AnnotatedField a, PropertyName name, boolean explName, boolean visible, boolean ignored)
    • addCtor

      public void addCtor(AnnotatedParameter a, PropertyName name, boolean explName, boolean visible, boolean ignored)
    • addGetter

      public void addGetter(AnnotatedMethod a, PropertyName name, boolean explName, boolean visible, boolean ignored)
    • addSetter

      public void addSetter(AnnotatedMethod a, PropertyName name, boolean explName, boolean visible, boolean ignored)
    • addAll

      public void addAll(POJOPropertyBuilder src)
      Method for adding all property members from specified collector into this collector.
    • removeIgnored

      public void removeIgnored()
      Method called to remove all entries that are marked as ignored.
    • removeNonVisible

      public JsonProperty.Access removeNonVisible(boolean inferMutators, POJOPropertiesCollector parent)
      Parameters:
      inferMutators - Whether mutators can be "pulled in" by visible accessors or not.
      parent - (nullable) Collector to add name ignorals to, if that is desired.
      Since:
      2.12 (earlier had different signature)
    • removeConstructors

      public void removeConstructors()
      Mutator that will simply drop any constructor parameters property may have.
      Since:
      2.5
    • removeFields

      public void removeFields()
      Mutator that will simply drop any fields property may have.
      Since:
      2.18
    • trimByVisibility

      public void trimByVisibility()
      Method called to trim unnecessary entries, such as implicit getter if there is an explict one available. This is important for later stages, to avoid unnecessary conflicts.
    • mergeAnnotations

      public void mergeAnnotations(boolean forSerialization)
    • anyVisible

      public boolean anyVisible()
    • anyIgnorals

      public boolean anyIgnorals()
    • anyExplicitsWithoutIgnoral

      public boolean anyExplicitsWithoutIgnoral()
    • findExplicitNames

      public Set<PropertyName> findExplicitNames()
      Method called to find out set of explicit names for accessors bound together due to implicit name.
      Since:
      2.4
    • hasExplicitName

      public boolean hasExplicitName(PropertyName name)
      Method find out if this property has specified explicit name: this is generally needed for properties that have not yet been renamed (Creator-detection).
      Parameters:
      name - Name to check against
      Returns:
      True if this property has specified explicit name
      Since:
      2.18.2
    • explode

      Method called when a previous call to findExplicitNames() found multiple distinct explicit names, and the property this builder represents basically needs to be broken apart and replaced by a set of more than one properties.
      Since:
      2.4
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromMemberAnnotations

      protected <T> T fromMemberAnnotations(tools.jackson.databind.introspect.POJOPropertyBuilder.WithMember<T> func)
      Helper method used for finding annotation values, from accessors relevant to current usage (deserialization, serialization)
    • fromMemberAnnotationsExcept

      protected <T> T fromMemberAnnotationsExcept(tools.jackson.databind.introspect.POJOPropertyBuilder.WithMember<T> func, T defaultValue)
    • _rawTypeOf

      protected Class<?> _rawTypeOf(AnnotatedMember m)