Class POJOPropertiesCollector

java.lang.Object
tools.jackson.databind.introspect.POJOPropertiesCollector

public class POJOPropertiesCollector extends Object
Helper class used for aggregating information about all possible properties of a POJO.
  • Field Details

    • _config

      protected final MapperConfig<?> _config
      Configuration settings
    • _accessorNaming

      protected final AccessorNamingStrategy _accessorNaming
      Handler used for name-mangling of getter, mutator (setter/with) methods
    • _forSerialization

      protected final boolean _forSerialization
      True if introspection is done for serialization (giving precedence for serialization annotations), or not (false, deserialization)
    • _type

      protected final JavaType _type
      Type of POJO for which properties are being collected.
    • _classDef

      protected final AnnotatedClass _classDef
      Low-level introspected class information (methods, fields etc)
    • _visibilityChecker

      protected final VisibilityChecker _visibilityChecker
    • _annotationIntrospector

      protected final AnnotationIntrospector _annotationIntrospector
    • _useAnnotations

      protected final boolean _useAnnotations
    • _isRecordType

      protected final boolean _isRecordType
    • _collected

      protected boolean _collected
      State flag we keep to indicate whether actual property information has been collected or not.
    • _properties

      protected LinkedHashMap<String,POJOPropertyBuilder> _properties
      Set of logical property information collected so far.
    • _creatorProperties

      protected List<POJOPropertyBuilder> _creatorProperties
    • _potentialCreators

      protected PotentialCreators _potentialCreators
      Since:
      2.18
    • _fieldRenameMappings

      protected Map<PropertyName,PropertyName> _fieldRenameMappings
      A set of "field renamings" that have been discovered, indicating intended renaming of other accessors: key is the implicit original name and value intended name to use instead.

      Note that these renamings are applied earlier than "regular" (explicit) renamings and affect implicit name: their effect may be changed by further renaming based on explicit indicators. The main use case is to effectively relink accessors based on fields discovered, and used to sort of correct otherwise missing linkage between fields and other accessors.

    • _anyGetters

      protected LinkedList<AnnotatedMember> _anyGetters
    • _anyGetterField

      protected LinkedList<AnnotatedMember> _anyGetterField
    • _anySetters

      protected LinkedList<AnnotatedMethod> _anySetters
    • _anySetterField

      protected LinkedList<AnnotatedMember> _anySetterField
    • _jsonKeyAccessors

      protected LinkedList<AnnotatedMember> _jsonKeyAccessors
      Accessors (field or "getter" method annotated with JsonKey
    • _jsonValueAccessors

      protected LinkedList<AnnotatedMember> _jsonValueAccessors
      Accessors (field or "getter" method) annotated with JsonValue
    • _perPropertyIgnoredNames

      protected HashSet<String> _perPropertyIgnoredNames
      Per-property ignorals: names collected from @JsonIgnore markers and read/write-only access rules via _collectIgnorals(java.lang.String).

      Kept as a mutable set because _renameProperties(java.util.Map<java.lang.String, tools.jackson.databind.introspect.POJOPropertyBuilder>) may remove entries for [databind#2001] when a per-property ignoral is overridden by a creator parameter renamed to the same name. The pre-rescue state is captured into _nonRescuedIgnoredPropertyNames on the first such removal so getNonRescuedIgnoredPropertyNames() can still report it. Class-level ignorals are tracked in _classLevelIgnoredNames instead so they remain immune to that rescue.

    • _classLevelIgnoredNames

      protected HashSet<String> _classLevelIgnoredNames
      Class-level ignorals: direction-specific names derived from @JsonIgnoreProperties (annotation plus config overrides), copied here from _propertyIgnorals during _collectClassLevelIgnorals().

      Held separately from _perPropertyIgnoredNames so that the [databind#2001] creator-rename rescue does not strip them: class-level ignorals are absolute, per-property ignorals can be overridden by creators.

      Since:
      3.2
    • _nonRescuedIgnoredPropertyNames

      protected HashSet<String> _nonRescuedIgnoredPropertyNames
      Snapshot of _perPropertyIgnoredNames taken just before the [databind#2001] creator-rename rescue can fire, used by getNonRescuedIgnoredPropertyNames(). Null when no rescue happened (in which case _perPropertyIgnoredNames itself is still complete).
      Since:
      3.2
    • _propertyIgnorals

      protected JsonIgnoreProperties.Value _propertyIgnorals
      Class-level ignorals (annotation plus config overrides), computed once during _collectClassLevelIgnorals() and exposed to the factory layer via getPropertyIgnorals() so that findPropertyIgnoralByName() is called exactly once per type.

      The direction-specific name set carried here is also mirrored into _classLevelIgnoredNames for inclusion in getIgnoredPropertyNames(); this field additionally retains the ignoreUnknown, allowGetters/allowSetters, and merge attributes which the simple name set does not.

    • _injectables

      protected LinkedHashMap<Object,AnnotatedMember> _injectables
      Lazily collected list of members that were annotated to indicate that they represent mutators for deserializer value injection.
    • _formatOverrides

      protected JsonFormat.Value _formatOverrides
      Lazily accessed information about POJO format overrides
  • Constructor Details

  • Method Details

    • getConfig

      public MapperConfig<?> getConfig()
    • getType

      public JavaType getType()
    • isRecordType

      public boolean isRecordType()
    • getClassDef

      public AnnotatedClass getClassDef()
    • getAnnotationIntrospector

      public AnnotationIntrospector getAnnotationIntrospector()
    • getProperties

      public List<BeanPropertyDefinition> getProperties()
    • getPotentialCreators

      public PotentialCreators getPotentialCreators()
    • getInjectables

      public Map<Object,AnnotatedMember> getInjectables()
    • getJsonKeyAccessor

      public AnnotatedMember getJsonKeyAccessor()
    • getJsonValueAccessor

      public AnnotatedMember getJsonValueAccessor()
    • getAnyGetterField

      public AnnotatedMember getAnyGetterField()
    • getAnyGetterMethod

      public AnnotatedMember getAnyGetterMethod()
    • getAnySetterField

      public AnnotatedMember getAnySetterField()
    • getAnySetterMethod

      public AnnotatedMethod getAnySetterMethod()
    • getIgnoredPropertyNames

      public Set<String> getIgnoredPropertyNames()
      Accessor for the full set of property names marked ignored — combining per-property @JsonIgnore markers, class-level @JsonIgnoreProperties, and read/write-only access rules. Filtered by direction (ser vs. deser) at collection time.

      Per-property names that have been "rescued" by the [databind#2001] creator-rename redirect are excluded from this set; class-level names are not subject to that rescue and always appear here. This is the set factory code should consult to populate a deserializer's runtime ignore-list (see BeanDeserializerFactory#addBeanProps). For the un-rescued per-property view see getNonRescuedIgnoredPropertyNames().

      Performance note: when both per-property and class-level ignorals exist, this allocates a fresh HashSet on every call to merge them. Callers that reference the result repeatedly (or in a loop) should cache the returned set in a local. The intended call-site is BeanDeserializerFactory#addBeanProps, which runs once per type during deserializer construction — not on the dispatch hot path.

    • getNonRescuedIgnoredPropertyNames

      public Set<String> getNonRescuedIgnoredPropertyNames()
      Accessor for the per-property ignorals view before any [databind#2001] creator-rename rescue is applied: includes every per-property @JsonIgnore or read/write-only name that was originally collected, even those later overridden by a creator parameter renamed to the same name. Class-level @JsonIgnoreProperties names are also included (they are never rescued in the first place).

      Most callers should use getIgnoredPropertyNames() instead — this accessor exists for the rare case where a caller needs to know about names that would have been ignored but for the rescue.

      Since:
      3.2
    • getPropertyIgnorals

      public JsonIgnoreProperties.Value getPropertyIgnorals()
      Accessor for class-level property ignorals (annotation plus config overrides), computed once during collection and cached for reuse by the factory layer. Returns null when no ignorals are defined.

      Carries only class-level ignorals, in their original (un-stripped) form. Equivalent to the class-level subset of getIgnoredPropertyNames(), but in JsonIgnoreProperties.Value form (which also carries ignoreUnknown, allowGetters/allowSetters, etc.).

    • getObjectIdInfo

      public ObjectIdInfo getObjectIdInfo()
      Accessor to find out whether type specified requires inclusion of Object Identifier.
    • getPropertyMap

      protected Map<String,POJOPropertyBuilder> getPropertyMap()
    • getFormatOverrides

      @Deprecated public JsonFormat.Value getFormatOverrides()
      Deprecated.
      Since 3.2
      Since:
      2.17
    • collectAll

      protected void collectAll()
      Internal method that will collect actual property information.
    • _addFields

      protected void _addFields(Map<String,POJOPropertyBuilder> props)
      Method for collecting basic information on all fields found
    • _addCreators

      protected void _addCreators(Map<String,POJOPropertyBuilder> props)
    • _addMethods

      protected void _addMethods(Map<String,POJOPropertyBuilder> props)
      Method for collecting basic information on all accessor methods found
    • _addGetterMethod

      protected void _addGetterMethod(Map<String,POJOPropertyBuilder> props, AnnotatedMethod m)
    • _addSetterMethod

      protected void _addSetterMethod(Map<String,POJOPropertyBuilder> props, AnnotatedMethod m)
    • _addInjectables

      protected void _addInjectables(Map<String,POJOPropertyBuilder> props)
    • _doAddInjectable

      protected void _doAddInjectable(JacksonInject.Value injectable, AnnotatedMember m)
    • _fixLeadingFieldNameCase

      protected void _fixLeadingFieldNameCase(Map<String,POJOPropertyBuilder> props)
    • _removeUnwantedProperties

      protected void _removeUnwantedProperties(Map<String,POJOPropertyBuilder> props)
      Method called to get rid of candidate properties that are marked as ignored.
    • _removeUnwantedAccessors

      protected void _removeUnwantedAccessors(Map<String,POJOPropertyBuilder> props)
      Method called to further get rid of unwanted individual accessors, based on read/write settings and rules for "pulling in" accessors (or not).
    • _collectIgnorals

      protected void _collectIgnorals(String name)
      Helper method called to record a per-property ignoral (from @JsonIgnore or read/write-only rules) into _perPropertyIgnoredNames. Used by _renameProperties(java.util.Map<java.lang.String, tools.jackson.databind.introspect.POJOPropertyBuilder>) to skip renaming ignored properties, and surfaced externally via getIgnoredPropertyNames().
    • hasCreatorBoundProperty

      public boolean hasCreatorBoundProperty(String name)
      Returns true if the (already-collected) properties-based creator has a parameter currently bound to the given name. Used by POJOPropertyBuilder.removeNonVisible(boolean, tools.jackson.databind.introspect.POJOPropertiesCollector) to skip READ_ONLY explicit-name ignorals that would shadow a sibling creator parameter ([databind#5975]).
      Since:
      3.2
    • _collectClassLevelIgnorals

      protected void _collectClassLevelIgnorals()
      Helper method called to collect class-level property ignorals: stores the full JsonIgnoreProperties.Value (annotation + config overrides) in _propertyIgnorals for reuse by the factory layer, and copies the direction-specific property names into _classLevelIgnoredNames (held separately from _perPropertyIgnoredNames so the [databind#2001] creator-rename rescue does not strip them — class-level ignorals are absolute).

      Uses MapperConfig.getDefaultPropertyIgnorals(java.lang.Class<?>) rather than calling findPropertyIgnoralByName() directly, so that config-level overrides are included and consistent with what the factory layer sees.

      Since:
      3.2
    • _renameProperties

      protected void _renameProperties(Map<String,POJOPropertyBuilder> props)
    • _rescueCreatorAliasIgnorals

      protected void _rescueCreatorAliasIgnorals()
      Removes from _perPropertyIgnoredNames any name that is a @JsonAlias of a (live) properties-based creator parameter. Companion to the [databind#2001] creator-rename rescue in _renameProperties(java.util.Map<java.lang.String, tools.jackson.databind.introspect.POJOPropertyBuilder>); see [databind#6031].
      Since:
      3.2.1
    • _renameUsing

      protected void _renameUsing(Map<String,POJOPropertyBuilder> propMap, PropertyNamingStrategy naming)
    • _renameWithWrappers

      protected void _renameWithWrappers(Map<String,POJOPropertyBuilder> props)
    • _sortProperties

      protected void _sortProperties(Map<String,POJOPropertyBuilder> props)
    • _resolveFieldVsGetter

      protected boolean _resolveFieldVsGetter(List<AnnotatedMember> accessors)
      Method that will be given a List with 2 or more accessors that may be in conflict: it will need to remove lower-priority accessors to leave just a single highest-priority accessor to use. If this succeeds method returns true, otherwise false.

      NOTE: method will directly modify given List directly, regardless of whether it ultimately succeeds or not.

      Returns:
      True if seeming conflict was resolved and there only remains single accessor
    • reportProblem

      protected void reportProblem(String msg, Object... args)
    • _property

      protected POJOPropertyBuilder _property(Map<String,POJOPropertyBuilder> props, PropertyName name)
    • _property

      protected POJOPropertyBuilder _property(Map<String,POJOPropertyBuilder> props, String implName)
    • _replaceCreatorProperty

      protected boolean _replaceCreatorProperty(List<POJOPropertyBuilder> creatorProperties, POJOPropertyBuilder prop)