Class BeanConfigContext
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:
Thread safety
BeanConfigContext instances are immutable and thread-safe.
BeanConfigContext.Builder instances are mutable and not thread-safe.
See Also:
@BeanConfig— the annotation form.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BeanConfigContextDefaultBeanConfigContextinstance with all settings at their defaults. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns a builder pre-populated with the values from this context.static BeanConfigContext.Buildercreate()Creates a new builder forBeanConfigContext.Returns theAnnotationProviderused to discover annotations on classes/methods/fields/parameters.Minimum bean class visibility.Minimum bean constructor visibility.Minimum bean field visibility.Returns theBeanMetaInitializerSPI hook used duringBeanMetaconstruction.Minimum bean method visibility.Returns theBeanPropertyPostProcessorSPI hook used duringBeanPropertyMetaconstruction.Returns the activeBeanStoreused for factory-based bean instantiation, ornull if none configured.Returns the property name used to embed the bean dictionary type name (default:"_type" ).Returns the set of classes (and supertypes) that are explicitly excluded from bean detection.Returns the set of fully qualified package names whose classes are excluded from bean detection.Returns the set of fully qualified package prefixes whose classes are excluded from bean detection.Returns thePropertyNamerused to derive property names from getter/setter/field names.booleanReturns whetherBeanMap.put(String,Object)returns the previous property value.booleanReturns whether classes must have a no-arg constructor to be considered beans.booleanReturns whether classes must implementSerializableto be considered beans.booleanReturns whether bean properties must have a setter to be considered writable from the getter.booleanReturns whether classes must have at least one property to be considered beans.booleanReturns whether fluent-style setters (returningthis ) should be detected.booleanReturns whether exceptions thrown from bean property getters should be silently swallowed.booleanReturns whether exceptions thrown from bean property setters should be silently swallowed.booleanReturns whether bean properties without setters should be silently ignored during deserialization.booleanReturns whethertransientfields should be excluded from bean property detection.booleanReturns whether unknown properties on incoming bean payloads should be ignored.booleanReturns whether attempts to set unknown bean properties tonull should be silently ignored.booleanisNotABean(ClassInfo ci) Returnstrue if the specified class is excluded from bean detection.booleanReturns whether record properties use record component (declaration) order.booleanReturns whether properties use declaration order instead of alphabetical order.booleanReturns whether interface proxies should be created for bean interfaces.booleanReturns whetherIntrospectorshould be used to discover bean properties.
-
Field Details
-
DEFAULT
DefaultBeanConfigContextinstance with all settings at their defaults.Equivalent to
BeanConfigContext.create().build().
-
-
Method Details
-
create
Creates a new builder forBeanConfigContext.- 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
Returns whetherBeanMap.put(String,Object)returns the previous property value.When
false (the default),BeanMap.put(...)always returnsnull 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
Returns whether classes must implementSerializableto be considered beans.- Returns:
true ifSerializableis 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
Returns whether classes must have at least one property to be considered beans.- Returns:
true if at least one property is required.
-
isFindFluentSetters
Returns whether fluent-style setters (returningthis ) 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 anull 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
Returns whether bean properties without setters should be silently ignored during deserialization.- Returns:
true if missing setters are ignored.
-
isIgnoreTransientFields
Returns whethertransientfields 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 tonull should be silently ignored.When
true (the default), trying to set an unknown property tonull is a no-op rather than an error. Whenfalse , the property setter still rejects unknown property names.- Returns:
true if unknown null properties are silently ignored.
-
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
Returns whether record properties use record component (declaration) order.When
true , the properties of aRecordare ordered byClass.getRecordComponents()even in the default sorted mode. Non-record beans are unaffected.- Returns:
true if records use component order.
-
isUseInterfaceProxies
Returns whether interface proxies should be created for bean interfaces.- Returns:
true if interface proxies are enabled.
-
isUseJavaBeanIntrospector
Returns whetherIntrospectorshould be used to discover bean properties.- Returns:
true if the JavaBeans introspector is used.
-
getPropertyNamer
Returns thePropertyNamerused 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
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 activeBeanStoreused for factory-based bean instantiation, ornull if none configured.- Returns:
- The bean store, or
null .
-
getAnnotationProvider
Returns theAnnotationProviderused to discover annotations on classes/methods/fields/parameters.- Returns:
- The annotation provider. Never
null .
-
getBeanMetaInitializer
Returns theBeanMetaInitializerSPI hook used duringBeanMetaconstruction.On the commons-side path this is
BeanMetaInitializer.NOOP(no marshalling-side help); on the marshalling-side path,MarshallingContextwires its own implementation that reads@Marshalled/@BeanTypeannotations and buildsBeanRegistryinstances.- Returns:
- The bean-meta initializer. Never
null .
-
getBeanPropertyPostProcessor
Returns theBeanPropertyPostProcessorSPI hook used duringBeanPropertyMetaconstruction.On the commons-side path this is
BeanPropertyPostProcessor.NOOP(no swap-aware transforms or@MarshalledProp/@Swap/@Urireads); on the marshalling-side path,MarshallingContextwires its own implementation.- Returns:
- The bean-property post-processor. Never
null .
-
isNotABean
Returnstrue if the specified class is excluded from bean detection.The default implementation checks
getNotBeanClasses(),getNotBeanPackageNames(), andgetNotBeanPackagePrefixes(), and rejects arrays/primitives/enums/annotations. A custom predicate (set viaBeanConfigContext.Builder.notABeanPredicate(Predicate)) overrides this behavior entirely.- Parameters:
ci- The class info being tested. Must not benull .- Returns:
true if the class is excluded from bean detection.
-