Annotation Type BeanConfig
BeanContext
and BeanTraverseContext
.
Used primarily for specifying bean configuration properties on REST classes and methods.
See Also:
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionMinimum bean class visibility.Minimum bean constructor visibility.Minimum bean field visibility.BeanMap.put() returns old property value.Minimum bean method visibility.Beans require no-arg constructors.Beans require Serializable interface.Beans require setters for getters.Debug mode.Class<?>[]
Bean dictionary.Class<?>[]
Replace bean dictionary.Beans don't require at least one property.Don't silently ignore missing setters.Don't ignore transient fields.Don't ignore unknown properties with null values.Don't use interface proxies.Find fluent setters.Ignore invocation errors on getters.Ignore invocation errors on setters.Ignore unknown properties.Ignore unknown enum values.Class<?>[]
Identifies a set of interfaces.Locale.Media type.Class<?>[]
Bean class exclusions.Class<?>[]
Replace classes that should not be considered beans.String[]
Bean package exclusions.String[]
Replace packages whose classes should not be considered beans.Class<? extends PropertyNamer>
Bean property namer.int
Optional rank for this config.Sort bean properties.Class<?>[]
Java object swaps.Class<?>[]
Replace Java object swap classes.Time zone.Bean type property name.Use enum names.Use Java Introspector.
-
Element Details
-
rank
int rankOptional rank for this config.Can be used to override default ordering and application of config annotations.
- Returns:
- The annotation value.
- Default:
- 0
-
beanClassVisibility
Minimum bean class visibility.Classes are not considered beans unless they meet the minimum visibility requirements.
For example, if the visibility is
PUBLIC and the bean class isprotected , then the class will not be interpreted as a bean class and be serialized as a string.
Use this setting to reduce the visibility requirement."PUBLIC" (default)"PROTECTED" "DEFAULT" "PRIVATE"
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
beanConstructorVisibility
Minimum bean constructor visibility.Only look for constructors with the specified minimum visibility.
This setting affects the logic for finding no-arg constructors for bean.
Normally, onlypublic no-arg constructors are used.
Use this setting if you want to reduce the visibility requirement."PUBLIC" (default)"PROTECTED" "DEFAULT" "PRIVATE"
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
beanFieldVisibility
Minimum bean field visibility.Only look for bean fields with the specified minimum visibility.
This affects which fields on a bean class are considered bean properties.
Normally onlypublic fields are considered.
Use this setting if you want to reduce the visibility requirement."PUBLIC" (default)"PROTECTED" "DEFAULT" "PRIVATE"
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
beanMapPutReturnsOldValue
BeanMap.put() returns old property value.If
"true" , then theBeanMap.put()
method will return old property values.
Otherwise, it returnsnull ."true" "false" (default because it introduces a slight performance penalty during serialization)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
beanMethodVisibility
Minimum bean method visibility.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 onlypublic getters and setters are considered.
Use this setting if you want to reduce the visibility requirement."PUBLIC" (default)"PROTECTED" "DEFAULT" "PRIVATE"
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
beansRequireDefaultConstructor
Beans require no-arg constructors.If
"true" , a Java class must implement a default no-arg constructor to be considered a bean.
Otherwise, the bean will be serialized as a string using theObject.toString()
method."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ). -
The
@Bean
annotation can be used on a class to override this setting when"true" .
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
beansRequireSerializable
Beans require Serializable interface.If
"true" , a Java class must implement theSerializable
interface to be considered a bean.
Otherwise, the bean will be serialized as a string using theObject.toString()
method."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ). -
The
@Bean
annotation can be used on a class to override this setting when"true" .
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
beansRequireSettersForGetters
Beans require setters for getters.If
"true" , only getters that have equivalent setters will be considered as properties on a bean.
Otherwise, they will be ignored."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
disableBeansRequireSomeProperties
Beans don't require at least one property.If
"true" , then a Java class doesn't need to contain at least 1 property to be considered a bean.
Otherwise, the bean will be serialized as a string using theObject.toString()
method."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
typePropertyName
Bean type property name.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.
Notes:
-
Default value:
"_type" . -
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
Default value:
-
debug
Debug mode.Enables the following additional information during serialization:
- When bean getters throws exceptions, the exception includes the object stack information in order to determine how that method was invoked.
-
Enables
BeanTraverseContext.Builder.detectRecursions()
.
Enables the following additional information during parsing:
- When bean setters throws exceptions, the exception includes the object stack information in order to determine how that method was invoked.
"true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
dictionary
Class<?>[] dictionaryBean 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 classFoo has a type-name of"myfoo" , then it would end up serialized as"{_type:'myfoo',...}" .This setting tells the parsers which classes to look for when resolving
"_type" attributes.See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
dictionary_replace
Class<?>[] dictionary_replaceReplace bean dictionary.Same as
dictionary()
but replaces any existing value.See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
findFluentSetters
Find fluent setters.When enabled, fluent setters are detected on beans.
Fluent setters must have the following attributes:
- Public.
- Not static.
- Take in one parameter.
- Return the bean itself.
"true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
ignoreInvocationExceptionsOnGetters
Ignore invocation errors on getters.If
"true" , errors thrown when calling bean getter methods will silently be ignored.
Otherwise, aBeanRuntimeException
is thrown."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
ignoreInvocationExceptionsOnSetters
Ignore invocation errors on setters.If
"true" , errors thrown when calling bean setter methods will silently be ignored.
Otherwise, aBeanRuntimeException
is thrown."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
disableIgnoreMissingSetters
Don't silently ignore missing setters.If
"true" , trying to set a value on a bean property without a setter will throw aBeanRuntimeException
.
Otherwise it will be sliently ignored."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
disableIgnoreTransientFields
Don't ignore transient fields.If
true , methods and fields marked astransient will not be ignored as bean properties."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
ignoreUnknownBeanProperties
Ignore unknown properties.If
"true" , trying to set a value on a non-existent bean property will silently be ignored.
Otherwise, aRuntimeException
is thrown."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
ignoreUnknownEnumValues
Ignore unknown enum values.If
"true" , unknown enum values are set tonull instead of throwing an exception."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
disableIgnoreUnknownNullBeanProperties
Don't ignore unknown properties with null values.If
"true" , trying to set anull value on a non-existent bean property will throw aBeanRuntimeException
. Otherwise it will be silently ignored."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
interfaces
Class<?>[] interfacesIdentifies a set of 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.
// Parent class or interface public abstract class A {public Stringfoo ="foo" ; }// Sub class public class A1extends A {public Stringbar ="bar" ; }// Apply it to a config @BeanConfig ( interfaces={ A.class } )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.
Notes:
- The
@Bean(interfaceClass)
annotation is the equivalent annotation-based solution.
- Returns:
- The annotation value.
- Default:
- {}
- The
-
locale
Locale.Specifies the default locale for serializer and parser sessions.
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
Supports VarResolver.DEFAULT (e.g.
-
mediaType
Media type.Specifies the default media type value for serializer and parser sessions.
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
Supports VarResolver.DEFAULT (e.g.
-
notBeanClasses
Class<?>[] notBeanClassesBean class exclusions.List of classes that should not be treated as beans even if they appear to be bean-like.
Not-bean classes are converted toStrings during serialization.Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
Supports VarResolver.DEFAULT (e.g.
-
notBeanClasses_replace
Replace classes that should not be considered beans.Same as
notBeanClasses()
but replaces any existing value.See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
notBeanPackages
Bean package exclusions.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.
Notes:
-
The default value excludes the following packages:
java.lang java.lang.annotation java.lang.ref java.lang.reflect java.io java.net java.nio.* java.util.*
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
The default value excludes the following packages:
-
notBeanPackages_replace
Replace packages whose classes should not be considered beans.Same as
notBeanPackages()
but replaces any existing value.See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
propertyNamer
Class<? extends PropertyNamer> propertyNamerBean property namer.The class to use for calculating bean property names.
Predefined classes:
BasicPropertyNamer
(default)PropertyNamerDLC
- Dashed-lower-case names.PropertyNamerULC
- Dashed-upper-case names.
See Also:
- Returns:
- The annotation value.
- Default:
- org.apache.juneau.PropertyNamer.Void.class
-
sortProperties
Sort bean properties.When
true , all bean properties will be serialized and access in alphabetical order.
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."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
swaps
Java object 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
Calendar object that gets swapped out for an ISO8601 string.Multiple swaps can be associated with a single class.
When multiple swaps are applicable to the same class, the media type pattern defined byObjectSwap.forMediaTypes()
or@Swap(mediaTypes)
are used to come up with the best match.See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
swaps_replace
Class<?>[] swaps_replaceReplace Java object swap classes.Same as
swaps()
but replaces any existing value.See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
timeZone
Time zone.Specifies the default timezone for serializer and parser sessions.
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
Supports VarResolver.DEFAULT (e.g.
-
useEnumNames
Use enum names.When enabled, enums are always serialized by name, not using
Object.toString()
."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
disableInterfaceProxies
Don't use interface proxies.Disables the feature where interfaces will be instantiated as proxy classes through the use of an
InvocationHandler
if there is no other way of instantiating them.
Setting this to"true" causes this to be aBeanRuntimeException
."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
useJavaBeanIntrospector
Use Java Introspector.Using the built-in Java bean introspector will not pick up fields or non-standard getters/setters.
Most@Bean
annotations will be ignored."true" "false" (default)
Notes:
-
Supports VarResolver.DEFAULT (e.g.
"$C{myConfigVar}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-