public class BeanContextBuilder extends ContextBuilder
All serializers and parsers extend from this class.
Provides a base set of common config property setters that allow you to build up serializers and parsers.
WriterSerializer s = JsonSerializer
.
Additional convenience methods are provided for setting properties using reduced syntax.
WriterSerializer s = JsonSerializer
.
psb
Constructor and Description |
---|
BeanContextBuilder()
Constructor.
|
BeanContextBuilder(PropertyStore ps)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
BeanContextBuilder |
add(Map<String,Object> properties)
Adds multiple configuration properties on this object.
|
BeanContextBuilder |
addTo(String name,
Object value)
Adds a value to a SET or LIST property.
|
BeanContextBuilder |
addTo(String name,
String key,
Object value)
Adds or overwrites a value to a SET, LIST, or MAP property.
|
BeanContextBuilder |
apply(PropertyStore copyFrom)
Copies the settings from the specified property store into this builder.
|
BeanContextBuilder |
beanClassVisibility(Visibility value)
Configuration property: Minimum bean class visibility.
|
BeanContextBuilder |
beanConstructorVisibility(Visibility value)
Configuration property: Minimum bean constructor visibility.
|
BeanContextBuilder |
beanDictionary(boolean append,
Object... values)
Configuration property: Bean dictionary.
|
BeanContextBuilder |
beanDictionary(Class<?>... values)
Configuration property: Bean dictionary.
|
BeanContextBuilder |
beanDictionary(Object... values)
Configuration property: Bean dictionary.
|
BeanContextBuilder |
beanDictionaryRemove(Object... values)
Configuration property: Bean dictionary.
|
BeanContextBuilder |
beanFieldVisibility(Visibility value)
Configuration property: Minimum bean field visibility.
|
BeanContextBuilder |
beanFilters(boolean append,
Object... values)
Configuration property: Bean filters.
|
BeanContextBuilder |
beanFilters(Class<?>... values)
Configuration property: Bean filters.
|
BeanContextBuilder |
beanFilters(Object... values)
Configuration property: Bean filters.
|
BeanContextBuilder |
beanFiltersRemove(Object... values)
Configuration property: Bean filters.
|
BeanContextBuilder |
beanMapPutReturnsOldValue()
Configuration property: BeanMap.put() returns old property value.
|
BeanContextBuilder |
beanMapPutReturnsOldValue(boolean value)
Configuration property: BeanMap.put() returns old property value.
|
BeanContextBuilder |
beanMethodVisibility(Visibility value)
Configuration property: Minimum bean method visibility.
|
BeanContextBuilder |
beansRequireDefaultConstructor()
Configuration property: Beans require no-arg constructors.
|
BeanContextBuilder |
beansRequireDefaultConstructor(boolean value)
Configuration property: Beans require no-arg constructors.
|
BeanContextBuilder |
beansRequireSerializable()
Configuration property: Beans require Serializable interface.
|
BeanContextBuilder |
beansRequireSerializable(boolean value)
Configuration property: Beans require Serializable interface.
|
BeanContextBuilder |
beansRequireSettersForGetters()
Configuration property: Beans require setters for getters.
|
BeanContextBuilder |
beansRequireSettersForGetters(boolean value)
Configuration property: Beans require setters for getters.
|
BeanContextBuilder |
beansRequireSomeProperties(boolean value)
Configuration property: Beans require at least one property.
|
BeanContextBuilder |
beanTypePropertyName(String value)
Configuration property: Bean type property name.
|
BeanContext |
build()
Build the object.
|
BeanContextBuilder |
debug()
Configuration property: Debug mode.
|
BeanContextBuilder |
debug(boolean value)
Configuration property: Debug mode.
|
BeanContextBuilder |
excludeProperties(Class<?> beanClass,
String properties)
Configuration property: Bean property excludes.
|
BeanContextBuilder |
excludeProperties(Map<String,String> values)
Configuration property: Bean property excludes.
|
BeanContextBuilder |
excludeProperties(String beanClassName,
String value)
Configuration property: Bean property excludes.
|
BeanContextBuilder |
ignoreInvocationExceptionsOnGetters()
Configuration property: Ignore invocation errors on getters.
|
BeanContextBuilder |
ignoreInvocationExceptionsOnGetters(boolean value)
Configuration property: Ignore invocation errors on getters.
|
BeanContextBuilder |
ignoreInvocationExceptionsOnSetters()
Configuration property: Ignore invocation errors on setters.
|
BeanContextBuilder |
ignoreInvocationExceptionsOnSetters(boolean value)
Configuration property: Ignore invocation errors on setters.
|
BeanContextBuilder |
ignorePropertiesWithoutSetters(boolean value)
Configuration property: Ignore properties without setters.
|
BeanContextBuilder |
ignoreUnknownBeanProperties()
Configuration property: Ignore unknown properties.
|
BeanContextBuilder |
ignoreUnknownBeanProperties(boolean value)
Configuration property: Ignore unknown properties.
|
BeanContextBuilder |
ignoreUnknownNullBeanProperties(boolean value)
Configuration property: Ignore unknown properties with null values.
|
<I> BeanContextBuilder |
implClass(Class<I> interfaceClass,
Class<? extends I> implClass)
Configuration property: Implementation classes.
|
BeanContextBuilder |
implClasses(Map<String,Class<?>> values)
Configuration property: Implementation classes.
|
BeanContextBuilder |
includeProperties(Class<?> beanClass,
String value)
Configuration property: Bean property includes.
|
BeanContextBuilder |
includeProperties(Map<String,String> values)
Configuration property: Bean property includes.
|
BeanContextBuilder |
includeProperties(String beanClassName,
String value)
Configuration property: Bean property includes.
|
BeanContextBuilder |
locale(Locale value)
Configuration property: Locale.
|
BeanContextBuilder |
mediaType(MediaType value)
Configuration property: Media type.
|
BeanContextBuilder |
notBeanClasses(boolean append,
Object... values)
Configuration property: Bean class exclusions.
|
BeanContextBuilder |
notBeanClasses(Class<?>... values)
Configuration property: Bean class exclusions.
|
BeanContextBuilder |
notBeanClasses(Object... values)
Configuration property: Bean class exclusions.
|
BeanContextBuilder |
notBeanClassesRemove(Object... values)
Configuration property: Bean class exclusions.
|
BeanContextBuilder |
notBeanPackages(boolean append,
Object... values)
Configuration property: Bean package exclusions.
|
BeanContextBuilder |
notBeanPackages(Object... values)
Configuration property: Bean package exclusions.
|
BeanContextBuilder |
notBeanPackages(String... values)
Configuration property: Bean package exclusions.
|
BeanContextBuilder |
notBeanPackagesRemove(Object... values)
Configuration property: Bean package exclusions.
|
BeanContextBuilder |
pojoSwaps(boolean append,
Object... values)
Configuration property: POJO swaps.
|
BeanContextBuilder |
pojoSwaps(Class<?>... values)
Configuration property: POJO swaps.
|
BeanContextBuilder |
pojoSwaps(Object... values)
Configuration property: POJO swaps.
|
BeanContextBuilder |
pojoSwapsRemove(Object... values)
Configuration property: POJO swaps.
|
BeanContextBuilder |
propertyNamer(Class<? extends PropertyNamer> value)
Configuration property: Bean property namer
|
BeanContextBuilder |
removeFrom(String name,
Object value)
Removes a value from a SET, LIST, or MAP property.
|
BeanContextBuilder |
set(boolean append,
String name,
Object value)
Sets or adds to a SET or LIST property.
|
BeanContextBuilder |
set(Map<String,Object> properties)
Sets multiple configuration properties on this object.
|
BeanContextBuilder |
set(String name,
Object value)
Sets a configuration property on this object.
|
BeanContextBuilder |
sortProperties()
Configuration property: Sort bean properties.
|
BeanContextBuilder |
sortProperties(boolean value)
Configuration property: Sort bean properties.
|
BeanContextBuilder |
timeZone(TimeZone value)
Configuration property: TimeZone.
|
BeanContextBuilder |
useInterfaceProxies(boolean value)
Configuration property: Use interface proxies.
|
BeanContextBuilder |
useJavaBeanIntrospector()
Configuration property: Use Java Introspector.
|
BeanContextBuilder |
useJavaBeanIntrospector(boolean value)
Configuration property: Use Java Introspector.
|
build, getPropertyStore, getPropertyStoreBuilder
public BeanContextBuilder()
public BeanContextBuilder(PropertyStore ps)
ps
- The initial configuration settings for this builder.public BeanContext build()
ContextBuilder
build
in class ContextBuilder
public BeanContextBuilder beanClassVisibility(Visibility value)
Classes are not considered beans unless they meet the minimum visibility requirements.
For example, if the visibility is PUBLIC
and the bean class is
value
- The new value for this property.
Visibility.PUBLIC
.public BeanContextBuilder beanConstructorVisibility(Visibility value)
Only look for constructors with the specified minimum visibility.
value
- The new value for this property.
Visibility.PUBLIC
.public BeanContextBuilder beanDictionary(Object... values)
Adds to the list of classes that make up the bean dictionary in this bean context.
values
- The values to add to this property.public BeanContextBuilder beanDictionary(Class<?>... values)
Same as beanDictionary(Object...)
but takes in an array of classes.
values
- The values to add to this property.public BeanContextBuilder beanDictionary(boolean append, Object... values)
Same as beanDictionary(Object...)
but allows you to optionally overwrite the previous value.
append
- If values
- The new values for this property.public BeanContextBuilder beanDictionaryRemove(Object... values)
Removes from the list of classes that make up the bean dictionary in this bean context.
values
- The values to remove from this property.public BeanContextBuilder beanFieldVisibility(Visibility value)
Only look for bean fields with the specified minimum visibility.
value
- The new value for this property.
Visibility.PUBLIC
.public BeanContextBuilder beanFilters(Object... values)
This is a programmatic equivalent to the @Bean
annotation.
It's useful when you want to use the Bean annotation functionality, but you don't have the ability to alter
the bean classes.
values
- The values to add to this property.
@Bean.typeName()
.
BeanDictionaryList
containing a collection of bean classes with type name annotations.
BeanDictionaryMap
containing a mapping of type names to classes without type name annotations.
public BeanContextBuilder beanFilters(Class<?>... values)
Same as beanFilters(Object...)
but takes in an array of classes.
values
- The values to add to this property.public BeanContextBuilder beanFilters(boolean append, Object... values)
Same as beanFilters(Object...)
but allows you to optionally overwrite the previous value.
append
- If values
- The new values for this property.
@Bean.typeName()
.
BeanDictionaryList
containing a collection of bean classes with type name annotations.
BeanDictionaryMap
containing a mapping of type names to classes without type name annotations.
public BeanContextBuilder beanFiltersRemove(Object... values)
Removes from the list of classes that make up the bean filters in this bean context.
values
- The values to remove from this property.
@Bean.typeName()
.
BeanDictionaryList
containing a collection of bean classes with type name annotations.
BeanDictionaryMap
containing a mapping of type names to classes without type name annotations.
public BeanContextBuilder beanMapPutReturnsOldValue(boolean value)
If BeanMap.put()
method will return old property
values.
Otherwise, it returns
value
- The new value for this property.
public BeanContextBuilder beanMapPutReturnsOldValue()
Shortcut for calling beanMapPutReturnsOldValue(
.
public BeanContextBuilder beanMethodVisibility(Visibility value)
Only look for bean methods with the specified minimum visibility.
value
- The new value for this property.
Visibility.PUBLIC
public BeanContextBuilder beansRequireDefaultConstructor(boolean value)
If
Otherwise, the bean will be serialized as a string using the Object.toString()
method.
value
- The new value for this property.
public BeanContextBuilder beansRequireDefaultConstructor()
Shortcut for calling beansRequireDefaultConstructor(
.
public BeanContextBuilder beansRequireSerializable(boolean value)
If Serializable
interface to be considered a bean.
Otherwise, the bean will be serialized as a string using the Object.toString()
method.
value
- The new value for this property.
public BeanContextBuilder beansRequireSerializable()
Shortcut for calling beansRequireSerializable(
.
public BeanContextBuilder beansRequireSettersForGetters(boolean value)
If
Otherwise, they will be ignored.
value
- The new value for this property.
public BeanContextBuilder beansRequireSettersForGetters()
Shortcut for calling beansRequireSettersForGetters(
.
public BeanContextBuilder beansRequireSomeProperties(boolean value)
If
Otherwise, the bean will be serialized as a string using the Object.toString()
method.
value
- The new value for this property.
public BeanContextBuilder beanTypePropertyName(String value)
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.
value
- The new value for this property.
public BeanContextBuilder debug(boolean value)
Enables the following additional information during serialization:
Serializer.SERIALIZER_detectRecursions
.
value
- The new value for this property.
public BeanContextBuilder debug()
Shortcut for calling debug(
.
public BeanContextBuilder excludeProperties(Class<?> beanClass, String properties)
Specifies to exclude the specified list of properties for the specified bean class.
beanClass
- The bean class.properties
- Comma-delimited list of property names.public BeanContextBuilder excludeProperties(Map<String,String> values)
Specifies to exclude the specified list of properties for the specified bean classes.
values
- The new value for this property.public BeanContextBuilder excludeProperties(String beanClassName, String value)
beanClassName
- The bean class name.
value
- Comma-delimited list of property names.public BeanContextBuilder ignoreInvocationExceptionsOnGetters(boolean value)
If BeanRuntimeException
is thrown.
value
- The new value for this property.
public BeanContextBuilder ignoreInvocationExceptionsOnGetters()
Shortcut for calling ignoreInvocationExceptionsOnGetters(
.
public BeanContextBuilder ignoreInvocationExceptionsOnSetters(boolean value)
If
Otherwise, a BeanRuntimeException
is thrown.
value
- The new value for this property.
public BeanContextBuilder ignoreInvocationExceptionsOnSetters()
Shortcut for calling ignoreInvocationExceptionsOnSetters(
.
public BeanContextBuilder ignorePropertiesWithoutSetters(boolean value)
If
Otherwise, a BeanRuntimeException
is thrown.
value
- The new value for this property.
public BeanContextBuilder ignoreUnknownBeanProperties(boolean value)
If
Otherwise, a BeanRuntimeException
is thrown.
value
- The new value for this property.
public BeanContextBuilder ignoreUnknownBeanProperties()
Shortcut for calling ignoreUnknownBeanProperties(
.
public BeanContextBuilder ignoreUnknownNullBeanProperties(boolean value)
If
Otherwise, a BeanRuntimeException
is thrown.
value
- The new value for this property.
public <I> BeanContextBuilder implClass(Class<I> interfaceClass, Class<? extends I> implClass)
I
- The class type of the interface.interfaceClass
- The interface class.implClass
- The implementation class.public BeanContextBuilder implClasses(Map<String,Class<?>> values)
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).
values
- The new value for this property.public BeanContextBuilder includeProperties(Class<?> beanClass, String value)
Specifies the set and order of names of properties associated with the bean class.
beanClass
- The bean class.value
- Comma-delimited list of property names.public BeanContextBuilder includeProperties(Map<String,String> values)
Specifies the set and order of names of properties associated with the bean class.
values
- The new value for this property.public BeanContextBuilder includeProperties(String beanClassName, String value)
Specifies the set and order of names of properties associated with the bean class.
beanClassName
- The bean class name.
value
- Comma-delimited list of property names.public BeanContextBuilder locale(Locale value)
Specifies a default locale for serializer and parser sessions.
value
- The new value for this property.public BeanContextBuilder mediaType(MediaType value)
Specifies a default media type value for serializer and parser sessions.
value
- The new value for this property.public BeanContextBuilder notBeanClasses(boolean append, Object... values)
Not-bean classes are converted to Strings
during serialization even if they appear to be
bean-like.
append
- If values
- The new value for this property.
public BeanContextBuilder notBeanClasses(Class<?>... values)
List of classes that should not be treated as beans even if they appear to be bean-like.
Not-bean classes are converted to Strings
during serialization.
values
- The values to add to this property.public BeanContextBuilder notBeanClasses(Object... values)
List of classes that should not be treated as beans even if they appear to be bean-like.
Not-bean classes are converted to Strings
during serialization.
values
- The values to add to this property.
public BeanContextBuilder notBeanClassesRemove(Object... values)
values
- The values to remove from this property.
public BeanContextBuilder notBeanPackages(boolean append, Object... values)
When specified, the current list of ignore packages are appended to.
append
- If values
- The new values for this property.
public BeanContextBuilder notBeanPackages(Object... values)
values
- The values to add to this property.
public BeanContextBuilder notBeanPackages(String... values)
values
- The values to add to this property.public BeanContextBuilder notBeanPackagesRemove(Object... values)
values
- public BeanContextBuilder pojoSwaps(boolean append, Object... values)
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 Calendar
object that gets swapped out for an ISO8601 string.
append
- If values
- The new value for this property.
public BeanContextBuilder pojoSwaps(Class<?>... values)
values
- The values to add to this property.public BeanContextBuilder pojoSwaps(Object... values)
values
- The values to add to this property.
PojoSwap
.
SurrogateSwap
.
public BeanContextBuilder pojoSwapsRemove(Object... values)
values
- The values to remove from this property.
PojoSwap
.
SurrogateSwap
.
public BeanContextBuilder propertyNamer(Class<? extends PropertyNamer> value)
The class to use for calculating bean property names.
value
- The new value for this setting.
PropertyNamerDefault
.public BeanContextBuilder sortProperties(boolean value)
When
value
- The new value for this property.
public BeanContextBuilder sortProperties()
Shortcut for calling sortProperties(
.
public BeanContextBuilder timeZone(TimeZone value)
value
- The new value for this property.public BeanContextBuilder useInterfaceProxies(boolean value)
If InvocationHandler
if there is no other way of instantiating them.
value
- The new value for this property.
public BeanContextBuilder useJavaBeanIntrospector(boolean value)
Using the built-in Java bean introspector will not pick up fields or non-standard getters/setters.
@Bean
annotations will be ignored if you enable this setting.
value
- The new value for this property.
public BeanContextBuilder useJavaBeanIntrospector()
Shortcut for calling useJavaBeanIntrospector(
.
public BeanContextBuilder set(String name, Object value)
ContextBuilder
set
in class ContextBuilder
name
- The property name.value
- The property value.PropertyStoreBuilder.set(String, Object)
public BeanContextBuilder set(boolean append, String name, Object value)
ContextBuilder
set
in class ContextBuilder
append
- If name
- The property name.value
- The property value.PropertyStoreBuilder.set(String, Object)
public BeanContextBuilder set(Map<String,Object> properties)
ContextBuilder
set
in class ContextBuilder
properties
- The properties to set on this class.PropertyStoreBuilder.set(java.util.Map)
public BeanContextBuilder add(Map<String,Object> properties)
ContextBuilder
add
in class ContextBuilder
properties
- The properties to set on this class.PropertyStoreBuilder.add(java.util.Map)
public BeanContextBuilder addTo(String name, Object value)
ContextBuilder
addTo
in class ContextBuilder
name
- The property name.value
- The new value to add to the SET property.public BeanContextBuilder addTo(String name, String key, Object value)
ContextBuilder
addTo
in class ContextBuilder
name
- The property name.key
- The property value map key.value
- The property value map value.public BeanContextBuilder removeFrom(String name, Object value)
ContextBuilder
removeFrom
in class ContextBuilder
name
- The property name.value
- The property value in the SET property.public BeanContextBuilder apply(PropertyStore copyFrom)
ContextBuilder
apply
in class ContextBuilder
copyFrom
- The factory whose settings are being copied.Copyright © 2018 Apache. All rights reserved.