@Documented @Target(value={TYPE,METHOD}) @Retention(value=RUNTIME) @Inherited @PropertyStoreApply(value=BeanConfigApply.class) public @interface BeanConfig
BeanContext
and BeanTraverseContext
.
Used primarily for specifying bean configuration properties on REST classes and methods.
Modifier and Type | Optional Element and Description |
---|---|
Bean[] |
applyBean
Dynamically applies
@Bean annotations to specified classes. |
Beanc[] |
applyBeanc
Dynamically applies
@Beanc annotations to specified constructors. |
BeanIgnore[] |
applyBeanIgnore
Dynamically applies
@BeanIgnore annotations to specified classes/methods/fields/constructors. |
Beanp[] |
applyBeanp
Dynamically applies
@Beanp annotations to specified methods. |
Example[] |
applyExample
Dynamically applies
@Example annotations to specified classes/methods/fields. |
NameProperty[] |
applyNameProperty
Dynamically applies
@NameProperty annotations to specified methods/fields. |
ParentProperty[] |
applyParentProperty
Dynamically applies
@ParentProperty annotations to specified methods/fields. |
Swap[] |
applySwap
Dynamically applies
@Swap annotations to specified classes/methods/fields. |
URI[] |
applyURI
Dynamically applies
@URI annotations to specified classes/methods/fields. |
String |
beanClassVisibility
Configuration property: Minimum bean class visibility.
|
String |
beanConstructorVisibility
Configuration property: Minimum bean constructor visibility.
|
Class<?>[] |
beanDictionary_remove
Deprecated.
|
Class<?>[] |
beanDictionary_replace
Deprecated.
|
Class<?>[] |
beanDictionary
Deprecated.
|
String |
beanFieldVisibility
Configuration property: Minimum bean field visibility.
|
Class<?>[] |
beanFilters_remove
Deprecated.
|
Class<?>[] |
beanFilters_replace
Deprecated.
|
Class<?>[] |
beanFilters
Deprecated.
|
String |
beanMapPutReturnsOldValue
Configuration property: BeanMap.put() returns old property value.
|
String |
beanMethodVisibility
Configuration property: Minimum bean method visibility.
|
String |
beansRequireDefaultConstructor
Configuration property: Beans require no-arg constructors.
|
String |
beansRequireSerializable
Configuration property: Beans require Serializable interface.
|
String |
beansRequireSettersForGetters
Configuration property: Beans require setters for getters.
|
String |
beansRequireSomeProperties
Configuration property: Beans require at least one property.
|
String[] |
bpi
Configuration property: Bean property includes.
|
CS[] |
bpiMap
Deprecated.
|
String[] |
bpro
Configuration property: Read-only bean properties.
|
CS[] |
bproMap
Deprecated.
|
String[] |
bpwo
Configuration property: Write-only bean properties.
|
CS[] |
bpwoMap
Deprecated.
|
String[] |
bpx
Configuration property: Bean property excludes.
|
CS[] |
bpxMap
Deprecated.
|
String |
debug
Configuration property: Debug mode.
|
String |
detectRecursions
Configuration property: Automatically detect POJO recursions.
|
Class<?>[] |
dictionary_remove
Configuration property: Remove from bean dictionary.
|
Class<?>[] |
dictionary_replace
Configuration property: Add to bean dictionary.
|
Class<?>[] |
dictionary
Configuration property: Bean dictionary.
|
CS[] |
example
Configuration property: POJO examples.
|
String[] |
examples
Configuration property: POJO examples.
|
CS[] |
excludeProperties
Deprecated.
|
String |
fluentSetters
Configuration property: Find fluent setters.
|
String |
ignoreInvocationExceptionsOnGetters
Configuration property: Ignore invocation errors on getters.
|
String |
ignoreInvocationExceptionsOnSetters
Configuration property: Ignore invocation errors on setters.
|
String |
ignorePropertiesWithoutSetters
Configuration property: Ignore properties without setters.
|
String |
ignoreRecursions
Configuration property: Ignore recursion errors.
|
String |
ignoreTransientFields
Configuration property: Ignore transient fields.
|
String |
ignoreUnknownBeanProperties
Configuration property: Ignore unknown properties.
|
String |
ignoreUnknownNullBeanProperties
Configuration property: Ignore unknown properties with null values.
|
CC[] |
implClasses
Configuration property: Implementation classes.
|
CS[] |
includeProperties
Deprecated.
|
String |
initialDepth
Configuration property: Initial depth.
|
Class<?>[] |
interfaces
Identifies a set of interfaces.
|
String |
locale
Configuration property: Locale.
|
String |
maxDepth
Configuration property: Max traversal depth.
|
String |
mediaType
Configuration property: Media type.
|
Class<?>[] |
notBeanClasses_remove
Configuration property: Remove from classes that should not be considered beans.
|
Class<?>[] |
notBeanClasses_replace
Configuration property: Add to classes that should not be considered beans.
|
Class<?>[] |
notBeanClasses
Configuration property: Bean class exclusions.
|
String[] |
notBeanPackages_remove
Configuration property: Remove from packages whose classes should not be considered beans.
|
String[] |
notBeanPackages_replace
Configuration property: Add to packages whose classes should not be considered beans.
|
String[] |
notBeanPackages
Configuration property: Bean package exclusions.
|
Class<? extends PojoSwap<?,?>>[] |
pojoSwaps_remove
Deprecated.
|
Class<? extends PojoSwap<?,?>>[] |
pojoSwaps_replace
Deprecated.
|
Class<? extends PojoSwap<?,?>>[] |
pojoSwaps
Deprecated.
|
Class<? extends PropertyNamer> |
propertyNamer
Configuration property: Bean property namer.
|
int |
rank
Optional rank for this config.
|
String |
sortProperties
Configuration property: Sort bean properties.
|
Class<?>[] |
swaps_remove
Configuration property: Remove from Java object swap classes.
|
Class<?>[] |
swaps_replace
Configuration property: Add to Java object swap classes.
|
Class<?>[] |
swaps
Configuration property: Java object swaps.
|
String |
timeZone
Configuration property: Time zone.
|
String |
typePropertyName
Configuration property: Bean type property name.
|
String |
useEnumNames
Configuration property: Use enum names.
|
String |
useInterfaceProxies
Configuration property: Use interface proxies.
|
String |
useJavaBeanIntrospector
Configuration property: Use Java Introspector.
|
public abstract int rank
Can be used to override default ordering and application of config annotations.
public abstract Beanc[] applyBeanc
@Beanc
annotations to specified constructors.
Provides an alternate approach for applying annotations using @Beanc.on
to specify the names
to apply the annotation to.
public abstract Beanp[] applyBeanp
@Beanp
annotations to specified methods.
Provides an alternate approach for applying annotations using @Beanp.on
to specify the names
to apply the annotation to.
public abstract BeanIgnore[] applyBeanIgnore
@BeanIgnore
annotations to specified classes/methods/fields/constructors.
Provides an alternate approach for applying annotations using @BeanIgnore.on
to specify the names
to apply the annotation to.
public abstract Example[] applyExample
@Example
annotations to specified classes/methods/fields.
Provides an alternate approach for applying annotations using @Example.on
to specify the names
to apply the annotation to.
public abstract NameProperty[] applyNameProperty
@NameProperty
annotations to specified methods/fields.
Provides an alternate approach for applying annotations using @NameProperty.on
to specify the names
to apply the annotation to.
public abstract ParentProperty[] applyParentProperty
@ParentProperty
annotations to specified methods/fields.
Provides an alternate approach for applying annotations using @ParentProperty.on
to specify the names
to apply the annotation to.
public abstract String beanClassVisibility
Classes are not considered beans unless they meet the minimum visibility requirements.
For example, if the visibility is
Use this setting to reduce the visibility requirement.
public abstract String beanConstructorVisibility
Only look for constructors with the specified minimum visibility.
This setting affects the logic for finding no-arg constructors for bean.
Normally, only
Use this setting if you want to reduce the visibility requirement.
@Deprecated public abstract Class<?>[] beanDictionary
The list of classes that make up the bean dictionary in this bean context.
A dictionary is a name/class mapping used to find class types during parsing when they cannot be inferred
through reflection.
The names are defined through the @Bean(typeName)
annotation defined on the bean class.
For example, if a class
This setting tells the parsers which classes to look for when resolving
dictionary()
.
@Deprecated public abstract Class<?>[] beanDictionary_replace
dictionary_replace()
.
@Deprecated public abstract Class<?>[] beanDictionary_remove
dictionary_remove()
.
public abstract String beanFieldVisibility
Only look for bean fields with the specified minimum visibility.
This affects which fields on a bean class are considered bean properties.
Normally only
Use this setting if you want to reduce the visibility requirement.
@Deprecated public abstract Class<?>[] beanFilters
This is a programmatic equivalent to the @Bean
annotation.
It's useful when you want to use the
BeanFilterBuilder
.
InterfaceBeanFilterBuilder
.
BeanContext.BEAN_beanFilters
interfaces()
or other various approaches.
@Deprecated public abstract Class<?>[] beanFilters_replace
interfaces()
or other various approaches.
@Deprecated public abstract Class<?>[] beanFilters_remove
interfaces()
or other various approaches.
public abstract String beanMapPutReturnsOldValue
If BeanMap.put()
method will return old property
values.
Otherwise, it returns
public abstract String beanMethodVisibility
Only look for bean methods with the specified minimum visibility.
This affects which methods are detected as getters and setters on a bean class.
Normally only
Use this setting if you want to reduce the visibility requirement.
public abstract String beansRequireDefaultConstructor
If
Otherwise, the bean will be serialized as a string using the Object.toString()
method.
@Bean
annotation can be used on a class to override this setting when public abstract String beansRequireSerializable
If Serializable
interface to be considered a bean.
Otherwise, the bean will be serialized as a string using the Object.toString()
method.
@Bean
annotation can be used on a class to override this setting when public abstract String beansRequireSettersForGetters
If
Otherwise, they will be ignored.
public abstract String beansRequireSomeProperties
If
Otherwise, the bean will be serialized as a string using the Object.toString()
method.
public abstract String typePropertyName
This specifies the name of the bean property used to store the dictionary name of a bean type so that the parser knows the data type to reconstruct.
public abstract String[] bpi
Bean.bpi()
annotation for all serializers.
The typical use case is when you're rendering summary and details views of the same bean in a resource and you want to expose or hide specific properties depending on the level of detail you want.
In the example below, our 'summary' view is a list of beans where we only want to show the ID property, and our detail view is a single bean where we want to expose different fields:
@Deprecated public abstract CS[] bpiMap
Specifies the set and order of names of properties associated with the bean class.
BeanContextBuilder.bpi(Class, String)
BeanContextBuilder.bpi(String, String)
BeanContextBuilder.bpi(Map)
applyBean()
and Bean.bpi()
.
public abstract String[] bpx
Bean.bpx()
annotation for all serializers.
Same as bpi()
except you specify a list of bean property names that you want to exclude from
serialization.
In the example below, our 'summary' view is a list of beans where we want to exclude some properties:
@Deprecated public abstract CS[] bpxMap
Specifies to exclude the specified list of properties for the specified bean class.
BeanContextBuilder.bpx(Class, String)
BeanContextBuilder.bpx(String, String)
BeanContextBuilder.bpx(Map)
applyBean()
and Bean.bpx()
.
public abstract String[] bpro
Bean.bpwo()
annotation for all parsers.
Specifies one or more properties on a bean that are read-only despite having valid getters. Serializers will serialize such properties as usual, but parsers will silently ignore them.
@Deprecated public abstract CS[] bproMap
Bean.bpro()
annotation for all parsers.
Specifies one or more properties on a bean that are read-only despite having valid getters. Serializers will serialize such properties as usual, but parsers will silently ignore them.
BeanContextBuilder.bpro(Class, String)
BeanContextBuilder.bpro(String, String)
BeanContextBuilder.bpro(Map)
applyBean()
and Bean.bpi()
.
public abstract String[] bpwo
Bean.bpwo()
annotation for all serializers.
Specifies one or more properties on a bean that are write-only despite having valid setters. Parsers will parse such properties as usual, but serializers will silently ignore them.
@Deprecated public abstract CS[] bpwoMap
Bean.bpwo()
annotation for all serializers.
Specifies one or more properties on a bean that are write-only despite having valid setters. Parsers will parse such properties as usual, but serializers will silently ignore them.
BeanContextBuilder.bpwo(Class, String)
BeanContextBuilder.bpwo(String, String)
BeanContextBuilder.bpwo(Map)
applyBean()
and Bean.bpwo()
.
public abstract String debug
Enables the following additional information during serialization:
BeanTraverseContext.BEANTRAVERSE_detectRecursions
.
Enables the following additional information during parsing:
public abstract Class<?>[] dictionary
The list of classes that make up the bean dictionary in this bean context.
A dictionary is a name/class mapping used to find class types during parsing when they cannot be inferred
through reflection.
The names are defined through the @Bean(typeName)
annotation defined on the bean class.
For example, if a class
This setting tells the parsers which classes to look for when resolving
public abstract Class<?>[] dictionary_replace
public abstract Class<?>[] dictionary_remove
public abstract CS[] example
Specifies an example of the specified class.
Examples are used in cases such as POJO examples in Swagger documents.
@Example
.
@Example
with zero arguments or one BeanSession
argument.
BeanSession
argument.
public abstract String[] examples
Same as example()
but allows you to define examples as a Simple-JSON string.
@Deprecated public abstract CS[] excludeProperties
bpxMap()
.
public abstract String fluentSetters
When enabled, fluent setters are detected on beans.
Fluent setters must have the following attributes:
public abstract String ignoreInvocationExceptionsOnGetters
If
Otherwise, a BeanRuntimeException
is thrown.
public abstract String ignoreInvocationExceptionsOnSetters
If
Otherwise, a BeanRuntimeException
is thrown.
public abstract String ignorePropertiesWithoutSetters
If
Otherwise, a RuntimeException
is thrown.
public abstract String ignoreTransientFields
If
public abstract String ignoreUnknownBeanProperties
If
Otherwise, a RuntimeException
is thrown.
public abstract String ignoreUnknownNullBeanProperties
If
Otherwise, a RuntimeException
is thrown.
public abstract CC[] implClasses
For interfaces and abstract classes this method can be used to specify an implementation class for the interface/abstract class so that instances of the implementation class are used when instantiated (e.g. during a parse).
@Deprecated public abstract CS[] includeProperties
bpiMap()
.
public abstract Class<?>[] interfaces
When specified, only the list of properties defined on the interface class will be used during serialization of implementation classes. Additional properties on subclasses will be ignored.
This annotation can be used on the parent class so that it filters to all child classes, or can be set individually on the child classes.
@Bean(interfaceClass)
annotation is the equivalent annotation-based solution.
public abstract String locale
Specifies the default locale for serializer and parser sessions.
public abstract String mediaType
Specifies the default media type value for serializer and parser sessions.
public abstract Class<?>[] notBeanClasses
List of classes that should not be treated as beans even if they appear to be bean-like.
Not-bean classes are converted to
public abstract Class<?>[] notBeanClasses_replace
public abstract Class<?>[] notBeanClasses_remove
public abstract String[] notBeanPackages
When specified, the current list of ignore packages are appended to.
Any classes within these packages will be serialized to strings using Object.toString()
.
Note that you can specify suffix patterns to include all subpackages.
public abstract String[] notBeanPackages_replace
public abstract String[] notBeanPackages_remove
@Deprecated public abstract Class<? extends PojoSwap<?,?>>[] pojoSwaps
swaps()
@Deprecated public abstract Class<? extends PojoSwap<?,?>>[] pojoSwaps_replace
swaps_replace()
@Deprecated public abstract Class<? extends PojoSwap<?,?>>[] pojoSwaps_remove
swaps_remove()
public abstract Class<? extends PropertyNamer> propertyNamer
The class to use for calculating bean property names.
Predefined classes:
PropertyNamerDefault
(default)
PropertyNamerDLC
- Dashed-lower-case names.
PropertyNamerULC
- Dashed-upper-case names.
public abstract String sortProperties
When
Otherwise, the natural order of the bean properties is used which is dependent on the JVM vendor.
On IBM JVMs, the bean properties are ordered based on their ordering in the Java file.
On Oracle JVMs, the bean properties are not ordered (which follows the official JVM specs).
This property is disabled by default so that IBM JVM users don't have to use @Bean
annotations
to force bean properties to be in a particular order and can just alter the order of the fields/methods
in the Java file.
public abstract Class<?>[] swaps
Swaps are used to "swap out" non-serializable classes with serializable equivalents during serialization, and "swap in" the non-serializable class during parsing.
An example of a swap would be a
Multiple swaps can be associated with a single class.
When multiple swaps are applicable to the same class, the media type pattern defined by
PojoSwap.forMediaTypes()
or @Swap(mediaTypes)
are used to come up with the best match.
BeanContext.BEAN_swaps
public abstract Class<?>[] swaps_replace
public abstract Class<?>[] swaps_remove
public abstract String timeZone
Specifies the default timezone for serializer and parser sessions.
public abstract String useEnumNames
When enabled, enums are always serialized by name, not using Object.toString()
.
public abstract String useInterfaceProxies
If InvocationHandler
if there is no other way of instantiating them.
Otherwise, throws a BeanRuntimeException
.
public abstract String useJavaBeanIntrospector
Using the built-in Java bean introspector will not pick up fields or non-standard getters/setters.
Most @Bean
annotations will be ignored.
public abstract String detectRecursions
Specifies that recursions should be checked for during traversal.
Recursions can occur when traversing models that aren't true trees but rather contain loops.
In general, unchecked recursions cause stack-overflow-errors.
These show up as ParseExceptions
with the message
The behavior when recursions are detected depends on the value for BeanTraverseContext.BEANTRAVERSE_ignoreRecursions
.
For example, if a model contains the links A->B->C->A, then the JSON generated will look like
the following when
{A:{B:{C:
public abstract String ignoreRecursions
Used in conjunction with BeanTraverseContext.BEANTRAVERSE_detectRecursions
.
Setting is ignored if
If
Otherwise, a BeanRecursionException
is thrown with the message
public abstract String initialDepth
The initial indentation level at the root.
Useful when constructing document fragments that need to be indented at a certain level.
public abstract String maxDepth
Abort traversal if specified depth is reached in the POJO tree.
If this depth is exceeded, an exception is thrown.
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.