@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 |
---|---|
String |
beanClassVisibility
Configuration property: Minimum bean class visibility.
|
String |
beanConstructorVisibility
Configuration property: Minimum bean constructor visibility.
|
Class<?>[] |
beanDictionary_remove
Configuration property: Remove from bean dictionary.
|
Class<?>[] |
beanDictionary_replace
Configuration property: Add to bean dictionary.
|
Class<?>[] |
beanDictionary
Configuration property: Bean dictionary.
|
String |
beanFieldVisibility
Configuration property: Minimum bean field visibility.
|
Class<?>[] |
beanFilters_remove
Configuration property: Remove from bean filters.
|
Class<?>[] |
beanFilters_replace
Configuration property: Add to bean filters.
|
Class<?>[] |
beanFilters
Configuration property: Bean filters.
|
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 |
beanTypePropertyName
Configuration property: Bean type property name.
|
String[] |
bpi
Configuration property: Bean property includes.
|
String[] |
bpx
Configuration property: Bean property excludes.
|
String |
debug
Configuration property: Debug mode.
|
String |
detectRecursions
Configuration property: Automatically detect POJO recursions.
|
CS[] |
example
Configuration property: POJO examples.
|
String[] |
examples
Configuration property: POJO examples.
|
CS[] |
excludeProperties
Configuration property: Bean property excludes.
|
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 |
ignoreUnknownBeanProperties
Configuration property: Ignore unknown properties.
|
String |
ignoreUnknownNullBeanProperties
Configuration property: Ignore unknown properties with null values.
|
CC[] |
implClasses
Configuration property: Implementation classes.
|
CS[] |
includeProperties
Configuration property: Bean property includes.
|
String |
initialDepth
Configuration property: Initial depth.
|
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
Configuration property: Remove from POJO swap classes.
|
Class<? extends PojoSwap<?,?>>[] |
pojoSwaps_replace
Configuration property: Add to POJO swap classes.
|
Class<? extends PojoSwap<?,?>>[] |
pojoSwaps
Configuration property: POJO swaps.
|
Class<? extends PropertyNamer> |
propertyNamer
Configuration property: Bean property namer.
|
int |
rank
Optional rank for this config.
|
String |
sortProperties
Configuration property: Sort bean properties.
|
String |
timeZone
Configuration property: Time zone.
|
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 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.
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
public abstract Class<?>[] beanDictionary_replace
public abstract Class<?>[] beanDictionary_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.
public abstract Class<?>[] beanFilters
This is a programmatic equivalent to the @Bean
annotation.
It's useful when you want to use the
BeanFilterBuilder
.
InterfaceBeanFilterBuilder
.
public abstract Class<?>[] beanFilters_replace
public abstract Class<?>[] beanFilters_remove
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 beanTypePropertyName
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
BeanContext.BEAN_includeProperties
property on 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:
public abstract String[] bpx
BeanContext.BEAN_excludeProperties
property on 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:
public abstract String debug
Enables the following additional information during serialization:
BeanTraverseContext.BEANTRAVERSE_detectRecursions
.
Enables the following additional information during parsing:
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.
public abstract CS[] excludeProperties
Specifies to exclude the specified list of properties for the specified bean class.
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 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).
public abstract CS[] includeProperties
Specifies the set and order of names of properties associated with the bean class.
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
public abstract Class<? extends PojoSwap<?,?>>[] pojoSwaps
POJO 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 POJO swap would be a
Multiple POJO 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_pojoSwaps
public abstract Class<? extends PojoSwap<?,?>>[] pojoSwaps_replace
public abstract Class<? extends PojoSwap<?,?>>[] pojoSwaps_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 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–2019 The Apache Software Foundation. All rights reserved.