Class BeanDescription

java.lang.Object
tools.jackson.databind.BeanDescription
Direct Known Subclasses:
BasicBeanDescription

public abstract class BeanDescription extends Object
Basic container for information gathered by ClassIntrospector to help in constructing serializers and deserializers. Note that the one implementation type is BasicBeanDescription, meaning that it is safe to upcast to that type.
  • Field Details

    • _type

      protected final JavaType _type
      Bean type information, including raw class and possible generics information
  • Constructor Details

    • BeanDescription

      protected BeanDescription(JavaType type)
  • Method Details

    • supplier

      public abstract BeanDescription.Supplier supplier()
      Method for constructing a supplier for this bean description instance: sometimes needed when code expects supplier, not description instance.
    • getType

      public JavaType getType()
      Method for accessing declared type of bean being introspected, including full generic type information (from declaration)
    • getBeanClass

      public Class<?> getBeanClass()
    • isRecordType

      public boolean isRecordType()
    • isNonStaticInnerClass

      public boolean isNonStaticInnerClass()
    • getClassInfo

      public abstract AnnotatedClass getClassInfo()
      Method for accessing low-level information about Class this item describes.
    • getObjectIdInfo

      public abstract ObjectIdInfo getObjectIdInfo()
      Accessor for getting information about Object Id expected to be used for this POJO type, if any.
    • hasKnownClassAnnotations

      public abstract boolean hasKnownClassAnnotations()
      Method for checking whether class being described has any annotations recognized by registered annotation introspector.
    • getClassAnnotations

      public abstract Annotations getClassAnnotations()
      Method for accessing collection of annotations the bean class has.
    • findProperties

      public abstract List<BeanPropertyDefinition> findProperties()
      Returns:
      Ordered Map with logical property name as key, and matching getter method as value.
    • getIgnoredPropertyNames

      public abstract Set<String> getIgnoredPropertyNames()
      Returns the full set of property names marked ignored — combining per-property @JsonIgnore markers, class-level @JsonIgnoreProperties (annotation and config overrides), and read/write-only access rules. The set is direction-specific: a name may appear for serialization but not deserialization, depending on the annotation attributes.

      Per-property names that have been "rescued" by a creator parameter renamed to the same name (see [databind#2001]) are excluded; class-level names are absolute and always appear. This is the canonical accessor for building a deserializer's runtime ignore-list — factory code does not need to combine it with getPropertyIgnorals().

    • getNonRescuedIgnoredPropertyNames

      public Set<String> getNonRescuedIgnoredPropertyNames()
      Returns the un-rescued view of getIgnoredPropertyNames(): includes per-property names that [databind#2001] would later rescue when a creator parameter is renamed to the same name. Class-level names are included exactly as in the rescued view (they are absolute either way).

      Default implementation returns getIgnoredPropertyNames(); subclasses backed by a property collector override to return the un-rescued set. Most callers should use getIgnoredPropertyNames(); this exists for tooling that needs to inspect the original ignoral declarations.

      Since:
      3.2
    • getPropertyIgnorals

      public JsonIgnoreProperties.Value getPropertyIgnorals()
      Returns the class-level property ignorals value (annotation plus config overrides), pre-computed during property collection. Preferred over re-calling findPropertyIgnoralByName() in factory code since the result is cached. Returns null when neither annotation nor config override defines any ignorals.

      Equivalent to the class-level subset of getIgnoredPropertyNames() but in JsonIgnoreProperties.Value form, which additionally carries the ignoreUnknown, allowGetters, allowSetters, and merge attributes.

    • findBackReferences

      public abstract List<BeanPropertyDefinition> findBackReferences()
      Method for locating all back-reference properties (setters, fields) bean has
    • getConstructors

      public abstract List<AnnotatedConstructor> getConstructors()
      Helper method that will return all non-default constructors (that is, constructors that take one or more arguments) this class has.
    • getConstructorsWithMode

      public abstract List<AnnotatedAndMetadata<AnnotatedConstructor,JsonCreator.Mode>> getConstructorsWithMode()
      Method similar to getConstructors() except will also introspect JsonCreator.Mode and filter out ones marked as not applicable and include mode (or lack thereof) for remaining constructors.

      Note that no other filtering (regarding visibility or other annotations) is performed

    • getFactoryMethods

      public abstract List<AnnotatedMethod> getFactoryMethods()
      Helper method that will check all static methods of the bean class that seem like factory methods eligible to be used as Creators. This requires that the static method:
      1. Returns type compatible with bean type (same or subtype)
      2. Is recognized from either explicit annotation (usually @JsonCreator OR naming: names valueOf() and fromString() are recognized but only for 1-argument factory methods, and in case of fromString() argument type must further be either String or CharSequence.
      Note that caller typically applies further checks for things like visibility.
      Returns:
      List of static methods considered as possible Factory methods
    • getFactoryMethodsWithMode

      public abstract List<AnnotatedAndMetadata<AnnotatedMethod,JsonCreator.Mode>> getFactoryMethodsWithMode()
      Method similar to getFactoryMethods() but will return JsonCreator.Mode metadata along with qualifying factory method candidates.
      Since:
      2.13
    • findDefaultConstructor

      public abstract AnnotatedConstructor findDefaultConstructor()
      Method that will locate the no-arg constructor for this class, if it has one, and that constructor has not been marked as ignorable.
    • getPotentialCreators

      public abstract PotentialCreators getPotentialCreators()
      Method that is replacing earlier Creator introspection access methods.
      Returns:
      Container for introspected Creator candidates, if any
      Since:
      2.18
    • findJsonKeyAccessor

      public AnnotatedMember findJsonKeyAccessor()
      Method for locating accessor (readable field, or "getter" method) that has JsonKey annotation, if any. If multiple ones are found, an error is reported by throwing IllegalArgumentException
    • findJsonValueAccessor

      public abstract AnnotatedMember findJsonValueAccessor()
      Method for locating accessor (readable field, or "getter" method) that has JsonValue annotation, if any. If multiple ones are found, an error is reported by throwing IllegalArgumentException
    • findAnyGetter

      public abstract AnnotatedMember findAnyGetter()
      Method used to locate the Method or Field of introspected class that is annotated with JsonAnyGetter (or equivalent annotation). If no such AnnotatedMember exists null is returned. If more than one are found, an exception is thrown.
    • findAnySetterAccessor

      public abstract AnnotatedMember findAnySetterAccessor()
      Method used to locate a mutator (settable field, or 2-argument set method) of introspected class that is annotated with JsonAnySetter (or equivalent annotation). If no such mutator exists null is returned. If more than one are found an exception is thrown. Additional checks are also made to see that method signature is acceptable: needs to take 2 arguments, first one String or Object; second any can be any type.
    • findMethod

      public abstract AnnotatedMethod findMethod(String name, Class<?>[] paramTypes)
    • findPropertyInclusion

      public abstract JsonInclude.Value findPropertyInclusion(JsonInclude.Value defValue)
      Method for finding annotation-indicated inclusion definition (if any); possibly overriding given default value.

      NOTE: does NOT use global inclusion default settings as the base, unless passed as `defValue`.

    • findInjectables

      public abstract Map<Object,AnnotatedMember> findInjectables()
    • instantiateBean

      public abstract Object instantiateBean(boolean fixAccess)
      Method called to create a "default instance" of the bean, currently only needed for obtaining default field values which may be used for suppressing serialization of fields that have "not changed".
      Parameters:
      fixAccess - If true, method is allowed to fix access to the default constructor (to be able to call non-public constructor); if false, has to use constructor as is.
      Returns:
      Instance of class represented by this descriptor, if suitable default constructor was found; null otherwise.
    • findDefaultViews

      public abstract Class<?>[] findDefaultViews()
      Method for finding out if the POJO specifies default view(s) to use for properties, considering both per-type annotations and global default settings.