Class BeanConfigContext

java.lang.Object
org.apache.juneau.commons.bean.BeanConfigContext

public final class BeanConfigContext extends Object
Immutable runtime configuration for the bean-modeling layer.

BeanConfigContext is the runtime sibling of the @BeanConfig annotation: it carries the resolved values that drive how Java types are introspected as beans, independent of any marshalling concern. Settings include visibility thresholds, required-property toggles, fluent-setter detection, property naming, not-bean exclusions, the active BeanStore and AnnotationProvider, and a few related hooks.

This type is the bean-modeling counterpart of the marshalling-layer context that lives in juneau-marshall. It exists so the bean-modeling runtime (in commons.bean) can be used independently of the marshalling stack, and so the marshalling layer can compose a BeanConfigContext snapshot to feed bean-modeling code without exposing marshalling-only APIs.

Construction:

// All defaults. BeanConfigContext defaults = BeanConfigContext.DEFAULT; // Customized. BeanConfigContext ctx = BeanConfigContext.create() .beanClassVisibility(Visibility.PROTECTED) .findFluentSetters(true) .propertyNamer(new PropertyNamerDLC()) .build(); // Copy and tweak. BeanConfigContext ctx2 = ctx.copy() .unsortedProperties(true) .build();

Thread safety
BeanConfigContext instances are immutable and thread-safe. BeanConfigContext.Builder instances are mutable and not thread-safe.
See Also:
  • Field Details

  • Method Details

    • create

      Creates a new builder for BeanConfigContext.
      Returns:
      A new builder.
    • copy

      Returns a builder pre-populated with the values from this context.
      Returns:
      A new builder.
    • getBeanClassVisibility

      Minimum bean class visibility.

      Classes are not considered beans unless they meet this minimum visibility requirement.

      Returns:
      The minimum bean class visibility. Never null.
    • getBeanConstructorVisibility

      Minimum bean constructor visibility.
      Returns:
      The minimum bean constructor visibility. Never null.
    • getBeanFieldVisibility

      Minimum bean field visibility.
      Returns:
      The minimum bean field visibility. Never null.
    • getBeanMethodVisibility

      Minimum bean method visibility.
      Returns:
      The minimum bean method visibility. Never null.
    • isBeanMapPutReturnsOldValue

      public boolean isBeanMapPutReturnsOldValue()
      Returns whether BeanMap.put(String,Object) returns the previous property value.

      When false (the default), BeanMap.put(...) always returns null for performance reasons — the underlying bean's getter is skipped before the setter is invoked.

      Returns:
      true if old values are returned.
    • isBeansRequireDefaultConstructor

      Returns whether classes must have a no-arg constructor to be considered beans.
      Returns:
      true if a no-arg constructor is required.
    • isBeansRequireSerializable

      public boolean isBeansRequireSerializable()
      Returns whether classes must implement Serializable to be considered beans.
      Returns:
      true if Serializable is required.
    • isBeansRequireSettersForGetters

      Returns whether bean properties must have a setter to be considered writable from the getter.
      Returns:
      true if setters are required for getters.
    • isBeansRequireSomeProperties

      public boolean isBeansRequireSomeProperties()
      Returns whether classes must have at least one property to be considered beans.
      Returns:
      true if at least one property is required.
    • isFindFluentSetters

      public boolean isFindFluentSetters()
      Returns whether fluent-style setters (returning this) should be detected.
      Returns:
      true if fluent setters are detected.
    • isIgnoreInvocationExceptionsOnGetters

      Returns whether exceptions thrown from bean property getters should be silently swallowed.

      When true, an exception thrown by a getter is treated as a null property value rather than propagated to the caller.

      Returns:
      true if getter invocation exceptions are ignored.
    • isIgnoreInvocationExceptionsOnSetters

      Returns whether exceptions thrown from bean property setters should be silently swallowed.

      When true, an exception thrown by a setter is suppressed rather than propagated to the caller.

      Returns:
      true if setter invocation exceptions are ignored.
    • isIgnoreMissingSetters

      public boolean isIgnoreMissingSetters()
      Returns whether bean properties without setters should be silently ignored during deserialization.
      Returns:
      true if missing setters are ignored.
    • isIgnoreTransientFields

      public boolean isIgnoreTransientFields()
      Returns whether transient fields should be excluded from bean property detection.
      Returns:
      true if transient fields are ignored.
    • isIgnoreUnknownBeanProperties

      Returns whether unknown properties on incoming bean payloads should be ignored.
      Returns:
      true if unknown properties are ignored.
    • isIgnoreUnknownNullBeanProperties

      Returns whether attempts to set unknown bean properties to null should be silently ignored.

      When true (the default), trying to set an unknown property to null is a no-op rather than an error. When false, the property setter still rejects unknown property names.

      Returns:
      true if unknown null properties are silently ignored.
    • isUnsortedProperties

      public boolean isUnsortedProperties()
      Returns whether properties use declaration order instead of alphabetical order.

      Declaration order means record component order for records, field declaration order (superclass first) for other classes, followed by method-only properties in alphabetical order.

      Returns:
      true if properties remain unsorted.
    • isRecordComponentOrder

      public boolean isRecordComponentOrder()
      Returns whether record properties use record component (declaration) order.

      When true, the properties of a Record are ordered by Class.getRecordComponents() even in the default sorted mode. Non-record beans are unaffected.

      Returns:
      true if records use component order.
    • isUseInterfaceProxies

      public boolean isUseInterfaceProxies()
      Returns whether interface proxies should be created for bean interfaces.
      Returns:
      true if interface proxies are enabled.
    • isUseJavaBeanIntrospector

      public boolean isUseJavaBeanIntrospector()
      Returns whether Introspector should be used to discover bean properties.
      Returns:
      true if the JavaBeans introspector is used.
    • getPropertyNamer

      Returns the PropertyNamer used to derive property names from getter/setter/field names.
      Returns:
      The active property namer. Never null.
    • getBeanTypePropertyName

      Returns the property name used to embed the bean dictionary type name (default: "_type").
      Returns:
      The bean type property name. Never null.
    • getNotBeanPackageNames

      Returns the set of fully qualified package names whose classes are excluded from bean detection.
      Returns:
      The not-a-bean package name set. Never null. Unmodifiable.
    • getNotBeanPackagePrefixes

      Returns the set of fully qualified package prefixes whose classes are excluded from bean detection.
      Returns:
      The not-a-bean package prefix set. Never null. Unmodifiable.
    • getNotBeanClasses

      public Set<Class<?>> getNotBeanClasses()
      Returns the set of classes (and supertypes) that are explicitly excluded from bean detection.
      Returns:
      The not-a-bean class set. Never null. Unmodifiable.
    • getBeanStore

      Returns the active BeanStore used for factory-based bean instantiation, or null if none configured.
      Returns:
      The bean store, or null.
    • getAnnotationProvider

      Returns the AnnotationProvider used to discover annotations on classes/methods/fields/parameters.
      Returns:
      The annotation provider. Never null.
    • getBeanMetaInitializer

      Returns the BeanMetaInitializer SPI hook used during BeanMeta construction.

      On the commons-side path this is BeanMetaInitializer.NOOP (no marshalling-side help); on the marshalling-side path, MarshallingContext wires its own implementation that reads @Marshalled / @BeanType annotations and builds BeanRegistry instances.

      Returns:
      The bean-meta initializer. Never null.
    • getBeanPropertyPostProcessor

      Returns the BeanPropertyPostProcessor SPI hook used during BeanPropertyMeta construction.

      On the commons-side path this is BeanPropertyPostProcessor.NOOP (no swap-aware transforms or @MarshalledProp / @Swap / @Uri reads); on the marshalling-side path, MarshallingContext wires its own implementation.

      Returns:
      The bean-property post-processor. Never null.
    • isNotABean

      public boolean isNotABean(ClassInfo ci)
      Returns true if the specified class is excluded from bean detection.

      The default implementation checks getNotBeanClasses(), getNotBeanPackageNames(), and getNotBeanPackagePrefixes(), and rejects arrays/primitives/enums/annotations. A custom predicate (set via BeanConfigContext.Builder.notABeanPredicate(Predicate)) overrides this behavior entirely.

      Parameters:
      ci - The class info being tested. Must not be null.
      Returns:
      true if the class is excluded from bean detection.