http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroup.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroup.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroup.java index 1f3e218..33fad70 100644 --- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroup.java +++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroup.java @@ -12,12 +12,11 @@ // *************************************************************************************************************************** package org.apache.juneau.serializer; -import static org.apache.juneau.internal.ArrayUtils.*; - import java.util.*; import java.util.concurrent.*; import org.apache.juneau.*; +import org.apache.juneau.internal.*; /** * Represents a group of {@link Serializer Serializers} that can be looked up by media type. @@ -45,87 +44,40 @@ import org.apache.juneau.*; * <h5 class='section'>Example:</h5> * <p class='bcode'> * <jc>// Construct a new serializer group</jc> - * SerializerGroup g = <jk>new</jk> SerializerGroup(); - * - * <jc>// Add some serializers to it</jc> - * g.append(JsonSerializer.<jk>class</jk>, XmlSerializer.<jk>class</jk>); - * - * <jc>// Change settings for all serializers in the group and lock it.</jc> - * g.setProperty(SerializerContext.<jsf>SERIALIZER_useWhitespace</jsf>, <jk>true</jk>) - * .addPojoSwaps(CalendarSwap.ISO8601DT.<jk>class</jk>) - * .lock(); + * SerializerGroup g = <jk>new</jk> SerializerGroupBuilder(); + * .append(JsonSerializer.<jk>class</jk>, XmlSerializer.<jk>class</jk>); <jc>// Add some serializers to it</jc> + * .ws().pojoSwaps(CalendarSwap.ISO8601DT.<jk>class</jk>) <jc>// Change settings for all serializers in the group.</jc> + * .build(); * * <jc>// Find the appropriate serializer by Accept type</jc> * String mediaTypeMatch = g.findMatch(<js>"text/foo, text/json;q=0.8, text/*;q:0.6, *\/*;q=0.0"</js>); - * WriterSerializer s = (WriterSerializer)g.getSerializer(mediaTypeMatch); + * WriterSerializer s = g.getWriterSerializer(mediaTypeMatch); * * <jc>// Serialize a bean to JSON text </jc> * AddressBook addressBook = <jk>new</jk> AddressBook(); <jc>// Bean to serialize.</jc> * String json = s.serialize(addressBook); * </p> */ -public final class SerializerGroup extends Lockable { +public final class SerializerGroup { // Maps Accept headers to matching serializers. private final Map<String,SerializerMatch> cache = new ConcurrentHashMap<String,SerializerMatch>(); - private final CopyOnWriteArrayList<Serializer> serializers = new CopyOnWriteArrayList<Serializer>(); - - /** - * Adds the specified serializer to the beginning of this group. - * - * @param s The serializer to add to this group. - * @return This object (for method chaining). - */ - public SerializerGroup append(Serializer s) { - checkLock(); - synchronized(this) { - cache.clear(); - serializers.add(0, s); - } - return this; - } - - /** - * Registers the specified serializers with this group. - * - * @param s The serializers to append to this group. - * @return This object (for method chaining). - * @throws Exception Thrown if {@link Serializer} could not be constructed. - */ - public SerializerGroup append(Class<? extends Serializer>...s) throws Exception { - for (Class<? extends Serializer> ss : reverse(s)) - append(ss); - return this; - } + final Serializer[] serializers; + private final PropertyStore propertyStore; /** - * Same as {@link #append(Class[])}, except specify a single class to avoid unchecked compile warnings. + * Constructor. * - * @param s The serializer to append to this group. - * @return This object (for method chaining). - * @throws Exception Thrown if {@link Serializer} could not be constructed. + * @param propertyStore The modifiable properties that were used to initialize the serializers. + * A snapshot of these will be made so that we can clone and modify this group. + * @param serializers The serializers defined in this group. + * The order is important because they will be tried in reverse order (e.g. + * newer first) in which they will be tried to match against media types. */ - public SerializerGroup append(Class<? extends Serializer> s) throws Exception { - try { - append(s.newInstance()); - } catch (NoClassDefFoundError e) { - // Ignore if dependent library not found (e.g. Jena). - System.err.println(e); // NOT DEBUG - } - return this; - } - - /** - * Adds the serializers in the specified group to this group. - * - * @param g The group containing the serializers to add to this group. - * @return This object (for method chaining). - */ - public SerializerGroup append(SerializerGroup g) { - for (Serializer s : reverse(g.serializers.toArray(new Serializer[g.serializers.size()]))) - append(s); - return this; + public SerializerGroup(PropertyStore propertyStore, Serializer[] serializers) { + this.propertyStore = PropertyStore.create(propertyStore); + this.serializers = ArrayUtils.reverse(serializers); } /** @@ -224,9 +176,9 @@ public final class SerializerGroup extends Lockable { } /** - * Returns the media types that all parsers in this group can handle + * Returns the media types that all serializers in this group can handle. * <p> - * Entries are ordered in the same order as the parsers in the group. + * Entries are ordered in the same order as the serializers in the group. * * @return The list of media types. */ @@ -239,1225 +191,23 @@ public final class SerializerGroup extends Lockable { return l; } - - //-------------------------------------------------------------------------------- - // Properties - //-------------------------------------------------------------------------------- - - /** - * Calls {@link Serializer#setMaxDepth(int)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_maxDepth - */ - public SerializerGroup setMaxDepth(int value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setMaxDepth(value); - return this; - } - - /** - * Calls {@link Serializer#setInitialDepth(int)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_initialDepth - */ - public SerializerGroup setInitialDepth(int value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setInitialDepth(value); - return this; - } - - /** - * Calls {@link Serializer#setDetectRecursions(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_detectRecursions - */ - public SerializerGroup setDetectRecursions(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setDetectRecursions(value); - return this; - } - - /** - * Calls {@link Serializer#setIgnoreRecursions(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_ignoreRecursions - */ - public SerializerGroup setIgnoreRecursions(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setIgnoreRecursions(value); - return this; - } - /** - * Calls {@link Serializer#setUseWhitespace(boolean)} on all serializers in this group. + * Returns a copy of the property store that was used to create the serializers in this group. + * This method returns a new factory each time so is somewhat expensive. * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_useWhitespace + * @return A new copy of the property store passed in to the constructor. */ - public SerializerGroup setUseWhitespace(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setUseWhitespace(value); - return this; - } - - /** - * Calls {@link Serializer#setAddBeanTypeProperties(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_addBeanTypeProperties - */ - public SerializerGroup setAddBeanTypeProperties(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setAddBeanTypeProperties(value); - return this; - } - - /** - * Calls {@link Serializer#setQuoteChar(char)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_quoteChar - */ - public SerializerGroup setQuoteChar(char value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setQuoteChar(value); - return this; - } - - /** - * Calls {@link Serializer#setTrimNullProperties(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_trimNullProperties - */ - public SerializerGroup setTrimNullProperties(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setTrimNullProperties(value); - return this; - } - - /** - * Calls {@link Serializer#setTrimEmptyCollections(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_trimEmptyCollections - */ - public SerializerGroup setTrimEmptyCollections(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setTrimEmptyCollections(value); - return this; - } - - /** - * Calls {@link Serializer#setTrimEmptyMaps(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_trimEmptyMaps - */ - public SerializerGroup setTrimEmptyMaps(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setTrimEmptyMaps(value); - return this; - } - - /** - * Calls {@link Serializer#setTrimStrings(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_trimStrings - */ - public SerializerGroup setTrimStrings(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setTrimStrings(value); - return this; - } - - /** - * Calls {@link Serializer#setRelativeUriBase(String)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_relativeUriBase - */ - public SerializerGroup setRelativeUriBase(String value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setRelativeUriBase(value); - return this; - } - - /** - * Calls {@link Serializer#setAbsolutePathUriBase(String)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_absolutePathUriBase - */ - public SerializerGroup setAbsolutePathUriBase(String value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setAbsolutePathUriBase(value); - return this; - } - - /** - * Calls {@link Serializer#setSortCollections(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_sortCollections - */ - public SerializerGroup setSortCollections(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setSortCollections(value); - return this; - } - - /** - * Calls {@link Serializer#setSortMaps(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see SerializerContext#SERIALIZER_sortMaps - */ - public SerializerGroup setSortMaps(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setSortMaps(value); - return this; - } - - /** - * Calls {@link Serializer#setBeansRequireDefaultConstructor(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beansRequireDefaultConstructor - */ - public SerializerGroup setBeansRequireDefaultConstructor(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeansRequireDefaultConstructor(value); - return this; - } - - /** - * Calls {@link Serializer#setBeansRequireSerializable(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beansRequireSerializable - */ - public SerializerGroup setBeansRequireSerializable(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeansRequireSerializable(value); - return this; - } - - /** - * Calls {@link Serializer#setBeansRequireSettersForGetters(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beansRequireSettersForGetters - */ - public SerializerGroup setBeansRequireSettersForGetters(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeansRequireSettersForGetters(value); - return this; - } - - /** - * Calls {@link Serializer#setBeansRequireSomeProperties(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beansRequireSomeProperties - */ - public SerializerGroup setBeansRequireSomeProperties(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeansRequireSomeProperties(value); - return this; - } - - /** - * Calls {@link Serializer#setBeanMapPutReturnsOldValue(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanMapPutReturnsOldValue - */ - public SerializerGroup setBeanMapPutReturnsOldValue(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeanMapPutReturnsOldValue(value); - return this; - } - - /** - * Calls {@link Serializer#setBeanConstructorVisibility(Visibility)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanConstructorVisibility - */ - public SerializerGroup setBeanConstructorVisibility(Visibility value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeanConstructorVisibility(value); - return this; - } - - /** - * Calls {@link Serializer#setBeanClassVisibility(Visibility)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanClassVisibility - */ - public SerializerGroup setBeanClassVisibility(Visibility value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeanClassVisibility(value); - return this; - } - - /** - * Calls {@link Serializer#setBeanFieldVisibility(Visibility)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanFieldVisibility - */ - public SerializerGroup setBeanFieldVisibility(Visibility value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeanFieldVisibility(value); - return this; - } - - /** - * Calls {@link Serializer#setMethodVisibility(Visibility)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_methodVisibility - */ - public SerializerGroup setMethodVisibility(Visibility value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setMethodVisibility(value); - return this; - } - - /** - * Calls {@link Serializer#setUseJavaBeanIntrospector(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_useJavaBeanIntrospector - */ - public SerializerGroup setUseJavaBeanIntrospector(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setUseJavaBeanIntrospector(value); - return this; - } - - /** - * Calls {@link Serializer#setUseInterfaceProxies(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_useInterfaceProxies - */ - public SerializerGroup setUseInterfaceProxies(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setUseInterfaceProxies(value); - return this; - } - - /** - * Calls {@link Serializer#setIgnoreUnknownBeanProperties(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_ignoreUnknownBeanProperties - */ - public SerializerGroup setIgnoreUnknownBeanProperties(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setIgnoreUnknownBeanProperties(value); - return this; - } - - /** - * Calls {@link Serializer#setIgnoreUnknownNullBeanProperties(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_ignoreUnknownNullBeanProperties - */ - public SerializerGroup setIgnoreUnknownNullBeanProperties(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setIgnoreUnknownNullBeanProperties(value); - return this; - } - - /** - * Calls {@link Serializer#setIgnorePropertiesWithoutSetters(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_ignorePropertiesWithoutSetters - */ - public SerializerGroup setIgnorePropertiesWithoutSetters(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setIgnorePropertiesWithoutSetters(value); - return this; - } - - /** - * Calls {@link Serializer#setIgnoreInvocationExceptionsOnGetters(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_ignoreInvocationExceptionsOnGetters - */ - public SerializerGroup setIgnoreInvocationExceptionsOnGetters(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setIgnoreInvocationExceptionsOnGetters(value); - return this; - } - - /** - * Calls {@link Serializer#setIgnoreInvocationExceptionsOnSetters(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_ignoreInvocationExceptionsOnSetters - */ - public SerializerGroup setIgnoreInvocationExceptionsOnSetters(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setIgnoreInvocationExceptionsOnSetters(value); - return this; - } - - /** - * Calls {@link Serializer#setSortProperties(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_sortProperties - */ - public SerializerGroup setSortProperties(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setSortProperties(value); - return this; - } - - /** - * Calls {@link Serializer#setNotBeanPackages(String...)} on all serializers in this group. - * - * @param values The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanPackages - */ - public SerializerGroup setNotBeanPackages(String...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setNotBeanPackages(values); - return this; - } - - /** - * Calls {@link Serializer#setNotBeanPackages(Collection)} on all serializers in this group. - * - * @param values The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanPackages - */ - public SerializerGroup setNotBeanPackages(Collection<String> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setNotBeanPackages(values); - return this; - } - - /** - * Calls {@link Serializer#addNotBeanPackages(String...)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanPackages - * @see BeanContext#BEAN_notBeanPackages_remove - */ - public SerializerGroup addNotBeanPackages(String...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addNotBeanPackages(values); - return this; - } - - /** - * Calls {@link Serializer#addNotBeanPackages(Collection)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanPackages - * @see BeanContext#BEAN_notBeanPackages_remove - */ - public SerializerGroup addNotBeanPackages(Collection<String> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addNotBeanPackages(values); - return this; - } - - /** - * Calls {@link Serializer#removeNotBeanPackages(String...)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanPackages - * @see BeanContext#BEAN_notBeanPackages_remove - */ - public SerializerGroup removeNotBeanPackages(String...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.removeNotBeanPackages(values); - return this; - } - - /** - * Calls {@link Serializer#removeNotBeanPackages(Collection)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanPackages - * @see BeanContext#BEAN_notBeanPackages_remove - */ - public SerializerGroup removeNotBeanPackages(Collection<String> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.removeNotBeanPackages(values); - return this; + public PropertyStore createPropertyStore() { + return PropertyStore.create(propertyStore); } /** - * Calls {@link Serializer#setNotBeanClasses(Class...)} on all serializers in this group. + * Returns a copy of the serializers in this group. + * This method returns a new array each time so is somewhat expensive. * - * @param values The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanClasses + * @return A new array containing the serializers in this group. */ - public SerializerGroup setNotBeanClasses(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setNotBeanClasses(values); - return this; - } - - /** - * Calls {@link Serializer#setNotBeanClasses(Collection)} on all serializers in this group. - * - * @param values The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanPackages - */ - public SerializerGroup setNotBeanClasses(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setNotBeanClasses(values); - return this; - } - - /** - * Calls {@link Serializer#addNotBeanClasses(Class...)} on all serializers in this group. - * - * @param values The values to add to this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanClasses - * @see BeanContext#BEAN_notBeanClasses_add - */ - public SerializerGroup addNotBeanClasses(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addNotBeanClasses(values); - return this; - } - - /** - * Calls {@link Serializer#addNotBeanClasses(Collection)} on all serializers in this group. - * - * @param values The values to add to this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanClasses - * @see BeanContext#BEAN_notBeanClasses_add - */ - public SerializerGroup addNotBeanClasses(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addNotBeanClasses(values); - return this; - } - - /** - * Calls {@link Serializer#removeNotBeanClasses(Class...)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanClasses - * @see BeanContext#BEAN_notBeanClasses_remove - */ - public SerializerGroup removeNotBeanClasses(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.removeNotBeanClasses(values); - return this; - } - - /** - * Calls {@link Serializer#removeNotBeanClasses(Collection)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_notBeanClasses - * @see BeanContext#BEAN_notBeanClasses_remove - */ - public SerializerGroup removeNotBeanClasses(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.removeNotBeanClasses(values); - return this; - } - - /** - * Calls {@link Serializer#setBeanFilters(Class...)} on all serializers in this group. - * - * @param values The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanFilters - */ - public SerializerGroup setBeanFilters(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeanFilters(values); - return this; - } - - /** - * Calls {@link Serializer#setBeanFilters(Collection)} on all serializers in this group. - * - * @param values The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanFilters - */ - public SerializerGroup setBeanFilters(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeanFilters(values); - return this; - } - - /** - * Calls {@link Serializer#addBeanFilters(Class...)} on all serializers in this group. - * - * @param values The values to add to this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanFilters - * @see BeanContext#BEAN_beanFilters_add - */ - public SerializerGroup addBeanFilters(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addBeanFilters(values); - return this; - } - - /** - * Calls {@link Serializer#addBeanFilters(Collection)} on all serializers in this group. - * - * @param values The values to add to this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanFilters - * @see BeanContext#BEAN_beanFilters_add - */ - public SerializerGroup addBeanFilters(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addBeanFilters(values); - return this; - } - - /** - * Calls {@link Serializer#removeBeanFilters(Class...)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanFilters - * @see BeanContext#BEAN_beanFilters_remove - */ - public SerializerGroup removeBeanFilters(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.removeBeanFilters(values); - return this; - } - - /** - * Calls {@link Serializer#removeBeanFilters(Collection)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanFilters - * @see BeanContext#BEAN_beanFilters_remove - */ - public SerializerGroup removeBeanFilters(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.removeBeanFilters(values); - return this; - } - - /** - * Calls {@link Serializer#setPojoSwaps(Class...)} on all serializers in this group. - * - * @param values The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_pojoSwaps - */ - public SerializerGroup setPojoSwaps(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setPojoSwaps(values); - return this; - } - - /** - * Calls {@link Serializer#setPojoSwaps(Collection)} on all serializers in this group. - * - * @param values The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_pojoSwaps - */ - public SerializerGroup setPojoSwaps(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setPojoSwaps(values); - return this; - } - - /** - * Calls {@link Serializer#addPojoSwaps(Class...)} on all serializers in this group. - * - * @param values The values to add to this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_pojoSwaps - * @see BeanContext#BEAN_pojoSwaps_add - */ - public SerializerGroup addPojoSwaps(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addPojoSwaps(values); - return this; - } - - /** - * Calls {@link Serializer#addPojoSwaps(Collection)} on all serializers in this group. - * - * @param values The values to add to this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_pojoSwaps - * @see BeanContext#BEAN_pojoSwaps_add - */ - public SerializerGroup addPojoSwaps(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addPojoSwaps(values); - return this; - } - - /** - * Calls {@link Serializer#removePojoSwaps(Class...)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_pojoSwaps - * @see BeanContext#BEAN_pojoSwaps_remove - */ - public SerializerGroup removePojoSwaps(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.removePojoSwaps(values); - return this; - } - - /** - * Calls {@link Serializer#removePojoSwaps(Collection)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_pojoSwaps - * @see BeanContext#BEAN_pojoSwaps_remove - */ - public SerializerGroup removePojoSwaps(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.removePojoSwaps(values); - return this; - } - - /** - * Calls {@link Serializer#setImplClasses(Map)} on all serializers in this group. - * - * @param values The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_implClasses - */ - public SerializerGroup setImplClasses(Map<Class<?>,Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setImplClasses(values); - return this; - } - - /** - * Calls {@link Serializer#addImplClass(Class,Class)} on all serializers in this group. - * - * @param interfaceClass The interface class. - * @param implClass The implementation class. - * @param <T> The class type of the interface. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_implClasses - * @see BeanContext#BEAN_implClasses_put - */ - public <T> SerializerGroup addImplClass(Class<T> interfaceClass, Class<? extends T> implClass) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addImplClass(interfaceClass, implClass); - return this; - } - - /** - * Calls {@link Serializer#setBeanDictionary(Class...)} on all serializers in this group. - * - * @param values The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanDictionary - */ - public SerializerGroup setBeanDictionary(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeanDictionary(values); - return this; - } - - /** - * Calls {@link Serializer#setBeanDictionary(Collection)} on all serializers in this group. - * - * @param values The values to add to this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanDictionary - * @see BeanContext#BEAN_beanDictionary_add - */ - public SerializerGroup setBeanDictionary(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeanDictionary(values); - return this; - } - - /** - * Calls {@link Serializer#addToBeanDictionary(Class...)} on all serializers in this group. - * - * @param values The values to add to this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanDictionary - * @see BeanContext#BEAN_beanDictionary_add - */ - public SerializerGroup addToBeanDictionary(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addToBeanDictionary(values); - return this; - } - - /** - * Calls {@link Serializer#addToBeanDictionary(Collection)} on all serializers in this group. - * - * @param values The values to add to this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanDictionary - * @see BeanContext#BEAN_beanDictionary_add - */ - public SerializerGroup addToBeanDictionary(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addToBeanDictionary(values); - return this; - } - - /** - * Calls {@link Serializer#removeFromBeanDictionary(Class...)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanDictionary - * @see BeanContext#BEAN_beanDictionary_remove - */ - public SerializerGroup removeFromBeanDictionary(Class<?>...values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.removeFromBeanDictionary(values); - return this; - } - - /** - * Calls {@link Serializer#removeFromBeanDictionary(Collection)} on all serializers in this group. - * - * @param values The values to remove from this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanDictionary - * @see BeanContext#BEAN_beanDictionary_remove - */ - public SerializerGroup removeFromBeanDictionary(Collection<Class<?>> values) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.removeFromBeanDictionary(values); - return this; - } - - /** - * Calls {@link Serializer#setBeanTypePropertyName(String)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_beanTypePropertyName - */ - public SerializerGroup setBeanTypePropertyName(String value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setBeanTypePropertyName(value); - return this; - } - - /** - * Calls {@link Serializer#setDefaultParser(Class)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_defaultParser - */ - public SerializerGroup setDefaultParser(Class<?> value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setDefaultParser(value); - return this; - } - - /** - * Calls {@link Serializer#setLocale(Locale)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_locale - */ - public SerializerGroup setLocale(Locale value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setLocale(value); - return this; - } - - /** - * Calls {@link Serializer#setTimeZone(TimeZone)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_timeZone - */ - public SerializerGroup setTimeZone(TimeZone value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setTimeZone(value); - return this; - } - - /** - * Calls {@link Serializer#setMediaType(MediaType)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_mediaType - */ - public SerializerGroup setMediaType(MediaType value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setMediaType(value); - return this; - } - - /** - * Calls {@link Serializer#setDebug(boolean)} on all serializers in this group. - * - * @param value The new value for this property. - * @return This object (for method chaining). - * @throws LockedException If {@link #lock()} was called on this class. - * @see BeanContext#BEAN_debug - */ - public SerializerGroup setDebug(boolean value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setDebug(value); - return this; - } - - /** - * Calls {@link Serializer#setProperty(String,Object)} on all serializers in this group. - * - * @param name The property name. - * @param value The property value. - * @return This class (for method chaining). - * @throws LockedException If {@link #lock()} has been called on this object or {@link ContextFactory} object. - * @see ContextFactory#setProperty(String, Object) - */ - public SerializerGroup setProperty(String name, Object value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setProperty(name, value); - return this; - } - - /** - * Calls {@link Serializer#setProperties(ObjectMap)} on all serializers in this group. - * - * @param properties The properties to set on this class. - * @return This class (for method chaining). - * @throws LockedException If {@link #lock()} has been called on this object. - * @see ContextFactory#setProperties(java.util.Map) - */ - public SerializerGroup setProperties(ObjectMap properties) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setProperties(properties); - return this; - } - - /** - * Calls {@link Serializer#addToProperty(String,Object)} on all serializers in this group. - * - * @param name The property name. - * @param value The new value to add to the SET property. - * @return This object (for method chaining). - * @throws ConfigException If property is not a SET property. - * @throws LockedException If {@link #lock()} has been called on this object. - */ - public SerializerGroup addToProperty(String name, Object value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.addToProperty(name, value); - return this; - } - - /** - * Calls {@link Serializer#putToProperty(String,Object,Object)} on all serializers in this group. - * - * @param name The property name. - * @param key The property value map key. - * @param value The property value map value. - * @return This object (for method chaining). - * @throws ConfigException If property is not a MAP property. - * @throws LockedException If {@link #lock()} has been called on this object. - */ - public SerializerGroup putToProperty(String name, Object key, Object value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.putToProperty(name, key, value); - return this; - } - - /** - * Calls {@link Serializer#putToProperty(String,Object)} on all serializers in this group. - * - * @param name The property value. - * @param value The property value map value. - * @return This object (for method chaining). - * @throws ConfigException If property is not a MAP property. - * @throws LockedException If {@link #lock()} has been called on this object. - */ - public SerializerGroup putToProperty(String name, Object value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.putToProperty(name, value); - return this; - } - - /** - * Calls {@link Serializer#removeFromProperty(String,Object)} on all serializers in this group. - * - * @param name The property name. - * @param value The property value in the SET property. - * @return This object (for method chaining). - * @throws ConfigException If property is not a SET property. - * @throws LockedException If {@link #lock()} has been called on this object. - */ - public SerializerGroup removeFromProperty(String name, Object value) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.removeFromProperty(name, value); - return this; - } - - - //-------------------------------------------------------------------------------- - // Overridden methods - //-------------------------------------------------------------------------------- - - /** - * Calls {@link Serializer#setClassLoader(ClassLoader)} on all serializers in this group. - * - * @param classLoader The new classloader. - * @throws LockedException If {@link ContextFactory#lock()} was called on this class or the bean context. - * @return This object (for method chaining). - * @see ContextFactory#setClassLoader(ClassLoader) - */ - public SerializerGroup setClassLoader(ClassLoader classLoader) throws LockedException { - checkLock(); - for (Serializer s : serializers) - s.setClassLoader(classLoader); - return this; - } - - /** - * Locks this group and all serializers in this group. - */ - @Override /* Lockable */ - public SerializerGroup lock() { - super.lock(); - for (Serializer s : serializers) - s.lock(); - return this; - } - - /** - * Clones this group and all serializers in this group. - */ - @Override /* Lockable */ - public SerializerGroup clone() throws CloneNotSupportedException { - SerializerGroup g = new SerializerGroup(); - - List<Serializer> l = new ArrayList<Serializer>(serializers.size()); - for (Serializer s : serializers) - l.add(s.clone()); - - g.serializers.addAll(l); - - return g; + public Serializer[] getSerializers() { + return ArrayUtils.reverse(serializers); } }
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java new file mode 100644 index 0000000..b639358 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java @@ -0,0 +1,983 @@ +// *************************************************************************************************************************** +// * 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.serializer; + +import static org.apache.juneau.BeanContext.*; +import static org.apache.juneau.serializer.SerializerContext.*; + +import java.util.*; + +import org.apache.juneau.*; + +/** + * Builder class for creating instances of {@link SerializerGroup}. + */ +public class SerializerGroupBuilder { + + private final List<Object> serializers; + private final PropertyStore propertyStore; + + /** + * Create an empty serializer group builder. + */ + public SerializerGroupBuilder() { + this.serializers = new ArrayList<Object>(); + this.propertyStore = PropertyStore.create(); + } + + /** + * Clone an existing serializer group builder. + * @param copyFrom The serializer group that we're copying settings and serializers from. + */ + public SerializerGroupBuilder(SerializerGroup copyFrom) { + this.serializers = new ArrayList<Object>(Arrays.asList(copyFrom.serializers)); + this.propertyStore = copyFrom.createPropertyStore(); + } + + /** + * Registers the specified serializers with this group. + * + * @param s The serializers to append to this group. + * @return This object (for method chaining). + */ + public SerializerGroupBuilder append(Class<?>...s) { + serializers.addAll(Arrays.asList(s)); + return this; + } + + /** + * Registers the specified serializers with this group. + * + * @param s The serializers to append to this group. + * @return This object (for method chaining). + */ + public SerializerGroupBuilder append(Serializer...s) { + serializers.addAll(Arrays.asList(s)); + return this; + } + + /** + * Registers the specified serializers with this group. + * + * @param s The serializers to append to this group. + * @return This object (for method chaining). + */ + public SerializerGroupBuilder append(List<Serializer> s) { + serializers.addAll(s); + return this; + } + + /** + * Creates a new {@link SerializerGroup} object using a snapshot of the settings defined in this builder. + * <p> + * This method can be called multiple times to produce multiple serializer groups. + * + * @return A new {@link SerializerGroup} object. + */ + @SuppressWarnings("unchecked") + public SerializerGroup build() { + List<Serializer> l = new ArrayList<Serializer>(); + for (Object s : serializers) { + Class<? extends Serializer> c = null; + PropertyStore ps = propertyStore; + if (s instanceof Class) { + c = ((Class<? extends Serializer>)s); + } else { + // Note that if we added a serializer instance, we want a new instance with this builder's properties + // on top of the previous serializer's properties. + Serializer s2 = (Serializer)s; + ps = s2.createPropertyStore().copyFrom(propertyStore); + c = s2.getClass(); + } + try { + l.add(c.getConstructor(PropertyStore.class).newInstance(ps)); + } catch (Exception e) { + throw new RuntimeException("Could not instantiate serializer " + c.getName(), e); + } + } + return new SerializerGroup(propertyStore, l.toArray(new Serializer[l.size()])); + } + + + //-------------------------------------------------------------------------------- + // Properties + //-------------------------------------------------------------------------------- + + /** + * Sets a property on all serializers in this group. + * + * @param name The property name. + * @param value The property value. + * @return This object (for method chaining). + * @see PropertyStore#setProperty(String, Object) + */ + public SerializerGroupBuilder property(String name, Object value) { + propertyStore.setProperty(name, value); + return this; + } + + /** + * Sets a set of properties on all serializers in this group. + * + * @param properties The properties to set on this class. + * @return This object (for method chaining). + * @see PropertyStore#setProperties(java.util.Map) + */ + public SerializerGroupBuilder properties(ObjectMap properties) { + propertyStore.setProperties(properties); + return this; + } + + /** + * Adds a value to a SET property on all serializers in this group. + * + * @param name The property name. + * @param value The new value to add to the SET property. + * @return This object (for method chaining). + * @throws ConfigException If property is not a SET property. + */ + public SerializerGroupBuilder addToProperty(String name, Object value) { + propertyStore.addToProperty(name, value); + return this; + } + + /** + * Adds or overwrites a value to a MAP property on all serializers in this group. + * + * @param name The property name. + * @param key The property value map key. + * @param value The property value map value. + * @return This object (for method chaining). + * @throws ConfigException If property is not a MAP property. + */ + public SerializerGroupBuilder putToProperty(String name, Object key, Object value) { + propertyStore.putToProperty(name, key, value); + return this; + } + + /** + * Adds or overwrites a value to a MAP property on all serializers in this group. + * + * @param name The property value. + * @param value The property value map value. + * @return This object (for method chaining). + * @throws ConfigException If property is not a MAP property. + */ + public SerializerGroupBuilder putToProperty(String name, Object value) { + propertyStore.putToProperty(name, value); + return this; + } + + /** + * Removes a value from a SET property on all serializers in this group. + * + * @param name The property name. + * @param value The property value in the SET property. + * @return This object (for method chaining). + * @throws ConfigException If property is not a SET property. + */ + public SerializerGroupBuilder removeFromProperty(String name, Object value) { + propertyStore.removeFromProperty(name, value); + return this; + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_maxDepth} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_maxDepth + */ + public SerializerGroupBuilder maxDepth(int value) { + return property(SERIALIZER_maxDepth, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_initialDepth} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_initialDepth + */ + public SerializerGroupBuilder initialDepth(int value) { + return property(SERIALIZER_initialDepth, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_detectRecursions} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_detectRecursions + */ + public SerializerGroupBuilder detectRecursions(boolean value) { + return property(SERIALIZER_detectRecursions, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_ignoreRecursions} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_ignoreRecursions + */ + public SerializerGroupBuilder ignoreRecursions(boolean value) { + return property(SERIALIZER_ignoreRecursions, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_useWhitespace} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_useWhitespace + */ + public SerializerGroupBuilder useWhitespace(boolean value) { + return property(SERIALIZER_useWhitespace, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_addBeanTypeProperties} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_addBeanTypeProperties + */ + public SerializerGroupBuilder addBeanTypeProperties(boolean value) { + return property(SERIALIZER_addBeanTypeProperties, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_quoteChar} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_quoteChar + */ + public SerializerGroupBuilder quoteChar(char value) { + return property(SERIALIZER_quoteChar, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_trimNullProperties} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_trimNullProperties + */ + public SerializerGroupBuilder trimNullProperties(boolean value) { + return property(SERIALIZER_trimNullProperties, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_trimEmptyCollections} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_trimEmptyCollections + */ + public SerializerGroupBuilder trimEmptyCollections(boolean value) { + return property(SERIALIZER_trimEmptyCollections, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_trimEmptyMaps} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_trimEmptyMaps + */ + public SerializerGroupBuilder trimEmptyMaps(boolean value) { + return property(SERIALIZER_trimEmptyMaps, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_trimStrings} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_trimStrings + */ + public SerializerGroupBuilder trimStrings(boolean value) { + return property(SERIALIZER_trimStrings, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_relativeUriBase} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_relativeUriBase + */ + public SerializerGroupBuilder relativeUriBase(String value) { + return property(SERIALIZER_relativeUriBase, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_absolutePathUriBase} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_absolutePathUriBase + */ + public SerializerGroupBuilder absolutePathUriBase(String value) { + return property(SERIALIZER_absolutePathUriBase, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_sortCollections} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_sortCollections + */ + public SerializerGroupBuilder sortCollections(boolean value) { + return property(SERIALIZER_sortCollections, value); + } + + /** + * Sets the {@link SerializerContext#SERIALIZER_sortMaps} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see SerializerContext#SERIALIZER_sortMaps + */ + public SerializerGroupBuilder sortMaps(boolean value) { + return property(SERIALIZER_sortMaps, value); + } + + /** + * Sets the {@link BeanContext#BEAN_beansRequireDefaultConstructor} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beansRequireDefaultConstructor + */ + public SerializerGroupBuilder beansRequireDefaultConstructor(boolean value) { + return property(BEAN_beansRequireDefaultConstructor, value); + } + + /** + * Sets the {@link BeanContext#BEAN_beansRequireSerializable} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beansRequireSerializable + */ + public SerializerGroupBuilder beansRequireSerializable(boolean value) { + return property(BEAN_beansRequireSerializable, value); + } + + /** + * Sets the {@link BeanContext#BEAN_beansRequireSettersForGetters} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beansRequireSettersForGetters + */ + public SerializerGroupBuilder beansRequireSettersForGetters(boolean value) { + return property(BEAN_beansRequireSettersForGetters, value); + } + + /** + * Sets the {@link BeanContext#BEAN_beansRequireSomeProperties} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beansRequireSomeProperties + */ + public SerializerGroupBuilder beansRequireSomeProperties(boolean value) { + return property(BEAN_beansRequireSomeProperties, value); + } + + /** + * Sets the {@link BeanContext#BEAN_beanMapPutReturnsOldValue} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanMapPutReturnsOldValue + */ + public SerializerGroupBuilder beanMapPutReturnsOldValue(boolean value) { + return property(BEAN_beanMapPutReturnsOldValue, value); + } + + /** + * Sets the {@link BeanContext#BEAN_beanConstructorVisibility} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanConstructorVisibility + */ + public SerializerGroupBuilder beanConstructorVisibility(Visibility value) { + return property(BEAN_beanConstructorVisibility, value); + } + + /** + * Sets the {@link BeanContext#BEAN_beanClassVisibility} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanClassVisibility + */ + public SerializerGroupBuilder beanClassVisibility(Visibility value) { + return property(BEAN_beanClassVisibility, value); + } + + /** + * Sets the {@link BeanContext#BEAN_beanFieldVisibility} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanFieldVisibility + */ + public SerializerGroupBuilder beanFieldVisibility(Visibility value) { + return property(BEAN_beanFieldVisibility, value); + } + + /** + * Sets the {@link BeanContext#BEAN_methodVisibility} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_methodVisibility + */ + public SerializerGroupBuilder methodVisibility(Visibility value) { + return property(BEAN_methodVisibility, value); + } + + /** + * Sets the {@link BeanContext#BEAN_useJavaBeanIntrospector} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_useJavaBeanIntrospector + */ + public SerializerGroupBuilder useJavaBeanIntrospector(boolean value) { + return property(BEAN_useJavaBeanIntrospector, value); + } + + /** + * Sets the {@link BeanContext#BEAN_useInterfaceProxies} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_useInterfaceProxies + */ + public SerializerGroupBuilder useInterfaceProxies(boolean value) { + return property(BEAN_useInterfaceProxies, value); + } + + /** + * Sets the {@link BeanContext#BEAN_ignoreUnknownBeanProperties} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_ignoreUnknownBeanProperties + */ + public SerializerGroupBuilder ignoreUnknownBeanProperties(boolean value) { + return property(BEAN_ignoreUnknownBeanProperties, value); + } + + /** + * Sets the {@link BeanContext#BEAN_ignoreUnknownNullBeanProperties} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_ignoreUnknownNullBeanProperties + */ + public SerializerGroupBuilder ignoreUnknownNullBeanProperties(boolean value) { + return property(BEAN_ignoreUnknownNullBeanProperties, value); + } + + /** + * Sets the {@link BeanContext#BEAN_ignorePropertiesWithoutSetters} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_ignorePropertiesWithoutSetters + */ + public SerializerGroupBuilder ignorePropertiesWithoutSetters(boolean value) { + return property(BEAN_ignorePropertiesWithoutSetters, value); + } + + /** + * Sets the {@link BeanContext#BEAN_ignoreInvocationExceptionsOnGetters} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_ignoreInvocationExceptionsOnGetters + */ + public SerializerGroupBuilder ignoreInvocationExceptionsOnGetters(boolean value) { + return property(BEAN_ignoreInvocationExceptionsOnGetters, value); + } + + /** + * Sets the {@link BeanContext#BEAN_ignoreInvocationExceptionsOnSetters} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_ignoreInvocationExceptionsOnSetters + */ + public SerializerGroupBuilder ignoreInvocationExceptionsOnSetters(boolean value) { + return property(BEAN_ignoreInvocationExceptionsOnSetters, value); + } + + /** + * Sets the {@link BeanContext#BEAN_sortProperties} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_sortProperties + */ + public SerializerGroupBuilder sortProperties(boolean value) { + return property(BEAN_sortProperties, value); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanPackages_add} property on all serializers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanPackages_add + */ + public SerializerGroupBuilder notBeanPackages(String...values) { + return property(BEAN_notBeanPackages_add, values); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanPackages_add} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanPackages_add + */ + public SerializerGroupBuilder notBeanPackages(Collection<String> value) { + return property(BEAN_notBeanPackages_add, value); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanPackages} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanPackages + */ + public SerializerGroupBuilder setNotBeanPackages(String...values) { + return property(BEAN_notBeanPackages, values); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanPackages} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanPackages + */ + public SerializerGroupBuilder setNotBeanPackages(Collection<String> values) { + return property(BEAN_notBeanPackages, values); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanPackages_remove} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanPackages_remove + */ + public SerializerGroupBuilder removeNotBeanPackages(String...values) { + return property(BEAN_notBeanPackages_remove, values); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanPackages_remove} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanPackages_remove + */ + public SerializerGroupBuilder removeNotBeanPackages(Collection<String> values) { + return property(BEAN_notBeanPackages_remove, values); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanClasses_add} property on all serializers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanClasses_add + */ + public SerializerGroupBuilder notBeanClasses(Class<?>...values) { + return property(BEAN_notBeanClasses_add, values); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanClasses_add} property on all serializers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanPackages_add + */ + public SerializerGroupBuilder notBeanClasses(Collection<Class<?>> values) { + return property(BEAN_notBeanClasses_add, values); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanClasses} property on all serializers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanClasses + */ + public SerializerGroupBuilder setNotBeanClasses(Class<?>...values) { + return property(BEAN_notBeanClasses, values); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanClasses} property on all serializers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanClasses + */ + public SerializerGroupBuilder setNotBeanClasses(Collection<Class<?>> values) { + return property(BEAN_notBeanClasses, values); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanClasses_remove} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanClasses_remove + */ + public SerializerGroupBuilder removeNotBeanClasses(Class<?>...values) { + return property(BEAN_notBeanClasses_remove, values); + } + + /** + * Sets the {@link BeanContext#BEAN_notBeanClasses_remove} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_notBeanClasses_remove + */ + public SerializerGroupBuilder removeNotBeanClasses(Collection<Class<?>> values) { + return property(BEAN_notBeanClasses_remove, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanFilters_add} property on all serializers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanFilters_add + */ + public SerializerGroupBuilder beanFilters(Class<?>...values) { + return property(BEAN_beanFilters_add, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanFilters_add} property on all serializers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanFilters_add + */ + public SerializerGroupBuilder beanFilters(Collection<Class<?>> values) { + return property(BEAN_beanFilters_add, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanFilters} property on all serializers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanFilters + */ + public SerializerGroupBuilder setBeanFilters(Class<?>...values) { + return property(BEAN_beanFilters, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanFilters} property on all serializers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanFilters + */ + public SerializerGroupBuilder setBeanFilters(Collection<Class<?>> values) { + return property(BEAN_beanFilters, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanFilters_remove} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanFilters_remove + */ + public SerializerGroupBuilder removeBeanFilters(Class<?>...values) { + return property(BEAN_beanFilters_remove, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanFilters_remove} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanFilters_remove + */ + public SerializerGroupBuilder removeBeanFilters(Collection<Class<?>> values) { + return property(BEAN_beanFilters_remove, values); + } + + /** + * Sets the {@link BeanContext#BEAN_pojoSwaps_add} property on all serializers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_pojoSwaps_add + */ + public SerializerGroupBuilder pojoSwaps(Class<?>...values) { + return property(BEAN_pojoSwaps_add, values); + } + + /** + * Sets the {@link BeanContext#BEAN_pojoSwaps_add} property on all serializers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_pojoSwaps_add + */ + public SerializerGroupBuilder pojoSwaps(Collection<Class<?>> values) { + return property(BEAN_pojoSwaps_add, values); + } + + /** + * Sets the {@link BeanContext#BEAN_pojoSwaps} property on all serializers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_pojoSwaps + */ + public SerializerGroupBuilder setPojoSwaps(Class<?>...values) { + return property(BEAN_pojoSwaps, values); + } + + /** + * Sets the {@link BeanContext#BEAN_pojoSwaps} property on all serializers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_pojoSwaps + */ + public SerializerGroupBuilder setPojoSwaps(Collection<Class<?>> values) { + return property(BEAN_pojoSwaps, values); + } + + /** + * Sets the {@link BeanContext#BEAN_pojoSwaps_remove} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_pojoSwaps_remove + */ + public SerializerGroupBuilder removePojoSwaps(Class<?>...values) { + return property(BEAN_pojoSwaps_remove, values); + } + + /** + * Sets the {@link BeanContext#BEAN_pojoSwaps_remove} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_pojoSwaps_remove + */ + public SerializerGroupBuilder removePojoSwaps(Collection<Class<?>> values) { + return property(BEAN_pojoSwaps_remove, values); + } + + /** + * Sets the {@link BeanContext#BEAN_implClasses} property on all serializers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_implClasses + */ + public SerializerGroupBuilder implClasses(Map<Class<?>,Class<?>> values) { + return property(BEAN_implClasses, values); + } + + /** + * Sets the {@link BeanContext#BEAN_implClasses_put} property on all serializers in this group. + * + * @param interfaceClass The interface class. + * @param implClass The implementation class. + * @param <T> The class type of the interface. + * @return This object (for method chaining). + * @see BeanContext#BEAN_implClasses + * @see BeanContext#BEAN_implClasses_put + */ + public <T> SerializerGroupBuilder implClass(Class<T> interfaceClass, Class<? extends T> implClass) { + return putToProperty(BEAN_implClasses, interfaceClass, implClass); + } + + /** + * Sets the {@link BeanContext#BEAN_beanDictionary_add} property on all serializers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanDictionary_add + */ + public SerializerGroupBuilder beanDictionary(Class<?>...values) { + return property(BEAN_beanDictionary_add, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanDictionary_add} property on all serializers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanDictionary_add + */ + public SerializerGroupBuilder beanDictionary(Collection<Class<?>> values) { + return property(BEAN_beanDictionary_add, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanDictionary} property on all serializers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanDictionary + */ + public SerializerGroupBuilder setBeanDictionary(Class<?>...values) { + return property(BEAN_beanDictionary, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanDictionary} property on all serializers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanDictionary + */ + public SerializerGroupBuilder setBeanDictionary(Collection<Class<?>> values) { + return property(BEAN_beanDictionary, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanDictionary_remove} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanDictionary_remove + */ + public SerializerGroupBuilder removeFromBeanDictionary(Class<?>...values) { + return property(BEAN_beanDictionary_remove, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanDictionary_remove} property on all serializers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanDictionary_remove + */ + public SerializerGroupBuilder removeFromBeanDictionary(Collection<Class<?>> values) { + return property(BEAN_beanDictionary_remove, values); + } + + /** + * Sets the {@link BeanContext#BEAN_beanTypePropertyName} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_beanTypePropertyName + */ + public SerializerGroupBuilder beanTypePropertyName(String value) { + return property(BEAN_beanTypePropertyName, value); + } + + /** + * Sets the {@link BeanContext#BEAN_defaultParser} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_defaultParser + */ + public SerializerGroupBuilder defaultParser(Class<?> value) { + return property(BEAN_defaultParser, value); + } + + /** + * Sets the {@link BeanContext#BEAN_locale} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_locale + */ + public SerializerGroupBuilder locale(Locale value) { + return property(BEAN_locale, value); + } + + /** + * Sets the {@link BeanContext#BEAN_timeZone} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_timeZone + */ + public SerializerGroupBuilder timeZone(TimeZone value) { + return property(BEAN_timeZone, value); + } + + /** + * Sets the {@link BeanContext#BEAN_mediaType} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_mediaType + */ + public SerializerGroupBuilder mediaType(MediaType value) { + return property(BEAN_mediaType, value); + } + + /** + * Sets the {@link BeanContext#BEAN_debug} property on all serializers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @see BeanContext#BEAN_debug + */ + public SerializerGroupBuilder debug(boolean value) { + return property(BEAN_debug, value); + } + + /** + * Specifies the classloader to use when resolving classes from strings for all serializers in this group. + * <p> + * Can be used for resolving class names when the classes being created are in a different + * classloader from the Juneau code. + * <p> + * If <jk>null</jk>, the system classloader will be used to resolve classes. + * + * @param classLoader The new classloader. + * @return This object (for method chaining). + * @see PropertyStore#setClassLoader(ClassLoader) + */ + public SerializerGroupBuilder classLoader(ClassLoader classLoader) { + propertyStore.setClassLoader(classLoader); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java index 34477b7..2fdfd0b 100644 --- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java @@ -86,7 +86,7 @@ public class SerializerSession extends BeanSession { * </ul> * @param op The override properties. * These override any context properties defined in the context. - * @param javaMethod The java method that called this parser, usually the method in a REST servlet. + * @param javaMethod The java method that called this serializer, usually the method in a REST servlet. * @param locale The session locale. * If <jk>null</jk>, then the locale defined on the context is used. * @param timeZone The session timezone.
