All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.juneau.BeanContextBuilder Maven / Gradle / Ivy

There is a newer version: 9.0.1
Show newest version
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
// * with the License.  You may obtain a copy of the License at                                                              *
// *                                                                                                                         *
// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
// *                                                                                                                         *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
// * specific language governing permissions and limitations under the License.                                              *
// ***************************************************************************************************************************
package org.apache.juneau;

import static org.apache.juneau.BeanContext.*;

import java.io.*;
import java.lang.reflect.*;
import java.util.*;

import org.apache.juneau.annotation.*;
import org.apache.juneau.http.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;

/**
 * Builder class for building instances of serializers, parsers, and bean contexts.
 *
 * 

* 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 * .create() * .set(JSON_simpleMode, true) * .set(SERIALIZER_useWhitespace, true) * .set(SERIALIZER_quoteChar, "'") * .build(); *

* *

* Additional convenience methods are provided for setting properties using reduced syntax. * *

* WriterSerializer s = JsonSerializer * .create() // Create a JsonSerializerBuilder * .simple() // Simple mode * .ws() // Use whitespace * .sq() // Use single quotes * .build(); // Create a JsonSerializer *

* *
See Also:
*
    *
*/ public class BeanContextBuilder extends ContextBuilder { /** * Constructor. * * All default settings. */ public BeanContextBuilder() { super(); } /** * Constructor. * * @param ps The initial configuration settings for this builder. */ public BeanContextBuilder(PropertyStore ps) { super(ps); } @Override /* ContextBuilder */ public BeanContext build() { return build(BeanContext.class); } //----------------------------------------------------------------------------------------------------------------- // Properties //----------------------------------------------------------------------------------------------------------------- /** * Configuration property: 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 is protected, then the class * will not be interpreted as a bean class and will be treated as a string. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanClassVisibility} *
* * @param value * The new value for this property. *
The default is {@link Visibility#PUBLIC}. * @return This object (for method chaining). */ public BeanContextBuilder beanClassVisibility(Visibility value) { return set(BEAN_beanClassVisibility, value); } /** * Configuration property: Minimum bean constructor visibility. * *

* Only look for constructors with the specified minimum visibility. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanConstructorVisibility} *
* * @param value * The new value for this property. *
The default is {@link Visibility#PUBLIC}. * @return This object (for method chaining). */ public BeanContextBuilder beanConstructorVisibility(Visibility value) { return set(BEAN_beanConstructorVisibility, value); } /** * Configuration property: Bean dictionary. * *

* Adds to the list of classes that make up the bean dictionary in this bean context. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanDictionary} *
* * @param values * The values to add to this property. * @return This object (for method chaining). */ public BeanContextBuilder beanDictionary(Object...values) { return addTo(BEAN_beanDictionary, values); } /** * Configuration property: Bean dictionary. * *

* Same as {@link #beanDictionary(Object...)} but takes in an array of classes. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanDictionary} *
* * @param values * The values to add to this property. * @return This object (for method chaining). */ public BeanContextBuilder beanDictionary(Class...values) { return addTo(BEAN_beanDictionary, values); } /** * Configuration property: Bean dictionary. * *

* Same as {@link #beanDictionary(Object...)} but allows you to optionally overwrite the previous value. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanDictionary} *
* * @param append * If true, the previous value is appended to. Otherwise, the previous value is replaced. * @param values * The new values for this property. * @return This object (for method chaining). */ public BeanContextBuilder beanDictionary(boolean append, Object...values) { return set(append, BEAN_beanDictionary, values); } /** * Configuration property: Bean dictionary. * *

* Removes from the list of classes that make up the bean dictionary in this bean context. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanDictionary} *
* * @param values * The values to remove from this property. * @return This object (for method chaining). */ public BeanContextBuilder beanDictionaryRemove(Object...values) { return removeFrom(BEAN_beanDictionary, values); } /** * Configuration property: Minimum bean field visibility. * *

* Only look for bean fields with the specified minimum visibility. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanFieldVisibility} *
* * @param value * The new value for this property. *
The default is {@link Visibility#PUBLIC}. * @return This object (for method chaining). */ public BeanContextBuilder beanFieldVisibility(Visibility value) { return set(BEAN_beanFieldVisibility, value); } /** * Configuration property: Bean filters. * *

* This is a programmatic equivalent to the {@link Bean @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. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanFilters} *
* * @param values * The values to add to this property. *
Values can consist of any of the following types: *
    *
  • Any bean class that specifies a value for {@link Bean#typeName() @Bean(typeName)}. *
  • Any subclass of {@link BeanDictionaryList} containing a collection of bean classes with type name annotations. *
  • Any subclass of {@link BeanDictionaryMap} containing a mapping of type names to classes without type name annotations. *
  • Any array or collection of the objects above. *
* @return This object (for method chaining). */ public BeanContextBuilder beanFilters(Object...values) { return addTo(BEAN_beanFilters, values); } /** * Configuration property: Bean filters. * *

* Same as {@link #beanFilters(Object...)} but takes in an array of classes. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanFilters} *
* * @param values * The values to add to this property. * @return This object (for method chaining). */ public BeanContextBuilder beanFilters(Class...values) { return addTo(BEAN_beanFilters, values); } /** * Configuration property: Bean filters. * *

* Same as {@link #beanFilters(Object...)} but allows you to optionally overwrite the previous value. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanFilters} *
* * @param append * If true, the previous value is appended to. Otherwise, the previous value is replaced. * @param values * The new values for this property. *
Values can consist of any of the following types: *
    *
  • Any bean class that specifies a value for {@link Bean#typeName() @Bean(typeName)}. *
  • Any subclass of {@link BeanDictionaryList} containing a collection of bean classes with type name annotations. *
  • Any subclass of {@link BeanDictionaryMap} containing a mapping of type names to classes without type name annotations. *
  • Any array or collection of the objects above. *
* @return This object (for method chaining). */ public BeanContextBuilder beanFilters(boolean append, Object...values) { return set(append, BEAN_beanFilters, values); } /** * Configuration property: Bean filters. * *

* Removes from the list of classes that make up the bean filters in this bean context. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanFilters} *
* * @param values * The values to remove from this property. *
Values can consist of any of the following types: *
    *
  • Any bean class that specifies a value for {@link Bean#typeName() @Bean(typeName)}. *
  • Any subclass of {@link BeanDictionaryList} containing a collection of bean classes with type name annotations. *
  • Any subclass of {@link BeanDictionaryMap} containing a mapping of type names to classes without type name annotations. *
  • Any array or collection of the objects above. *
* @return This object (for method chaining). */ public BeanContextBuilder beanFiltersRemove(Object...values) { return removeFrom(BEAN_beanFilters, values); } /** * Configuration property: BeanMap.put() returns old property value. * *

* If true, then the {@link BeanMap#put(String,Object) BeanMap.put()} method will return old property * values. *
Otherwise, it returns null. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanMapPutReturnsOldValue} *
* * @param value * The new value for this property. *
The default is false. * @return This object (for method chaining). */ public BeanContextBuilder beanMapPutReturnsOldValue(boolean value) { return set(BEAN_beanMapPutReturnsOldValue, value); } /** * Configuration property: BeanMap.put() returns old property value. * *

* Shortcut for calling beanMapPutReturnsOldValue(true). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanMapPutReturnsOldValue} *
* * @return This object (for method chaining). */ public BeanContextBuilder beanMapPutReturnsOldValue() { return set(BEAN_beanMapPutReturnsOldValue, true); } /** * Configuration property: Minimum bean method visibility. * *

* Only look for bean methods with the specified minimum visibility. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanMethodVisibility} *
* * @param value * The new value for this property. *
The default is {@link Visibility#PUBLIC} * @return This object (for method chaining). */ public BeanContextBuilder beanMethodVisibility(Visibility value) { return set(BEAN_beanMethodVisibility, value); } /** * Configuration property: 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 the {@link Object#toString()} method. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beansRequireDefaultConstructor} *
* * @param value * The new value for this property. *
The default is false. * @return This object (for method chaining). */ public BeanContextBuilder beansRequireDefaultConstructor(boolean value) { return set(BEAN_beansRequireDefaultConstructor, value); } /** * Configuration property: Beans require no-arg constructors. * *

* Shortcut for calling beansRequireDefaultConstructor(true). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beansRequireDefaultConstructor} *
* * @return This object (for method chaining). */ public BeanContextBuilder beansRequireDefaultConstructor() { return set(BEAN_beansRequireDefaultConstructor, true); } /** * Configuration property: Beans require Serializable interface. * *

* If true, a Java class must implement the {@link Serializable} interface to be considered a bean. *
Otherwise, the bean will be serialized as a string using the {@link Object#toString()} method. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beansRequireSerializable} *
* * @param value * The new value for this property. *
The default is false. * @return This object (for method chaining). */ public BeanContextBuilder beansRequireSerializable(boolean value) { return set(BEAN_beansRequireSerializable, value); } /** * Configuration property: Beans require Serializable interface. * *

* Shortcut for calling beansRequireSerializable(true). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beansRequireSerializable} *
* * @return This object (for method chaining). */ public BeanContextBuilder beansRequireSerializable() { return set(BEAN_beansRequireSerializable, true); } /** * Configuration property: 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. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beansRequireSettersForGetters} *
* * @param value * The new value for this property. *
The default is false. * @return This object (for method chaining). */ public BeanContextBuilder beansRequireSettersForGetters(boolean value) { return set(BEAN_beansRequireSettersForGetters, value); } /** * Configuration property: Beans require setters for getters. * *

* Shortcut for calling beansRequireSettersForGetters(true). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beansRequireSettersForGetters} *
* * @return This object (for method chaining). */ public BeanContextBuilder beansRequireSettersForGetters() { return set(BEAN_beansRequireSettersForGetters, true); } /** * Configuration property: Beans require at least one property. * *

* If true, then a Java class must contain at least 1 property to be considered a bean. *
Otherwise, the bean will be serialized as a string using the {@link Object#toString()} method. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beansRequireSomeProperties} *
* * @param value * The new value for this property. *
The default is true. * @return This object (for method chaining). */ public BeanContextBuilder beansRequireSomeProperties(boolean value) { return set(BEAN_beansRequireSomeProperties, value); } /** * Configuration property: 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. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_beanTypePropertyName} *
* * @param value * The new value for this property. *
The default is "_type". * @return This object (for method chaining). */ public BeanContextBuilder beanTypePropertyName(String value) { return set(BEAN_beanTypePropertyName, value); } /** * Configuration property: 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 {@link Serializer#BEANTRAVERSE_detectRecursions}. *
* *
See Also:
*
    *
  • {@link BeanContext#BEAN_debug} *
* * @param value * The new value for this property. *
The default is false. * @return This object (for method chaining). */ public BeanContextBuilder debug(boolean value) { return set(BEAN_debug, value); } /** * Configuration property: Debug mode. * *

* Shortcut for calling debug(true). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_debug} *
* * @return This object (for method chaining). */ public BeanContextBuilder debug() { return set(BEAN_debug, true); } /** * Configuration property: POJO example. * *

* Specifies an example of the specified class. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_examples} *
* * @param pojoClass The POJO class. * @param o An instance of the POJO class used for examples. * @return This object (for method chaining). */ public BeanContextBuilder example(Class pojoClass, T o) { return addTo(BEAN_examples, pojoClass.getName(), o); } /** * Configuration property: Bean property excludes. * *

* Specifies to exclude the specified list of properties for the specified bean class. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_excludeProperties} *
* * @param beanClass The bean class. * @param properties Comma-delimited list of property names. * @return This object (for method chaining). */ public BeanContextBuilder excludeProperties(Class beanClass, String properties) { return addTo(BEAN_excludeProperties, beanClass.getName(), properties); } /** * Configuration property: Bean property excludes. * *

* Specifies to exclude the specified list of properties for the specified bean classes. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_excludeProperties} *
* * @param values * The new value for this property. * @return This object (for method chaining). */ public BeanContextBuilder excludeProperties(Map values) { return set(BEAN_excludeProperties, values); } /** * Configuration property: Bean property excludes. * *
See Also:
*
    *
  • {@link BeanContext#BEAN_excludeProperties} *
* * @param beanClassName * The bean class name. *
Can be a simple name, fully-qualified name, or "*" for all bean classes. * @param value Comma-delimited list of property names. * @return This object (for method chaining). */ public BeanContextBuilder excludeProperties(String beanClassName, String value) { return addTo(BEAN_excludeProperties, beanClassName, value); } /** * Configuration property: 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. *
* *
See Also:
*
    *
  • {@link BeanContext#BEAN_fluentSetters} *
* * @param value * The new value for this property. *
The default is false. * @return This object (for method chaining). */ public BeanContextBuilder fluentSetters(boolean value) { return set(BEAN_fluentSetters, value); } /** * Configuration property: Find fluent setters. * *

* Shortcut for calling fluentSetters(true). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_fluentSetters} *
* * @return This object (for method chaining). */ public BeanContextBuilder fluentSetters() { return set(BEAN_fluentSetters, true); } /** * Configuration property: Ignore invocation errors on getters. * *

* If true, errors thrown when calling bean getter methods will silently be ignored. * Otherwise, a {@code BeanRuntimeException} is thrown. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_ignoreInvocationExceptionsOnGetters} *
* * @param value * The new value for this property. *
The default is false. * @return This object (for method chaining). */ public BeanContextBuilder ignoreInvocationExceptionsOnGetters(boolean value) { return set(BEAN_ignoreInvocationExceptionsOnGetters, value); } /** * Configuration property: Ignore invocation errors on getters. * *

* Shortcut for calling ignoreInvocationExceptionsOnGetters(true). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_ignoreInvocationExceptionsOnGetters} *
* * @return This object (for method chaining). */ public BeanContextBuilder ignoreInvocationExceptionsOnGetters() { return set(BEAN_ignoreInvocationExceptionsOnGetters, true); } /** * Configuration property: Ignore invocation errors on setters. * *

* If true, errors thrown when calling bean setter methods will silently be ignored. *
Otherwise, a {@code BeanRuntimeException} is thrown. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_ignoreInvocationExceptionsOnSetters} *
* * @param value * The new value for this property. *
The default is false. * @return This object (for method chaining). */ public BeanContextBuilder ignoreInvocationExceptionsOnSetters(boolean value) { return set(BEAN_ignoreInvocationExceptionsOnSetters, value); } /** * Configuration property: Ignore invocation errors on setters. * *

* Shortcut for calling ignoreInvocationExceptionsOnSetters(true). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_ignoreInvocationExceptionsOnSetters} *
* * @return This object (for method chaining). */ public BeanContextBuilder ignoreInvocationExceptionsOnSetters() { return set(BEAN_ignoreInvocationExceptionsOnSetters, true); } /** * Configuration property: Ignore properties without setters. * *

* If true, trying to set a value on a bean property without a setter will silently be ignored. *
Otherwise, a {@code BeanRuntimeException} is thrown. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_ignorePropertiesWithoutSetters} *
* * @param value * The new value for this property. *
The default is true. * @return This object (for method chaining). */ public BeanContextBuilder ignorePropertiesWithoutSetters(boolean value) { return set(BEAN_ignorePropertiesWithoutSetters, value); } /** * Configuration property: Ignore unknown properties. * *

* If true, trying to set a value on a non-existent bean property will silently be ignored. *
Otherwise, a {@code BeanRuntimeException} is thrown. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_ignoreUnknownBeanProperties} *
* * @param value * The new value for this property. *
The default is false. * @return This object (for method chaining). */ public BeanContextBuilder ignoreUnknownBeanProperties(boolean value) { return set(BEAN_ignoreUnknownBeanProperties, value); } /** * Configuration property: Ignore unknown properties. * *

* Shortcut for calling ignoreUnknownBeanProperties(true). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_ignoreUnknownBeanProperties} *
* * @return This object (for method chaining). */ public BeanContextBuilder ignoreUnknownBeanProperties() { return set(BEAN_ignoreUnknownBeanProperties, true); } /** * Configuration property: Ignore unknown properties with null values. * *

* If true, trying to set a null value on a non-existent bean property will silently be ignored. *
Otherwise, a {@code BeanRuntimeException} is thrown. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_ignoreUnknownNullBeanProperties} *
* * @param value * The new value for this property. *
The default is true. * @return This object (for method chaining). */ public BeanContextBuilder ignoreUnknownNullBeanProperties(boolean value) { return set(BEAN_ignoreUnknownNullBeanProperties, value); } /** * Configuration property: Implementation classes. * *
See Also:
*
    *
  • {@link BeanContext#BEAN_implClasses} *
* * @param interfaceClass The interface class. * @param implClass The implementation class. * @param The class type of the interface. * @return This object (for method chaining). */ public BeanContextBuilder implClass(Class interfaceClass, Class implClass) { return addTo(BEAN_implClasses, interfaceClass.getName(), implClass); } /** * Configuration property: Implementation classes. * *

* 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). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_implClasses} *
* * @param values The new value for this property. * @return This object (for method chaining). */ public BeanContextBuilder implClasses(Map> values) { return set(BEAN_implClasses, values); } /** * Configuration property: Bean property includes. * *

* Specifies the set and order of names of properties associated with the bean class. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_includeProperties} *
* * @param beanClass The bean class. * @param value Comma-delimited list of property names. * @return This object (for method chaining). */ public BeanContextBuilder includeProperties(Class beanClass, String value) { return addTo(BEAN_includeProperties, beanClass.getName(), value); } /** * Configuration property: Bean property includes. * *

* Specifies the set and order of names of properties associated with the bean class. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_includeProperties} *
* * @param values The new value for this property. * @return This object (for method chaining). */ public BeanContextBuilder includeProperties(Map values) { return set(BEAN_includeProperties, values); } /** * Configuration property: Bean property includes. * *

* Specifies the set and order of names of properties associated with the bean class. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_includeProperties} *
* * @param beanClassName * The bean class name. *
Can be a simple name, fully-qualified name, or "*" for all beans. * @param value Comma-delimited list of property names. * @return This object (for method chaining). */ public BeanContextBuilder includeProperties(String beanClassName, String value) { return addTo(BEAN_includeProperties, beanClassName, value); } /** * Configuration property: Locale. * *

* Specifies a default locale for serializer and parser sessions. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_locale} *
* * @param value The new value for this property. * @return This object (for method chaining). */ public BeanContextBuilder locale(Locale value) { return set(BEAN_locale, value); } /** * Configuration property: Media type. * *

* Specifies a default media type value for serializer and parser sessions. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_mediaType} *
* * @param value The new value for this property. * @return This object (for method chaining). */ public BeanContextBuilder mediaType(MediaType value) { return set(BEAN_mediaType, value); } /** * Configuration property: Bean class exclusions. * *

* Not-bean classes are converted to Strings during serialization even if they appear to be * bean-like. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_notBeanClasses} *
* * @param append * If true, the previous value is appended to. *
Otherwise, the previous value is replaced. * @param values * The new value for this property. *
Values can consist of any of the following types: *
    *
  • Classes. *
  • Arrays and collections of classes. *
* @return This object (for method chaining). */ public BeanContextBuilder notBeanClasses(boolean append, Object...values) { return set(append, BEAN_notBeanClasses, values); } /** * Configuration property: Bean 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 to Strings during serialization. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_notBeanClasses} *
* * @param values The values to add to this property. * @return This object (for method chaining). */ public BeanContextBuilder notBeanClasses(Class...values) { return addTo(BEAN_notBeanClasses, values); } /** * Configuration property: Bean 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 to Strings during serialization. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_notBeanClasses} *
* * @param values * The values to add to this property. *
Values can consist of any of the following types: *
    *
  • Classes. *
  • Arrays and collections of classes. *
* @return This object (for method chaining). */ public BeanContextBuilder notBeanClasses(Object...values) { return addTo(BEAN_notBeanClasses, values); } /** * Configuration property: Bean class exclusions. * *
See Also:
*
    *
  • {@link BeanContext#BEAN_notBeanClasses} *
* * @param values * The values to remove from this property. *
Values can consist of any of the following types: *
    *
  • Classes. *
  • Arrays and collections of classes. *
* @return This object (for method chaining). */ public BeanContextBuilder notBeanClassesRemove(Object...values) { return removeFrom(BEAN_notBeanClasses, values); } /** * Configuration property: Bean package exclusions. * *

* When specified, the current list of ignore packages are appended to. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_notBeanPackages} *
* * @param append * If true, the previous value is appended to. *
Otherwise, the previous value is replaced. * @param values * The new values for this property. *
Values can consist of any of the following types: *
    *
  • Classes. *
  • Arrays and collections of classes. *
* @return This object (for method chaining). */ public BeanContextBuilder notBeanPackages(boolean append, Object...values) { return set(append, BEAN_notBeanPackages, values); } /** * Configuration property: Bean package exclusions. * *
See Also:
*
    *
  • {@link BeanContext#BEAN_notBeanPackages} *
* * @param values * The values to add to this property. *
Values can consist of any of the following types: *
    *
  • Strings. *
  • Arrays and collections of strings. *
* @return This object (for method chaining). */ public BeanContextBuilder notBeanPackages(Object...values) { return addTo(BEAN_notBeanPackages, values); } /** * Configuration property: Bean package exclusions. * *
See Also:
*
    *
  • {@link BeanContext#BEAN_notBeanPackages} *
* * @param values * The values to add to this property. * @return This object (for method chaining). */ public BeanContextBuilder notBeanPackages(String...values) { return addTo(BEAN_notBeanPackages, values); } /** * Configuration property: Bean package exclusions. * *
See Also:
*
    *
  • {@link BeanContext#BEAN_notBeanPackages} *
* * @param values *
Values can consist of any of the following types: *
Possible values are: *
    *
  • Strings. *
  • Arrays and collections of strings. *
* @return This object (for method chaining). */ public BeanContextBuilder notBeanPackagesRemove(Object...values) { return removeFrom(BEAN_notBeanPackages, values); } /** * Configuration property: POJO swaps. * *

* 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. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_pojoSwaps} *
* * @param append * If true, the previous value is appended to. *
Otherwise, the previous value is replaced. * @param values * The new value for this property. *
Values can consist of any of the following types: *
    *
  • Strings. *
  • Arrays and collections of strings. *
* @return This object (for method chaining). */ public BeanContextBuilder pojoSwaps(boolean append, Object...values) { return set(append, BEAN_pojoSwaps, values); } /** * Configuration property: POJO swaps. * *
See Also:
*
    *
  • {@link BeanContext#BEAN_pojoSwaps} *
* * @param values The values to add to this property. * @return This object (for method chaining). */ public BeanContextBuilder pojoSwaps(Class...values) { return addTo(BEAN_pojoSwaps, values); } /** * Configuration property: POJO swaps. * *
See Also:
*
    *
  • {@link BeanContext#BEAN_pojoSwaps} *
* * @param values * The values to add to this property. *
Values can consist of any of the following types: *
    *
  • Any subclass of {@link PojoSwap}. *
  • Any surrogate class. A shortcut for defining a {@link SurrogateSwap}. *
  • Any array or collection of the objects above. *
* @return This object (for method chaining). */ public BeanContextBuilder pojoSwaps(Object...values) { return addTo(BEAN_pojoSwaps, values); } /** * Configuration property: POJO swaps. * *
See Also:
*
    *
  • {@link BeanContext#BEAN_pojoSwaps} *
* * @param values * The values to remove from this property. *
Values can consist of any of the following types: *
    *
  • Any subclass of {@link PojoSwap}. *
  • Any surrogate class. A shortcut for defining a {@link SurrogateSwap}. *
  • Any array or collection of the objects above. *
* @return This object (for method chaining). */ public BeanContextBuilder pojoSwapsRemove(Object...values) { return removeFrom(BEAN_pojoSwaps, values); } /** * Configuration property: Bean property namer * *

* The class to use for calculating bean property names. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_propertyNamer} *
* * @param value * The new value for this setting. *
The default is {@link PropertyNamerDefault}. * @return This object (for method chaining). */ public BeanContextBuilder propertyNamer(Class value) { return set(BEAN_propertyNamer, value); } /** * Configuration property: 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. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_sortProperties} *
* * @param value * The new value for this property. *
The default is false. * @return This object (for method chaining). */ public BeanContextBuilder sortProperties(boolean value) { return set(BEAN_sortProperties, value); } /** * Configuration property: Sort bean properties. * *

* Shortcut for calling sortProperties(true). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_sortProperties} *
* * @return This object (for method chaining). */ public BeanContextBuilder sortProperties() { return set(BEAN_sortProperties, true); } /** * Configuration property: TimeZone. * *
See Also:
*
    *
  • {@link BeanContext#BEAN_timeZone} *
* * @param value The new value for this property. * @return This object (for method chaining). */ public BeanContextBuilder timeZone(TimeZone value) { return set(BEAN_timeZone, value); } /** * Configuration property: Use enum names. * *

* When enabled, enums are always serialized by name instead of using {@link Object#toString()}. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_useEnumNames} *
* * @return This object (for method chaining). */ public BeanContextBuilder useEnumNames() { return set(BEAN_useEnumNames, true); } /** * Configuration property: Use interface proxies. * *

* If true, then interfaces will be instantiated as proxy classes through the use of an * {@link InvocationHandler} if there is no other way of instantiating them. * *

See Also:
*
    *
  • {@link BeanContext#BEAN_useInterfaceProxies} *
* * @param value * The new value for this property. *
The default is true. * @return This object (for method chaining). */ public BeanContextBuilder useInterfaceProxies(boolean value) { return set(BEAN_useInterfaceProxies, value); } /** * Configuration property: Use Java Introspector. * *

* Using the built-in Java bean introspector will not pick up fields or non-standard getters/setters. * *

Notes:
*
    *
  • Most {@link Bean @Bean} annotations will be ignored if you enable this setting. *
* *
See Also:
*
    *
  • {@link BeanContext#BEAN_useJavaBeanIntrospector} *
* * @param value * The new value for this property. *
The default is false. * @return This object (for method chaining). */ public BeanContextBuilder useJavaBeanIntrospector(boolean value) { return set(BEAN_useJavaBeanIntrospector, value); } /** * Configuration property: Use Java Introspector. * *

* Shortcut for calling useJavaBeanIntrospector(true). * *

See Also:
*
    *
  • {@link BeanContext#BEAN_useJavaBeanIntrospector} *
* * @return This object (for method chaining). */ public BeanContextBuilder useJavaBeanIntrospector() { return set(BEAN_useJavaBeanIntrospector, true); } @Override /* ContextBuilder */ public BeanContextBuilder set(String name, Object value) { super.set(name, value); return this; } @Override /* ContextBuilder */ public BeanContextBuilder set(boolean append, String name, Object value) { super.set(append, name, value); return this; } @Override /* ContextBuilder */ public BeanContextBuilder set(Map properties) { super.set(properties); return this; } @Override /* ContextBuilder */ public BeanContextBuilder add(Map properties) { super.add(properties); return this; } @Override /* ContextBuilder */ public BeanContextBuilder addTo(String name, Object value) { super.addTo(name, value); return this; } @Override /* ContextBuilder */ public BeanContextBuilder addTo(String name, String key, Object value) { super.addTo(name, key, value); return this; } @Override /* ContextBuilder */ public BeanContextBuilder removeFrom(String name, Object value) { super.removeFrom(name, value); return this; } @Override /* ContextBuilder */ public BeanContextBuilder apply(PropertyStore copyFrom) { super.apply(copyFrom); return this; } }