You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/09/13 14:19:11 UTC
(commons-beanutils) 02/04: Format
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git
commit 2aa8770dd02aea09fbffc78681a6d6151ce8f606
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Sep 13 10:17:52 2024 -0400
Format
---
.../beanutils2/BaseDynaBeanMapDecorator.java | 3 +-
.../apache/commons/beanutils2/BasicDynaBean.java | 129 +--
.../apache/commons/beanutils2/BasicDynaClass.java | 106 +-
.../beanutils2/BeanAccessLanguageException.java | 5 +-
.../apache/commons/beanutils2/BeanComparator.java | 66 +-
.../commons/beanutils2/BeanIntrospectionData.java | 47 +-
.../commons/beanutils2/BeanIntrospector.java | 25 +-
.../org/apache/commons/beanutils2/BeanMap.java | 110 +-
.../apache/commons/beanutils2/BeanPredicate.java | 33 +-
.../BeanPropertyValueChangeConsumer.java | 87 +-
.../BeanPropertyValueEqualsPredicate.java | 104 +-
.../beanutils2/BeanToPropertyValueTransformer.java | 83 +-
.../org/apache/commons/beanutils2/BeanUtils.java | 343 +++---
.../apache/commons/beanutils2/BeanUtilsBean.java | 659 +++++------
.../commons/beanutils2/ConstructorUtils.java | 264 ++---
.../beanutils2/ContextClassLoaderLocal.java | 130 +--
.../commons/beanutils2/ConversionException.java | 5 +-
.../apache/commons/beanutils2/ConvertUtils.java | 103 +-
.../commons/beanutils2/ConvertUtilsBean.java | 319 +++---
.../org/apache/commons/beanutils2/Converter.java | 31 +-
.../commons/beanutils2/ConvertingWrapDynaBean.java | 28 +-
.../beanutils2/DefaultBeanIntrospector.java | 72 +-
.../beanutils2/DefaultIntrospectionContext.java | 14 +-
.../org/apache/commons/beanutils2/DynaBean.java | 101 +-
.../beanutils2/DynaBeanPropertyMapDecorator.java | 70 +-
.../org/apache/commons/beanutils2/DynaClass.java | 46 +-
.../apache/commons/beanutils2/DynaProperty.java | 92 +-
.../beanutils2/FluentPropertyBeanIntrospector.java | 76 +-
.../commons/beanutils2/IntrospectionContext.java | 35 +-
.../apache/commons/beanutils2/LazyDynaBean.java | 312 +++---
.../apache/commons/beanutils2/LazyDynaClass.java | 203 ++--
.../apache/commons/beanutils2/LazyDynaList.java | 239 ++--
.../org/apache/commons/beanutils2/LazyDynaMap.java | 235 ++--
.../beanutils2/MappedPropertyDescriptor.java | 202 ++--
.../org/apache/commons/beanutils2/MethodUtils.java | 846 ++++++--------
.../commons/beanutils2/MutableDynaClass.java | 65 +-
.../commons/beanutils2/NestedNullException.java | 3 +-
.../apache/commons/beanutils2/PropertyUtils.java | 690 ++++++------
.../commons/beanutils2/PropertyUtilsBean.java | 1163 ++++++++------------
.../SuppressPropertiesBeanIntrospector.java | 36 +-
.../apache/commons/beanutils2/WeakFastHashMap.java | 122 +-
.../apache/commons/beanutils2/WrapDynaBean.java | 190 ++--
.../apache/commons/beanutils2/WrapDynaClass.java | 127 +--
.../beanutils2/converters/AbstractConverter.java | 168 +--
.../beanutils2/converters/ArrayConverter.java | 228 ++--
.../beanutils2/converters/BigDecimalConverter.java | 29 +-
.../beanutils2/converters/BigIntegerConverter.java | 29 +-
.../beanutils2/converters/BooleanConverter.java | 122 +-
.../beanutils2/converters/ByteConverter.java | 29 +-
.../beanutils2/converters/CalendarConverter.java | 22 +-
.../beanutils2/converters/CharacterConverter.java | 35 +-
.../beanutils2/converters/ClassConverter.java | 37 +-
.../beanutils2/converters/ColorConverter.java | 172 ++-
.../beanutils2/converters/ConverterFacade.java | 26 +-
.../beanutils2/converters/DateConverter.java | 22 +-
.../beanutils2/converters/DateTimeConverter.java | 245 ++---
.../beanutils2/converters/DimensionConverter.java | 24 +-
.../beanutils2/converters/DoubleConverter.java | 29 +-
.../beanutils2/converters/DurationConverter.java | 24 +-
.../beanutils2/converters/EnumConverter.java | 30 +-
.../beanutils2/converters/FileConverter.java | 24 +-
.../beanutils2/converters/FloatConverter.java | 29 +-
.../converters/InetAddressConverter.java | 15 +-
.../beanutils2/converters/IntegerConverter.java | 29 +-
.../beanutils2/converters/LocalDateConverter.java | 22 +-
.../converters/LocalDateTimeConverter.java | 22 +-
.../beanutils2/converters/LocalTimeConverter.java | 24 +-
.../beanutils2/converters/LocaleConverter.java | 8 +-
.../beanutils2/converters/LongConverter.java | 29 +-
.../beanutils2/converters/MonthDayConverter.java | 24 +-
.../beanutils2/converters/NumberConverter.java | 188 ++--
.../converters/OffsetDateTimeConverter.java | 22 +-
.../beanutils2/converters/OffsetTimeConverter.java | 24 +-
.../beanutils2/converters/PathConverter.java | 24 +-
.../beanutils2/converters/PatternConverter.java | 10 +-
.../beanutils2/converters/PeriodConverter.java | 24 +-
.../beanutils2/converters/PointConverter.java | 16 +-
.../beanutils2/converters/ShortConverter.java | 29 +-
.../beanutils2/converters/StringConverter.java | 41 +-
.../beanutils2/converters/URIConverter.java | 24 +-
.../beanutils2/converters/URLConverter.java | 24 +-
.../beanutils2/converters/UUIDConverter.java | 24 +-
.../beanutils2/converters/YearConverter.java | 24 +-
.../beanutils2/converters/YearMonthConverter.java | 24 +-
.../beanutils2/converters/ZoneIdConverter.java | 24 +-
.../beanutils2/converters/ZoneOffsetConverter.java | 24 +-
.../converters/ZonedDateTimeConverter.java | 22 +-
.../beanutils2/converters/package-info.java | 6 +-
.../beanutils2/expression/DefaultResolver.java | 77 +-
.../commons/beanutils2/expression/Resolver.java | 118 +-
.../beanutils2/expression/package-info.java | 3 +-
.../commons/beanutils2/locale/LocaleBeanUtils.java | 539 +++++----
.../beanutils2/locale/LocaleBeanUtilsBean.java | 635 ++++-------
.../beanutils2/locale/LocaleConvertUtils.java | 267 +++--
.../beanutils2/locale/LocaleConvertUtilsBean.java | 191 ++--
.../locale/converters/ByteLocaleConverter.java | 2 +-
.../locale/converters/DateLocaleConverter.java | 12 +-
.../locale/converters/DecimalLocaleConverter.java | 14 +-
.../locale/converters/DoubleLocaleConverter.java | 2 +-
.../locale/converters/LongLocaleConverter.java | 2 +-
.../locale/converters/ShortLocaleConverter.java | 2 +-
.../locale/converters/StringLocaleConverter.java | 2 +-
.../beanutils2/locale/converters/package-info.java | 7 +-
.../commons/beanutils2/locale/package-info.java | 3 +-
.../apache/commons/beanutils2/package-info.java | 186 ++--
.../commons/beanutils2/sql/ResultSetDynaClass.java | 4 +-
.../commons/beanutils2/sql/ResultSetIterator.java | 4 +-
.../commons/beanutils2/sql/RowSetDynaClass.java | 6 +-
.../converters/locale/SqlDateLocaleConverter.java | 2 +-
.../converters/locale/SqlTimeLocaleConverter.java | 2 +-
.../locale/SqlTimestampLocaleConverter.java | 2 +-
.../org/apache/commons/beanutils2/BeanMapTest.java | 90 +-
.../BeanPropertyValueEqualsPredicateTest.java | 2 +-
.../commons/beanutils2/BeanUtilsBeanTest.java | 2 +-
.../commons/beanutils2/DynaPropertyTest.java | 3 +-
.../commons/beanutils2/LazyDynaBeanTest.java | 2 +-
.../commons/beanutils2/LazyDynaClassTest.java | 2 +-
.../apache/commons/beanutils2/LazyDynaMapTest.java | 2 +-
.../commons/beanutils2/MappedPropertyTest.java | 2 +-
.../commons/beanutils2/PassTestException.java | 2 +-
.../commons/beanutils2/bugs/Jira347Test.java | 6 +-
.../commons/beanutils2/bugs/Jira411Test.java | 1 +
.../commons/beanutils2/bugs/Jira493Test.java | 2 +-
.../commons/beanutils2/bugs/Jira509Test.java | 2 +-
.../commons/beanutils2/bugs/Jira541Test.java | 1 +
.../converters/AbstractNumberConverterTest.java | 110 +-
.../beanutils2/converters/ByteConverterTest.java | 8 +-
.../converters/CalendarConverterTest.java | 2 +-
.../beanutils2/converters/ColorConverterTest.java | 4 +-
.../beanutils2/converters/DateConverterTest.java | 2 +-
.../converters/DateLocaleConverterTest.java | 3 +-
.../beanutils2/converters/EnumConverterTest.java | 3 +-
.../beanutils2/converters/FloatConverterTest.java | 4 +-
.../converters/FloatLocaleConverterTest.java | 14 +-
.../converters/IntegerConverterTest.java | 8 +-
.../converters/LocalDateConverterTest.java | 2 +-
.../converters/LocalDateTimeConverterTest.java | 2 +-
.../converters/OffsetDateTimeConverterTest.java | 2 +-
.../beanutils2/converters/ShortConverterTest.java | 8 +-
.../beanutils2/converters/URLConverterTest.java | 2 +-
.../converters/ZonedDateTimeConverterTest.java | 2 +-
.../sql/converters/SqlTimeConverterTest.java | 2 +-
142 files changed, 5104 insertions(+), 6965 deletions(-)
diff --git a/src/main/java/org/apache/commons/beanutils2/BaseDynaBeanMapDecorator.java b/src/main/java/org/apache/commons/beanutils2/BaseDynaBeanMapDecorator.java
index c9915fb6..53508635 100644
--- a/src/main/java/org/apache/commons/beanutils2/BaseDynaBeanMapDecorator.java
+++ b/src/main/java/org/apache/commons/beanutils2/BaseDynaBeanMapDecorator.java
@@ -70,7 +70,7 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
if (!(obj instanceof Map.Entry)) {
return false;
}
- final Map.Entry<? ,?> other = (Map.Entry<? ,?>) obj;
+ final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
return Objects.equals(key, other.getKey()) && Objects.equals(value, other.getValue());
}
@@ -94,6 +94,7 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
throw new UnsupportedOperationException();
}
}
+
private final DynaBean dynaBean;
private final boolean readOnly;
diff --git a/src/main/java/org/apache/commons/beanutils2/BasicDynaBean.java b/src/main/java/org/apache/commons/beanutils2/BasicDynaBean.java
index 2bc9b6ae..154a1558 100644
--- a/src/main/java/org/apache/commons/beanutils2/BasicDynaBean.java
+++ b/src/main/java/org/apache/commons/beanutils2/BasicDynaBean.java
@@ -24,15 +24,18 @@ import java.util.Map;
import java.util.Objects;
/**
- * <p>Minimal implementation of the {@code DynaBean} interface. Can be
- * used as a convenience base class for more sophisticated implementations.</p>
+ * <p>
+ * Minimal implementation of the {@code DynaBean} interface. Can be used as a convenience base class for more sophisticated implementations.
+ * </p>
*
- * <p><strong>IMPLEMENTATION NOTE</strong> - Instances of this class that are
- * accessed from multiple threads simultaneously need to be synchronized.</p>
+ * <p>
+ * <strong>IMPLEMENTATION NOTE</strong> - Instances of this class that are accessed from multiple threads simultaneously need to be synchronized.
+ * </p>
*
- * <p><strong>IMPLEMENTATION NOTE</strong> - Instances of this class can be
- * successfully serialized and deserialized <strong>ONLY</strong> if all
- * property values are {@code Serializable}.</p>
+ * <p>
+ * <strong>IMPLEMENTATION NOTE</strong> - Instances of this class can be successfully serialized and deserialized <strong>ONLY</strong> if all property values
+ * are {@code Serializable}.
+ * </p>
*/
public class BasicDynaBean implements DynaBean {
@@ -53,8 +56,7 @@ public class BasicDynaBean implements DynaBean {
private static final long serialVersionUID = 1L;
/**
- * The {@code DynaClass} "base class" that this DynaBean
- * is associated with.
+ * The {@code DynaClass} "base class" that this DynaBean is associated with.
*/
protected DynaClass dynaClass;
@@ -67,8 +69,7 @@ public class BasicDynaBean implements DynaBean {
private transient Map<String, Object> mapDecorator;
/**
- * Constructs a new {@code DynaBean} associated with the specified
- * {@code DynaClass} instance.
+ * Constructs a new {@code DynaBean} associated with the specified {@code DynaClass} instance.
*
* @param dynaClass The DynaClass we are associated with
*/
@@ -77,16 +78,13 @@ public class BasicDynaBean implements DynaBean {
}
/**
- * Does the specified mapped property contain a value for the specified
- * key value?
+ * Does the specified mapped property contain a value for the specified key value?
*
* @param name Name of the property to check
- * @param key Name of the key to check
- * @return {@code true} if the mapped property contains a value for
- * the specified key, otherwise {@code false}
+ * @param key Name of the key to check
+ * @return {@code true} if the mapped property contains a value for the specified key, otherwise {@code false}
*
- * @throws IllegalArgumentException if there is no property
- * of the specified name
+ * @throws IllegalArgumentException if there is no property of the specified name
*/
@Override
public boolean contains(final String name, final String key) {
@@ -104,8 +102,7 @@ public class BasicDynaBean implements DynaBean {
* @param name Name of the property whose value is to be retrieved
* @return The property's value
*
- * @throws IllegalArgumentException if there is no property
- * of the specified name
+ * @throws IllegalArgumentException if there is no property of the specified name
*/
@Override
public Object get(final String name) {
@@ -150,18 +147,14 @@ public class BasicDynaBean implements DynaBean {
/**
* Gets the value of an indexed property with the specified name.
*
- * @param name Name of the property whose value is to be retrieved
+ * @param name Name of the property whose value is to be retrieved
* @param index Index of the value to be retrieved
* @return The indexed property's value
*
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws IllegalArgumentException if the specified property
- * exists, but is not indexed
- * @throws IndexOutOfBoundsException if the specified index
- * is outside the range of the underlying property
- * @throws NullPointerException if no array or List has been
- * initialized for this property
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws IllegalArgumentException if the specified property exists, but is not indexed
+ * @throws IndexOutOfBoundsException if the specified index is outside the range of the underlying property
+ * @throws NullPointerException if no array or List has been initialized for this property
*/
@Override
public Object get(final String name, final int index) {
@@ -177,17 +170,14 @@ public class BasicDynaBean implements DynaBean {
}
/**
- * Gets the value of a mapped property with the specified name,
- * or {@code null} if there is no value for the specified key.
+ * Gets the value of a mapped property with the specified name, or {@code null} if there is no value for the specified key.
*
* @param name Name of the property whose value is to be retrieved
- * @param key Key of the value to be retrieved
+ * @param key Key of the value to be retrieved
* @return The mapped property's value
*
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws IllegalArgumentException if the specified property
- * exists, but is not mapped
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws IllegalArgumentException if the specified property exists, but is not mapped
*/
@Override
public Object get(final String name, final String key) {
@@ -201,8 +191,7 @@ public class BasicDynaBean implements DynaBean {
}
/**
- * Gets the {@code DynaClass} instance that describes the set of
- * properties available for this DynaBean.
+ * Gets the {@code DynaClass} instance that describes the set of properties available for this DynaBean.
*
* @return The associated DynaClass
*/
@@ -217,8 +206,7 @@ public class BasicDynaBean implements DynaBean {
* @param name Name of the property for which to retrieve the descriptor
* @return The property descriptor
*
- * @throws IllegalArgumentException if this is not a valid property
- * name for our DynaClass
+ * @throws IllegalArgumentException if this is not a valid property name for our DynaClass
*/
protected DynaProperty getDynaProperty(final String name) {
final DynaProperty descriptor = getDynaClass().getDynaProperty(name);
@@ -233,9 +221,10 @@ public class BasicDynaBean implements DynaBean {
* <p>
* Gets a Map representation of this DynaBean.
* <p>
- * This, for example, could be used in JSTL in the following way to access
- * a DynaBean's {@code fooProperty}:
- * <ul><li>{@code ${myDynaBean.<b>map</b>.fooProperty}}</li></ul>
+ * This, for example, could be used in JSTL in the following way to access a DynaBean's {@code fooProperty}:
+ * <ul>
+ * <li>{@code ${myDynaBean.<b>map</b>.fooProperty}}</li>
+ * </ul>
*
* @return a Map representation of this DynaBean
* @since 1.8.0
@@ -252,10 +241,9 @@ public class BasicDynaBean implements DynaBean {
/**
* Is an object of the source class assignable to the destination class?
*
- * @param dest Destination class
+ * @param dest Destination class
* @param source Source class
- * @return {@code true} if the source class is assignable to the
- * destination class, otherwise {@code false}
+ * @return {@code true} if the source class is assignable to the destination class, otherwise {@code false}
*/
protected boolean isAssignable(final Class<?> dest, final Class<?> source) {
// @formatter:off
@@ -272,15 +260,12 @@ public class BasicDynaBean implements DynaBean {
}
/**
- * Remove any existing value for the specified key on the
- * specified mapped property.
+ * Remove any existing value for the specified key on the specified mapped property.
*
- * @param name Name of the property for which a value is to
- * be removed
- * @param key Key of the value to be removed
+ * @param name Name of the property for which a value is to be removed
+ * @param key Key of the value to be removed
*
- * @throws IllegalArgumentException if there is no property
- * of the specified name
+ * @throws IllegalArgumentException if there is no property of the specified name
*/
@Override
public void remove(final String name, final String key) {
@@ -299,18 +284,14 @@ public class BasicDynaBean implements DynaBean {
/**
* Sets the value of an indexed property with the specified name.
*
- * @param name Name of the property whose value is to be set
+ * @param name Name of the property whose value is to be set
* @param index Index of the property to be set
* @param value Value to which this property is to be set
*
- * @throws ConversionException if the specified value cannot be
- * converted to the type required for this property
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws IllegalArgumentException if the specified property
- * exists, but is not indexed
- * @throws IndexOutOfBoundsException if the specified index
- * is outside the range of the underlying property
+ * @throws ConversionException if the specified value cannot be converted to the type required for this property
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws IllegalArgumentException if the specified property exists, but is not indexed
+ * @throws IndexOutOfBoundsException if the specified index is outside the range of the underlying property
*/
@Override
public void set(final String name, final int index, final Object value) {
@@ -336,15 +317,12 @@ public class BasicDynaBean implements DynaBean {
/**
* Sets the value of a simple property with the specified name.
*
- * @param name Name of the property whose value is to be set
+ * @param name Name of the property whose value is to be set
* @param value Value to which this property is to be set
*
- * @throws ConversionException if the specified value cannot be
- * converted to the type required for this property
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws NullPointerException if an attempt is made to set a
- * primitive property to null
+ * @throws ConversionException if the specified value cannot be converted to the type required for this property
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws NullPointerException if an attempt is made to set a primitive property to null
*/
@Override
public void set(final String name, final Object value) {
@@ -363,16 +341,13 @@ public class BasicDynaBean implements DynaBean {
/**
* Sets the value of a mapped property with the specified name.
*
- * @param name Name of the property whose value is to be set
- * @param key Key of the property to be set
+ * @param name Name of the property whose value is to be set
+ * @param key Key of the property to be set
* @param value Value to which this property is to be set
*
- * @throws ConversionException if the specified value cannot be
- * converted to the type required for this property
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws IllegalArgumentException if the specified property
- * exists, but is not mapped
+ * @throws ConversionException if the specified value cannot be converted to the type required for this property
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws IllegalArgumentException if the specified property exists, but is not mapped
*/
@SuppressWarnings("unchecked")
@Override
diff --git a/src/main/java/org/apache/commons/beanutils2/BasicDynaClass.java b/src/main/java/org/apache/commons/beanutils2/BasicDynaClass.java
index 39525485..28279ce5 100644
--- a/src/main/java/org/apache/commons/beanutils2/BasicDynaClass.java
+++ b/src/main/java/org/apache/commons/beanutils2/BasicDynaClass.java
@@ -23,38 +23,35 @@ import java.util.HashMap;
import java.util.Objects;
/**
- * <p>Minimal implementation of the {@code DynaClass} interface. Can be
- * used as a convenience base class for more sophisticated implementations.</p>
- * <p><strong>IMPLEMENTATION NOTE</strong> - The {@code DynaBean}
- * implementation class supplied to our constructor MUST have a one-argument
- * constructor of its own that accepts a {@code DynaClass}. This is
- * used to associate the DynaBean instance with this DynaClass.</p>
+ * <p>
+ * Minimal implementation of the {@code DynaClass} interface. Can be used as a convenience base class for more sophisticated implementations.
+ * </p>
+ * <p>
+ * <strong>IMPLEMENTATION NOTE</strong> - The {@code DynaBean} implementation class supplied to our constructor MUST have a one-argument constructor of its own
+ * that accepts a {@code DynaClass}. This is used to associate the DynaBean instance with this DynaClass.
+ * </p>
*/
public class BasicDynaClass implements DynaClass {
private static final long serialVersionUID = 1L;
/**
- * The method signature of the constructor we will use to create
- * new DynaBean instances.
+ * The method signature of the constructor we will use to create new DynaBean instances.
*/
private static final Class<?>[] CONSTRUCTOR_TYPES = { DynaClass.class };
/**
- * The constructor of the {@code dynaBeanClass} that we will use
- * for creating new instances.
+ * The constructor of the {@code dynaBeanClass} that we will use for creating new instances.
*/
protected transient Constructor<?> constructor;
/**
- * The argument values to be passed to the constructor we will use
- * to create new DynaBean instances.
+ * The argument values to be passed to the constructor we will use to create new DynaBean instances.
*/
protected Object[] constructorValues = { this };
/**
- * The {@code DynaBean} implementation class we will use for
- * creating new instances.
+ * The {@code DynaBean} implementation class we will use for creating new instances.
*/
protected Class<?> dynaBeanClass = BasicDynaBean.class;
@@ -69,9 +66,8 @@ public class BasicDynaClass implements DynaClass {
protected DynaProperty[] properties = DynaProperty.EMPTY_ARRAY;
/**
- * The set of dynamic properties that are part of this DynaClass,
- * keyed by the property name. Individual descriptor instances will
- * be the same instances as those in the {@code properties} list.
+ * The set of dynamic properties that are part of this DynaClass, keyed by the property name. Individual descriptor instances will be the same instances as
+ * those in the {@code properties} list.
*/
protected HashMap<String, DynaProperty> propertiesMap = new HashMap<>();
@@ -85,7 +81,7 @@ public class BasicDynaClass implements DynaClass {
/**
* Constructs a new BasicDynaClass with the specified parameters.
*
- * @param name Name of this DynaBean class
+ * @param name Name of this DynaBean class
* @param dynaBeanClass The implementation class for new instances
*/
public BasicDynaClass(final String name, final Class<?> dynaBeanClass) {
@@ -95,12 +91,11 @@ public class BasicDynaClass implements DynaClass {
/**
* Constructs a new BasicDynaClass with the specified parameters.
*
- * @param name Name of this DynaBean class
+ * @param name Name of this DynaBean class
* @param dynaBeanClass The implementation class for new instances
- * @param properties Property descriptors for the supported properties
+ * @param properties Property descriptors for the supported properties
*/
- public BasicDynaClass(final String name, Class<?> dynaBeanClass,
- final DynaProperty[] properties) {
+ public BasicDynaClass(final String name, Class<?> dynaBeanClass, final DynaProperty[] properties) {
if (name != null) {
this.name = name;
}
@@ -114,9 +109,8 @@ public class BasicDynaClass implements DynaClass {
}
/**
- * Gets the Class object we will use to create new instances in the
- * {@code newInstance()} method. This Class <strong>MUST</strong>
- * implement the {@code DynaBean} interface.
+ * Gets the Class object we will use to create new instances in the {@code newInstance()} method. This Class <strong>MUST</strong> implement the
+ * {@code DynaBean} interface.
*
* @return The class of the {@link DynaBean}
*/
@@ -125,13 +119,14 @@ public class BasicDynaClass implements DynaClass {
}
/**
- * <p>Return an array of {@code PropertyDescriptor} for the properties
- * currently defined in this DynaClass. If no properties are defined, a
- * zero-length array will be returned.</p>
+ * <p>
+ * Return an array of {@code PropertyDescriptor} for the properties currently defined in this DynaClass. If no properties are defined, a zero-length array
+ * will be returned.
+ * </p>
*
- * <p><strong>FIXME</strong> - Should we really be implementing
- * {@code getBeanInfo()} instead, which returns property descriptors
- * and a bunch of other stuff?</p>
+ * <p>
+ * <strong>FIXME</strong> - Should we really be implementing {@code getBeanInfo()} instead, which returns property descriptors and a bunch of other stuff?
+ * </p>
*
* @return the set of properties for this DynaClass
*/
@@ -141,11 +136,9 @@ public class BasicDynaClass implements DynaClass {
}
/**
- * Gets a property descriptor for the specified property, if it exists;
- * otherwise, return {@code null}.
+ * Gets a property descriptor for the specified property, if it exists; otherwise, return {@code null}.
*
- * @param name Name of the dynamic property for which a descriptor
- * is requested
+ * @param name Name of the dynamic property for which a descriptor is requested
* @return The descriptor for the specified property
*
* @throws IllegalArgumentException if no property name is specified
@@ -156,10 +149,8 @@ public class BasicDynaClass implements DynaClass {
}
/**
- * Gets the name of this DynaClass (analogous to the
- * {@code getName()} method of {@link Class}, which
- * allows the same {@code DynaClass} implementation class to support
- * different dynamic classes, with different sets of properties.
+ * Gets the name of this DynaClass (analogous to the {@code getName()} method of {@link Class}, which allows the same {@code DynaClass} implementation class
+ * to support different dynamic classes, with different sets of properties.
*
* @return the name of the DynaClass
*/
@@ -169,19 +160,15 @@ public class BasicDynaClass implements DynaClass {
}
/**
- * Instantiate and return a new DynaBean instance, associated
- * with this DynaClass.
+ * Instantiate and return a new DynaBean instance, associated with this DynaClass.
*
* @return A new {@code DynaBean} instance
- * @throws IllegalAccessException if the Class or the appropriate
- * constructor is not accessible
- * @throws InstantiationException if this Class represents an abstract
- * class, an array class, a primitive type, or void; or if instantiation
- * fails for some other reason
+ * @throws IllegalAccessException if the Class or the appropriate constructor is not accessible
+ * @throws InstantiationException if this Class represents an abstract class, an array class, a primitive type, or void; or if instantiation fails for some
+ * other reason
*/
@Override
- public DynaBean newInstance()
- throws IllegalAccessException, InstantiationException {
+ public DynaBean newInstance() throws IllegalAccessException, InstantiationException {
try {
// Refind the constructor after a deserialization (if needed)
if (constructor == null) {
@@ -190,41 +177,32 @@ public class BasicDynaClass implements DynaClass {
// Invoke the constructor to create a new bean instance
return (DynaBean) constructor.newInstance(constructorValues);
} catch (final InvocationTargetException e) {
- throw new InstantiationException
- (e.getTargetException().getMessage());
+ throw new InstantiationException(e.getTargetException().getMessage());
}
}
/**
- * Sets the Class object we will use to create new instances in the
- * {@code newInstance()} method. This Class <strong>MUST</strong>
- * implement the {@code DynaBean} interface.
+ * Sets the Class object we will use to create new instances in the {@code newInstance()} method. This Class <strong>MUST</strong> implement the
+ * {@code DynaBean} interface.
*
* @param dynaBeanClass The new Class object
*
- * @throws IllegalArgumentException if the specified Class does not
- * implement the {@code DynaBean} interface
+ * @throws IllegalArgumentException if the specified Class does not implement the {@code DynaBean} interface
*/
protected void setDynaBeanClass(final Class<?> dynaBeanClass) {
// Validate the argument type specified
if (dynaBeanClass.isInterface()) {
- throw new IllegalArgumentException
- ("Class " + dynaBeanClass.getName() +
- " is an interface, not a class");
+ throw new IllegalArgumentException("Class " + dynaBeanClass.getName() + " is an interface, not a class");
}
if (!DynaBean.class.isAssignableFrom(dynaBeanClass)) {
- throw new IllegalArgumentException
- ("Class " + dynaBeanClass.getName() +
- " does not implement DynaBean");
+ throw new IllegalArgumentException("Class " + dynaBeanClass.getName() + " does not implement DynaBean");
}
// Identify the Constructor we will use in newInstance()
try {
this.constructor = dynaBeanClass.getConstructor(CONSTRUCTOR_TYPES);
} catch (final NoSuchMethodException e) {
- throw new IllegalArgumentException
- ("Class " + dynaBeanClass.getName() +
- " does not have an appropriate constructor");
+ throw new IllegalArgumentException("Class " + dynaBeanClass.getName() + " does not have an appropriate constructor");
}
this.dynaBeanClass = dynaBeanClass;
}
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanAccessLanguageException.java b/src/main/java/org/apache/commons/beanutils2/BeanAccessLanguageException.java
index 8ae9d990..0e3efa1f 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanAccessLanguageException.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanAccessLanguageException.java
@@ -18,9 +18,8 @@
package org.apache.commons.beanutils2;
/**
- * Thrown to indicate that the <em>Bean Access Language</em> cannot execute query
- * against given bean. This is a runtime exception and access languages are encouraged
- * to subclass to create custom exceptions whenever appropriate.
+ * Thrown to indicate that the <em>Bean Access Language</em> cannot execute query against given bean. This is a runtime exception and access languages are
+ * encouraged to subclass to create custom exceptions whenever appropriate.
*
* @since 1.7
*/
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanComparator.java b/src/main/java/org/apache/commons/beanutils2/BeanComparator.java
index aaf42174..44619c48 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanComparator.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanComparator.java
@@ -22,19 +22,16 @@ import java.util.Comparator;
/**
* <p>
- * This comparator compares two beans by the specified bean property. It is also possible to compare beans based on
- * nested, indexed, combined, mapped bean properties. Please see the {@link PropertyUtilsBean} documentation for all
- * property name possibilities.
+ * This comparator compares two beans by the specified bean property. It is also possible to compare beans based on nested, indexed, combined, mapped bean
+ * properties. Please see the {@link PropertyUtilsBean} documentation for all property name possibilities.
*
* </p>
* <p>
- * <strong>Note:</strong> The BeanComparator passes the values of the specified bean property to an internal natural
- * order {@link Comparator}, if no comparator is specified in the constructor. If you are comparing two beans based on a
- * property that could contain "null" values, a suitable {@code Comparator} or Apache Commons Collection
- * {@code ComparatorChain} should be supplied in the constructor. Note that the passed in {@code Comparator} must
- * be able to handle the passed in objects. Because the type of the property to be compared is not known at compile time
- * no type checks can be performed by the compiler. Thus {@code ClassCastException} exceptions can be thrown if
- * unexpected property values occur.
+ * <strong>Note:</strong> The BeanComparator passes the values of the specified bean property to an internal natural order {@link Comparator}, if no comparator
+ * is specified in the constructor. If you are comparing two beans based on a property that could contain "null" values, a suitable {@code Comparator} or Apache
+ * Commons Collection {@code ComparatorChain} should be supplied in the constructor. Note that the passed in {@code Comparator} must be able to handle the
+ * passed in objects. Because the type of the property to be compared is not known at compile time no type checks can be performed by the compiler. Thus
+ * {@code ClassCastException} exceptions can be thrown if unexpected property values occur.
* </p>
*
* @param <T> the type of beans to be compared by this {@code Comparator}
@@ -45,15 +42,14 @@ public class BeanComparator<T, V> implements Comparator<T> {
/**
* A {@link Comparator Comparator} that compares {@link Comparable Comparable} objects.
* <p>
- * This Comparator is useful, for example, for enforcing the natural order in custom implementations of
- * {@link java.util.SortedSet SortedSet} and {@link java.util.SortedMap SortedMap}.
+ * This Comparator is useful, for example, for enforcing the natural order in custom implementations of {@link java.util.SortedSet SortedSet} and
+ * {@link java.util.SortedMap SortedMap}.
* </p>
*
* @param <E> the type of objects compared by this comparator
* @see java.util.Collections#reverseOrder()
*/
- private static final class NaturalOrderComparator<E extends Comparable<? super E>>
- implements Comparator<E> {
+ private static final class NaturalOrderComparator<E extends Comparable<? super E>> implements Comparator<E> {
/** The singleton instance. */
@SuppressWarnings("rawtypes")
@@ -87,6 +83,7 @@ public class BeanComparator<T, V> implements Comparator<T> {
return "NaturalOrderComparator".hashCode();
}
}
+
private static final long serialVersionUID = 1L;
/** Property. */
@@ -112,33 +109,29 @@ public class BeanComparator<T, V> implements Comparator<T> {
/**
* <p>
- * Constructs a property-based comparator for beans. This compares two beans by the property specified in the
- * property parameter. This constructor creates a {@code BeanComparator} that uses a
- * {@code ComparableComparator} to compare the property values.
+ * Constructs a property-based comparator for beans. This compares two beans by the property specified in the property parameter. This constructor creates a
+ * {@code BeanComparator} that uses a {@code ComparableComparator} to compare the property values.
* </p>
*
* <p>
- * Passing "null" to this constructor will cause the BeanComparator to compare objects based on natural order, that
- * is {@link Comparable}.
+ * Passing "null" to this constructor will cause the BeanComparator to compare objects based on natural order, that is {@link Comparable}.
* </p>
*
- * @param property String Name of a bean property, which may contain the name of a simple, nested, indexed, mapped,
- * or combined property. See {@link PropertyUtilsBean} for property query language syntax. If the property
- * passed in is null then the actual objects will be compared
+ * @param property String Name of a bean property, which may contain the name of a simple, nested, indexed, mapped, or combined property. See
+ * {@link PropertyUtilsBean} for property query language syntax. If the property passed in is null then the actual objects will be compared
*/
public BeanComparator(final String property) {
this(property, NaturalOrderComparator.INSTANCE);
}
/**
- * Constructs a property-based comparator for beans. This constructor creates a BeanComparator that uses the
- * supplied Comparator to compare the property values.
+ * Constructs a property-based comparator for beans. This constructor creates a BeanComparator that uses the supplied Comparator to compare the property
+ * values.
*
- * @param property Name of a bean property, can contain the name of a simple, nested, indexed, mapped, or combined
- * property. See {@link PropertyUtilsBean} for property query language syntax.
- * @param comparator BeanComparator will pass the values of the specified bean property to this Comparator. If your
- * bean property is not a comparable or contains null values, a suitable comparator may be supplied in this
- * constructor.
+ * @param property Name of a bean property, can contain the name of a simple, nested, indexed, mapped, or combined property. See {@link PropertyUtilsBean}
+ * for property query language syntax.
+ * @param comparator BeanComparator will pass the values of the specified bean property to this Comparator. If your bean property is not a comparable or
+ * contains null values, a suitable comparator may be supplied in this constructor.
*/
public BeanComparator(final String property, final Comparator<V> comparator) {
setProperty(property);
@@ -146,8 +139,7 @@ public class BeanComparator<T, V> implements Comparator<T> {
}
/**
- * Compare two JavaBeans by their shared property. If {@link #getProperty} is null then the actual objects will be
- * compared.
+ * Compare two JavaBeans by their shared property. If {@link #getProperty} is null then the actual objects will be compared.
*
* @param o1 Object The first bean to get data from to compare against
* @param o2 Object The second bean to get data from to compare
@@ -166,13 +158,12 @@ public class BeanComparator<T, V> implements Comparator<T> {
final Object value2 = PropertyUtils.getProperty(o2, property);
return internalCompare(value1, value2);
} catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
- throw new RuntimeException(e.getClass().getSimpleName()+": " + e.toString());
+ throw new RuntimeException(e.getClass().getSimpleName() + ": " + e.toString());
}
}
/**
- * Two {@code BeanComparator}'s are equals if and only if the wrapped comparators and the property names to be
- * compared are equal.
+ * Two {@code BeanComparator}'s are equals if and only if the wrapped comparators and the property names to be compared are equal.
*
* @param o Comparator to compare to
* @return whether the comparators are equal or not
@@ -227,8 +218,8 @@ public class BeanComparator<T, V> implements Comparator<T> {
}
/**
- * Compares the given values using the internal {@code Comparator}. <em>Note</em>: This comparison cannot be
- * performed in a type-safe way; so {@code ClassCastException} exceptions may be thrown.
+ * Compares the given values using the internal {@code Comparator}. <em>Note</em>: This comparison cannot be performed in a type-safe way; so
+ * {@code ClassCastException} exceptions may be thrown.
*
* @param val1 the first value to be compared
* @param val2 the second value to be compared
@@ -242,8 +233,7 @@ public class BeanComparator<T, V> implements Comparator<T> {
/**
* Sets the method to be called to compare two JavaBeans
*
- * @param property String method name to call to compare If the property passed in is null then the actual objects
- * will be compared
+ * @param property String method name to call to compare If the property passed in is null then the actual objects will be compared
*/
public void setProperty(final String property) {
this.property = property;
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanIntrospectionData.java b/src/main/java/org/apache/commons/beanutils2/BeanIntrospectionData.java
index f8c17dac..6cb10eb7 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanIntrospectionData.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanIntrospectionData.java
@@ -24,29 +24,24 @@ import java.util.Map;
/**
* <p>
- * An internally used helper class for storing introspection information about a bean
- * class.
+ * An internally used helper class for storing introspection information about a bean class.
* </p>
* <p>
- * This class is used by {@link PropertyUtilsBean}. When accessing bean properties via
- * reflection information about the properties available and their types and access
- * methods must be present. {@code PropertyUtilsBean} stores this information in a cache
- * so that it can be accessed quickly. The cache stores instances of this class.
+ * This class is used by {@link PropertyUtilsBean}. When accessing bean properties via reflection information about the properties available and their types and
+ * access methods must be present. {@code PropertyUtilsBean} stores this information in a cache so that it can be accessed quickly. The cache stores instances
+ * of this class.
* </p>
* <p>
- * This class mainly stores information about the properties of a bean class. Per default,
- * this is contained in {@code PropertyDescriptor} objects. Some additional information
- * required by the {@code BeanUtils} library is also stored here.
+ * This class mainly stores information about the properties of a bean class. Per default, this is contained in {@code PropertyDescriptor} objects. Some
+ * additional information required by the {@code BeanUtils} library is also stored here.
* </p>
*
* @since 1.9.1
*/
final class BeanIntrospectionData {
/**
- * Initializes the map with the names of the write methods for the supported
- * properties. The method names - if defined - need to be stored separately because
- * they may get lost when the GC claims soft references used by the
- * {@code PropertyDescriptor} objects.
+ * Initializes the map with the names of the write methods for the supported properties. The method names - if defined - need to be stored separately
+ * because they may get lost when the GC claims soft references used by the {@code PropertyDescriptor} objects.
*
* @param descs the array with the descriptors of the available properties
* @return the map with the names of write methods for properties
@@ -69,8 +64,7 @@ final class BeanIntrospectionData {
private final Map<String, String> writeMethodNames;
/**
- * Creates a new instance of {@code BeanIntrospectionData} and initializes its
- * completely.
+ * Creates a new instance of {@code BeanIntrospectionData} and initializes its completely.
*
* @param descs the array with the descriptors of the available properties
*/
@@ -79,10 +73,10 @@ final class BeanIntrospectionData {
}
/**
- * Creates a new instance of {@code BeanIntrospectionData} and allows setting the map
- * with write method names. This constructor is mainly used for testing purposes.
+ * Creates a new instance of {@code BeanIntrospectionData} and allows setting the map with write method names. This constructor is mainly used for testing
+ * purposes.
*
- * @param descs the array with the descriptors of the available properties
+ * @param descs the array with the descriptors of the available properties
* @param writeMethNames the map with the names of write methods
*/
BeanIntrospectionData(final PropertyDescriptor[] descs, final Map<String, String> writeMethNames) {
@@ -91,8 +85,7 @@ final class BeanIntrospectionData {
}
/**
- * Returns the {@code PropertyDescriptor} for the property with the specified name. If
- * this property is unknown, result is <b>null</b>.
+ * Returns the {@code PropertyDescriptor} for the property with the specified name. If this property is unknown, result is <b>null</b>.
*
* @param name the name of the property in question
* @return the {@code PropertyDescriptor} for this property or <b>null</b>
@@ -116,16 +109,13 @@ final class BeanIntrospectionData {
}
/**
- * Returns the write method for the property determined by the given
- * {@code PropertyDescriptor}. This information is normally available in the
- * descriptor object itself. However, at least by the ORACLE implementation, the
- * method is stored as a {@code SoftReference}. If this reference has been freed by
- * the GC, it may be the case that the method cannot be obtained again. Then,
- * additional information stored in this object is necessary to obtain the method
+ * Returns the write method for the property determined by the given {@code PropertyDescriptor}. This information is normally available in the descriptor
+ * object itself. However, at least by the ORACLE implementation, the method is stored as a {@code SoftReference}. If this reference has been freed by the
+ * GC, it may be the case that the method cannot be obtained again. Then, additional information stored in this object is necessary to obtain the method
* again.
*
* @param beanCls the class of the affected bean
- * @param desc the {@code PropertyDescriptor} of the desired property
+ * @param desc the {@code PropertyDescriptor} of the desired property
* @return the write method for this property or <b>null</b> if there is none
*/
public Method getWriteMethod(final Class<?> beanCls, final PropertyDescriptor desc) {
@@ -133,8 +123,7 @@ final class BeanIntrospectionData {
if (method == null) {
final String methodName = writeMethodNames.get(desc.getName());
if (methodName != null) {
- method = MethodUtils.getAccessibleMethod(beanCls, methodName,
- desc.getPropertyType());
+ method = MethodUtils.getAccessibleMethod(beanCls, methodName, desc.getPropertyType());
if (method != null) {
try {
desc.setWriteMethod(method);
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanIntrospector.java b/src/main/java/org/apache/commons/beanutils2/BeanIntrospector.java
index 58653232..650097f2 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanIntrospector.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanIntrospector.java
@@ -20,17 +20,13 @@ import java.beans.IntrospectionException;
/**
* <p>
- * Definition of an interface for components that can perform introspection on
- * bean classes.
+ * Definition of an interface for components that can perform introspection on bean classes.
* </p>
* <p>
- * Before {@link PropertyUtils} can be used for interaction with a specific Java
- * class, the class's properties have to be determined. This is called
- * <em>introspection</em> and is initiated automatically on demand.
- * {@code PropertyUtils} does not perform introspection on its own, but
- * delegates this task to one or more objects implementing this interface. This
- * makes it possible to customize introspection which may be useful for certain
- * code bases using non-standard conventions for accessing properties.
+ * Before {@link PropertyUtils} can be used for interaction with a specific Java class, the class's properties have to be determined. This is called
+ * <em>introspection</em> and is initiated automatically on demand. {@code PropertyUtils} does not perform introspection on its own, but delegates this task to
+ * one or more objects implementing this interface. This makes it possible to customize introspection which may be useful for certain code bases using
+ * non-standard conventions for accessing properties.
* </p>
*
* @since 1.9
@@ -38,14 +34,11 @@ import java.beans.IntrospectionException;
public interface BeanIntrospector {
/**
- * Performs introspection on a Java class. The current class to be inspected
- * can be queried from the passed in {@code IntrospectionContext}
- * object. A typical implementation has to obtain this class, determine its
- * properties according to the rules it implements, and add them to the
- * passed in context object.
+ * Performs introspection on a Java class. The current class to be inspected can be queried from the passed in {@code IntrospectionContext} object. A
+ * typical implementation has to obtain this class, determine its properties according to the rules it implements, and add them to the passed in context
+ * object.
*
- * @param icontext the context object for interaction with the initiator of
- * the introspection request
+ * @param icontext the context object for interaction with the initiator of the introspection request
* @throws IntrospectionException if an error occurs during introspection
*/
void introspect(IntrospectionContext icontext) throws IntrospectionException;
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanMap.java b/src/main/java/org/apache/commons/beanutils2/BeanMap.java
index 77ac3d43..4cda7d9e 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanMap.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanMap.java
@@ -37,8 +37,7 @@ import java.util.function.Function;
/**
* An implementation of Map for JavaBeans which uses introspection to get and put properties in the bean.
* <p>
- * If an exception occurs during attempts to get or set a property then the property is considered non existent in the
- * Map
+ * If an exception occurs during attempts to get or set a property then the property is considered non existent in the Map
* </p>
*/
public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
@@ -59,7 +58,7 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
* Constructs a new {@code Entry}.
*
* @param owner the BeanMap this entry belongs to
- * @param key the key for this entry
+ * @param key the key for this entry
* @param value the value for this entry
*/
protected Entry(final BeanMap owner, final String key, final Object value) {
@@ -90,12 +89,12 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
*/
public static final Object[] NULL_ARGUMENTS = {};
/**
- * Maps primitive Class types to transformers. The transformer transform strings into the appropriate primitive
- * wrapper.
+ * Maps primitive Class types to transformers. The transformer transform strings into the appropriate primitive wrapper.
*
* N.B. private & unmodifiable replacement for the (public & static) defaultTransformers instance.
*/
private static final Map<Class<? extends Object>, Function<?, ?>> typeTransformers = Collections.unmodifiableMap(createTypeTransformers());
+
private static Map<Class<? extends Object>, Function<?, ?>> createTypeTransformers() {
final Map<Class<? extends Object>, Function<?, ?>> defTransformers = new HashMap<>();
defTransformers.put(Boolean.TYPE, input -> Boolean.valueOf(input.toString()));
@@ -128,8 +127,7 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
// Map interface
/**
- * Constructs a new {@code BeanMap} that operates on the specified bean. If the given bean is
- * {@code null}, then this map will be empty.
+ * Constructs a new {@code BeanMap} that operates on the specified bean. If the given bean is {@code null}, then this map will be empty.
*
* @param bean the bean for this map to operate on
*/
@@ -139,10 +137,9 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
}
/**
- * This method reinitializes the bean map to have default values for the bean's properties. This is accomplished by
- * constructing a new instance of the bean which the map uses as its underlying data source. This behavior for
- * {@code clear()} differs from the Map contract in that the mappings are not actually removed from the map
- * (the mappings for a BeanMap are fixed).
+ * This method reinitializes the bean map to have default values for the bean's properties. This is accomplished by constructing a new instance of the bean
+ * which the map uses as its underlying data source. This behavior for {@code clear()} differs from the Map contract in that the mappings are not actually
+ * removed from the map (the mappings for a BeanMap are fixed).
*/
@Override
public void clear() {
@@ -225,14 +222,14 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
/**
* Returns true if the bean defines a property with the given name.
* <p>
- * The given name must be a {@code String}; if not, this method returns false. This method will also return
- * false if the bean does not define a property with that name.
+ * The given name must be a {@code String}; if not, this method returns false. This method will also return false if the bean does not define a property
+ * with that name.
* <p>
* Write-only properties will not be matched as the test operates against property read methods.
*
* @param name the name of the property to check
- * @return false if the given name is null or is not a {@code String}; false if the bean does not define a
- * property with that name; or true if the bean does define a property with that name
+ * @return false if the given name is null or is not a {@code String}; false if the bean does not define a property with that name; or true if the bean does
+ * define a property with that name
*/
@Override
public boolean containsKey(final Object name) {
@@ -253,31 +250,27 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
}
/**
- * Converts the given value to the given type. First, reflection is used to find a public constructor declared by
- * the given class that takes one argument, which must be the precise type of the given value. If such a constructor
- * is found, a new object is created by passing the given value to that constructor, and the newly constructed
- * object is returned.
+ * Converts the given value to the given type. First, reflection is used to find a public constructor declared by the given class that takes one argument,
+ * which must be the precise type of the given value. If such a constructor is found, a new object is created by passing the given value to that
+ * constructor, and the newly constructed object is returned.
* <P>
*
- * If no such constructor exists, and the given type is a primitive type, then the given value is converted to a
- * string using its {@link Object#toString() toString()} method, and that string is parsed into the correct
- * primitive type using, for instance, {@link Integer#valueOf(String)} to convert the string into an
- * {@code int}.
+ * If no such constructor exists, and the given type is a primitive type, then the given value is converted to a string using its {@link Object#toString()
+ * toString()} method, and that string is parsed into the correct primitive type using, for instance, {@link Integer#valueOf(String)} to convert the string
+ * into an {@code int}.
* <P>
*
- * If no special constructor exists and the given type is not a primitive type, this method returns the original
- * value.
+ * If no special constructor exists and the given type is not a primitive type, this method returns the original value.
*
- * @param <R> The return type.
+ * @param <R> The return type.
* @param newType the type to convert the value to
- * @param value the value to convert
+ * @param value the value to convert
* @return the converted value
- * @throws NumberFormatException if newType is a primitive type, and the string representation of the given value
- * cannot be converted to that type
- * @throws InstantiationException if the constructor found with reflection raises it
+ * @throws NumberFormatException if newType is a primitive type, and the string representation of the given value cannot be converted to that type
+ * @throws InstantiationException if the constructor found with reflection raises it
* @throws InvocationTargetException if the constructor found with reflection raises it
- * @throws IllegalAccessException never
- * @throws IllegalArgumentException never
+ * @throws IllegalAccessException never
+ * @throws IllegalArgumentException never
*/
protected <R> Object convertType(final Class<R> newType, final Object value)
throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
@@ -297,18 +290,17 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
}
/**
- * Creates an array of parameters to pass to the given mutator method. If the given object is not the right type to
- * pass to the method directly, it will be converted using {@link #convertType(Class,Object)}.
+ * Creates an array of parameters to pass to the given mutator method. If the given object is not the right type to pass to the method directly, it will be
+ * converted using {@link #convertType(Class,Object)}.
*
* @param method the mutator method
- * @param value the value to pass to the mutator method
+ * @param value the value to pass to the mutator method
* @return an array containing one object that is either the given value or a transformed value
- * @throws IllegalAccessException if {@link #convertType(Class,Object)} raises it
+ * @throws IllegalAccessException if {@link #convertType(Class,Object)} raises it
* @throws IllegalArgumentException if any other exception is raised by {@link #convertType(Class,Object)}
- * @throws ClassCastException if an error occurs creating the method args
+ * @throws ClassCastException if an error occurs creating the method args
*/
- protected Object[] createWriteMethodArguments(final Method method, Object value)
- throws IllegalAccessException, ClassCastException {
+ protected Object[] createWriteMethodArguments(final Method method, Object value) throws IllegalAccessException, ClassCastException {
try {
if (value != null) {
final Class<? extends Object>[] paramTypes = method.getParameterTypes();
@@ -378,10 +370,10 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
}
/**
- * Called during a successful {@link #put(String,Object)} operation. Default implementation does nothing. Override
- * to be notified of property changes in the bean caused by this map.
+ * Called during a successful {@link #put(String,Object)} operation. Default implementation does nothing. Override to be notified of property changes in the
+ * bean caused by this map.
*
- * @param key the name of the property that changed
+ * @param key the name of the property that changed
* @param oldValue the old value for that property
* @param newValue the new value for that property
*/
@@ -392,9 +384,8 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
/**
* Returns the value of the bean's property with the given name.
* <p>
- * The given name must be a {@link String} and must not be null; otherwise, this method returns {@code null}.
- * If the bean defines a property with the given name, the value of that property is returned. Otherwise,
- * {@code null} is returned.
+ * The given name must be a {@link String} and must not be null; otherwise, this method returns {@code null}. If the bean defines a property with the given
+ * name, the value of that property is returned. Otherwise, {@code null} is returned.
* <p>
* Write-only properties will not be matched as the test operates against property read methods.
*
@@ -408,8 +399,7 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
if (method != null) {
try {
return method.invoke(bean, NULL_ARGUMENTS);
- } catch (final IllegalAccessException | NullPointerException |
- InvocationTargetException | IllegalArgumentException e) {
+ } catch (final IllegalAccessException | NullPointerException | InvocationTargetException | IllegalArgumentException e) {
logWarn(e);
}
}
@@ -432,8 +422,7 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
* Returns the accessor for the property with the given name.
*
* @param name the name of the property
- * @return null if the name is null; null if the name is not a {@link String}; null if no such property exists; or
- * the accessor method for that property
+ * @return null if the name is null; null if the name is not a {@link String}; null if no such property exists; or the accessor method for that property
*/
protected Method getReadMethod(final Object name) {
return readMethods.get(name);
@@ -462,7 +451,7 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
/**
* Returns a transformer for the given primitive type.
*
- * @param <R> The transformer result type.
+ * @param <R> The transformer result type.
* @param type the primitive type whose transformer to return
* @return a transformer that will convert strings into that type, or null if the given type is not a primitive type
*/
@@ -476,8 +465,8 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
* Returns the mutator for the property with the given name.
*
* @param name the name of the
- * @return null if the name is null; null if the name is not a {@link String}; null if no such property exists; null
- * if the property is read-only; or the mutator method for that property
+ * @return null if the name is null; null if the name is not a {@link String}; null if no such property exists; null if the property is read-only; or the
+ * mutator method for that property
*/
protected Method getWriteMethod(final Object name) {
return writeMethods.get(name);
@@ -542,8 +531,7 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
/**
* Gets the keys for this BeanMap.
* <p>
- * Write-only properties are <b>not</b> included in the returned set of property names, although it is possible to
- * set their value and to get their type.
+ * Write-only properties are <b>not</b> included in the returned set of property names, although it is possible to set their value and to get their type.
*
* @return BeanMap keys. The Set returned by this method is not modifiable.
*/
@@ -579,12 +567,12 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
/**
* Sets the bean property with the given name to the given value.
*
- * @param name the name of the property to set
+ * @param name the name of the property to set
* @param value the value to set that property to
* @return the previous value of that property
- * @throws IllegalArgumentException if the given name is null; if the given name is not a {@link String}; if the
- * bean doesn't define a property with that name; or if the bean property with that name is read-only
- * @throws ClassCastException if an error occurs creating the method args
+ * @throws IllegalArgumentException if the given name is null; if the given name is not a {@link String}; if the bean doesn't define a property with that
+ * name; or if the bean property with that name is read-only
+ * @throws ClassCastException if an error occurs creating the method args
*/
@Override
public Object put(final String name, final Object value) throws IllegalArgumentException, ClassCastException {
@@ -592,8 +580,7 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
final Object oldValue = get(name);
final Method method = getWriteMethod(name);
if (method == null) {
- throw new IllegalArgumentException(
- "The bean of type: " + bean.getClass().getName() + " has no property called: " + name);
+ throw new IllegalArgumentException("The bean of type: " + bean.getClass().getName() + " has no property called: " + name);
}
try {
final Object[] arguments = createWriteMethodArguments(method, value);
@@ -610,8 +597,7 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
}
/**
- * Puts all of the writable properties from the given BeanMap into this BeanMap. Read-only and Write-only properties
- * will be ignored.
+ * Puts all of the writable properties from the given BeanMap into this BeanMap. Read-only and Write-only properties will be ignored.
*
* @param map the BeanMap whose properties to put
*/
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanPredicate.java b/src/main/java/org/apache/commons/beanutils2/BeanPredicate.java
index 6bf1a62a..1b42d1a3 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanPredicate.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanPredicate.java
@@ -24,8 +24,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- * <p>Predicate implementation that applies the given {@code Predicate}
- * to the result of calling the given property getter.
+ * <p>
+ * Predicate implementation that applies the given {@code Predicate} to the result of calling the given property getter.
* </p>
*
* @param <T> the type of the input to the predicate
@@ -41,12 +41,10 @@ public class BeanPredicate<T> implements Predicate<T> {
private Predicate<T> predicate;
/**
- * Constructs a {@code BeanPredicate} that applies the given
- * {@code Predicate} to the named property value.
- * @param propertyName the name of the property whose value is to be predicated,
- * not null
- * @param predicate the {@code Predicate} to be applied,
- * not null
+ * Constructs a {@code BeanPredicate} that applies the given {@code Predicate} to the named property value.
+ *
+ * @param propertyName the name of the property whose value is to be predicated, not null
+ * @param predicate the {@code Predicate} to be applied, not null
*/
public BeanPredicate(final String propertyName, final Predicate<T> predicate) {
this.propertyName = propertyName;
@@ -54,8 +52,8 @@ public class BeanPredicate<T> implements Predicate<T> {
}
/**
- * Gets the {@code Predicate} to be applied to the value of the named property
- * during {@link #test(Object)}.
+ * Gets the {@code Predicate} to be applied to the value of the named property during {@link #test(Object)}.
+ *
* @return {@code Predicate}, not null
*/
public Predicate<T> getPredicate() {
@@ -63,8 +61,8 @@ public class BeanPredicate<T> implements Predicate<T> {
}
/**
- * Gets the name of the property whose value is to be predicated.
- * in the evaluation.
+ * Gets the name of the property whose value is to be predicated. in the evaluation.
+ *
* @return the property name, not null
*/
public String getPropertyName() {
@@ -72,8 +70,8 @@ public class BeanPredicate<T> implements Predicate<T> {
}
/**
- * Sets the {@code Predicate} to be applied to the value of the named property
- * during {@link #test(Object)}.
+ * Sets the {@code Predicate} to be applied to the value of the named property during {@link #test(Object)}.
+ *
* @param predicate {@code Predicate}, not null
*/
public void setPredicate(final Predicate<T> predicate) {
@@ -82,16 +80,15 @@ public class BeanPredicate<T> implements Predicate<T> {
/**
* Sets the name of the property whose value is to be predicated.
- * @param propertyName the name of the property whose value is to be predicated,
- * not null
+ *
+ * @param propertyName the name of the property whose value is to be predicated, not null
*/
public void setPropertyName(final String propertyName) {
this.propertyName = propertyName;
}
/**
- * Evaluates the given object by applying the {@link #getPredicate()}
- * to a property value named by {@link #getPropertyName()}.
+ * Evaluates the given object by applying the {@link #getPredicate()} to a property value named by {@link #getPropertyName()}.
*
* @param object The object to test
* @return the result of the predicate evaluation
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumer.java b/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumer.java
index a215f32f..5035a205 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumer.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumer.java
@@ -24,19 +24,16 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- * <p>{@code Closure} that sets a property.</p>
* <p>
- * An implementation of {@link java.util.function.Consumer} that updates
- * a specified property on the object provided with a specified value.
- * The {@code BeanPropertyValueChangeClosure} constructor takes two parameters which determine
- * what property will be updated and with what value.
+ * {@code Closure} that sets a property.
+ * </p>
+ * <p>
+ * An implementation of {@link java.util.function.Consumer} that updates a specified property on the object provided with a specified value. The
+ * {@code BeanPropertyValueChangeClosure} constructor takes two parameters which determine what property will be updated and with what value.
* <dl>
- * <dt>
- * {@code public BeanPropertyValueChangeClosure( String propertyName, Object propertyValue )}
- * </dt>
- * <dd>
- * Will create a {@code Closure} that will update an object by setting the property
- * specified by {@code propertyName</code> to the value specified by <code>propertyValue}.
+ * <dt>{@code public BeanPropertyValueChangeClosure( String propertyName, Object propertyValue )}</dt>
+ * <dd>Will create a {@code Closure} that will update an object by setting the property specified by
+ * {@code propertyName</code> to the value specified by <code>propertyValue}.
* </dd>
* </dl>
*
@@ -59,17 +56,10 @@ import org.apache.commons.logging.LogFactory;
* }</pre>
*
* This would take a {@code Collection} of person objects and update the
- * {@code activeEmployee</code> property of each object in the <code>Collection} to
- * {@code true}. Assuming...
+ * {@code activeEmployee</code> property of each object in the <code>Collection} to {@code true}. Assuming...
* <ul>
- * <li>
- * The top level object in the {@code peopleCollection} is an object which represents a
- * person.
- * </li>
- * <li>
- * The person object has a {@code setActiveEmployee( boolean )} method which updates
- * the value for the object's {@code activeEmployee} property.
- * </li>
+ * <li>The top level object in the {@code peopleCollection} is an object which represents a person.</li>
+ * <li>The person object has a {@code setActiveEmployee( boolean )} method which updates the value for the object's {@code activeEmployee} property.</li>
* </ul>
*
* @param <T> The type of the input to the operation
@@ -89,8 +79,7 @@ public class BeanPropertyValueChangeConsumer<T, V> implements Consumer<T> {
private final String propertyName;
/**
- * The value that the property specified by {@code propertyName}
- * will be updated to when this {@code Closure} executes.
+ * The value that the property specified by {@code propertyName} will be updated to when this {@code Closure} executes.
*/
private final V propertyValue;
@@ -101,19 +90,16 @@ public class BeanPropertyValueChangeConsumer<T, V> implements Consumer<T> {
* {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged but
* not re-thrown. If set to {@code false} then if any objects in the property path leading
* up to the target property evaluate to {@code null} then the
- * {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged and
- * re-thrown.
+ * {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged and re-thrown.
*/
private final boolean ignoreNull;
/**
- * Constructor which takes the name of the property to be changed, the new value to set
- * the property to, and assumes {@code ignoreNull</code> to be <code>false}.
+ * Constructor which takes the name of the property to be changed, the new value to set the property to, and assumes
+ * {@code ignoreNull</code> to be <code>false}.
*
- * @param propertyName The name of the property that will be updated with the value specified by
- * {@code propertyValue}.
- * @param propertyValue The value that {@code propertyName} will be set to on the target
- * object.
+ * @param propertyName The name of the property that will be updated with the value specified by {@code propertyValue}.
+ * @param propertyValue The value that {@code propertyName} will be set to on the target object.
* @throws IllegalArgumentException If the propertyName provided is null or empty.
*/
public BeanPropertyValueChangeConsumer(final String propertyName, final V propertyValue) {
@@ -121,16 +107,12 @@ public class BeanPropertyValueChangeConsumer<T, V> implements Consumer<T> {
}
/**
- * Constructor which takes the name of the property to be changed, the new value to set
- * the property to and a boolean which determines whether {@code null} objects in the
- * property path will generate an {@code IllegalArgumentException} or not.
+ * Constructor which takes the name of the property to be changed, the new value to set the property to and a boolean which determines whether {@code null}
+ * objects in the property path will generate an {@code IllegalArgumentException} or not.
*
- * @param propertyName The name of the property that will be updated with the value specified by
- * {@code propertyValue}.
- * @param propertyValue The value that {@code propertyName} will be set to on the target
- * object.
- * @param ignoreNull Determines whether {@code null} objects in the property path will
- * generate an {@code IllegalArgumentException} or not.
+ * @param propertyName The name of the property that will be updated with the value specified by {@code propertyValue}.
+ * @param propertyValue The value that {@code propertyName} will be set to on the target object.
+ * @param ignoreNull Determines whether {@code null} objects in the property path will generate an {@code IllegalArgumentException} or not.
* @throws IllegalArgumentException If the propertyName provided is null or empty.
*/
public BeanPropertyValueChangeConsumer(final String propertyName, final V propertyValue, final boolean ignoreNull) {
@@ -143,14 +125,13 @@ public class BeanPropertyValueChangeConsumer<T, V> implements Consumer<T> {
}
/**
- * Updates the target object provided using the property update criteria provided when this
- * {@code BeanPropertyValueChangeClosure} was constructed. If any object in the property
- * path leading up to the target property is {@code null} then the outcome will be based on
- * the value of the {@code ignoreNull</code> attribute. By default, <code>ignoreNull} is
+ * Updates the target object provided using the property update criteria provided when this {@code BeanPropertyValueChangeClosure} was constructed. If any
+ * object in the property path leading up to the target property is {@code null} then the outcome will be based on the value of the
+ * {@code ignoreNull</code> attribute. By default, <code>ignoreNull} is
* {@code false</code> and would result in an <code>IllegalArgumentException} if an object
* in the property path leading up to the target property is {@code null}.
*
- * @param object The object to be updated.
+ * @param object The object to be updated.
* @throws IllegalArgumentException If an IllegalAccessException, InvocationTargetException, or
* NoSuchMethodException is thrown when trying to access the property specified on the object
* provided. Or if an object in the property path provided is {@code null} and
@@ -190,28 +171,24 @@ public class BeanPropertyValueChangeConsumer<T, V> implements Consumer<T> {
}
/**
- * Returns the value that the property specified by {@code propertyName}
- * will be updated to when this {@code Closure} executes.
+ * Returns the value that the property specified by {@code propertyName} will be updated to when this {@code Closure} executes.
*
- * @return The value that the property specified by {@code propertyName}
- * will be updated to when this {@code Closure} executes.
+ * @return The value that the property specified by {@code propertyName} will be updated to when this {@code Closure} executes.
*/
public V getPropertyValue() {
return propertyValue;
}
/**
- * Returns the flag that determines whether {@code null} objects in the property path will
- * generate an {@code IllegalArgumentException</code> or not. If set to <code>true} then
+ * Returns the flag that determines whether {@code null} objects in the property path will generate an
+ * {@code IllegalArgumentException</code> or not. If set to <code>true} then
* if any objects in the property path leading up to the target property evaluate to
* {@code null</code> then the <code>IllegalArgumentException} throw by
* {@code PropertyUtils</code> will be logged but not re-thrown. If set to <code>false} then
* if any objects in the property path leading up to the target property evaluate to
- * {@code null</code> then the <code>IllegalArgumentException} throw by
- * {@code PropertyUtils} will be logged and re-thrown.
+ * {@code null</code> then the <code>IllegalArgumentException} throw by {@code PropertyUtils} will be logged and re-thrown.
*
- * @return The flag that determines whether {@code null} objects in the property path will
- * generate an {@code IllegalArgumentException} or not.
+ * @return The flag that determines whether {@code null} objects in the property path will generate an {@code IllegalArgumentException} or not.
*/
public boolean isIgnoreNull() {
return ignoreNull;
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicate.java b/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicate.java
index 913d2f3a..6de9e1a1 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicate.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicate.java
@@ -25,24 +25,18 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- * <p>{@code Predicate} that evaluates a property value against a specified value.</p>
* <p>
- * An implementation of {@link java.util.function.Predicate} that evaluates a
- * property value on the object provided against a specified value and returns {@code true}
- * if equal; {@code false} otherwise.
- * The {@code BeanPropertyValueEqualsPredicate} constructor takes two parameters which
- * determine what property will be evaluated on the target object and what its expected value should
- * be.
+ * {@code Predicate} that evaluates a property value against a specified value.
+ * </p>
+ * <p>
+ * An implementation of {@link java.util.function.Predicate} that evaluates a property value on the object provided against a specified value and returns
+ * {@code true} if equal; {@code false} otherwise. The {@code BeanPropertyValueEqualsPredicate} constructor takes two parameters which determine what property
+ * will be evaluated on the target object and what its expected value should be.
* </p>
* <dl>
- * <dt>
- * <strong>
- * {@code public BeanPropertyValueEqualsPredicate( String propertyName, Object propertyValue )}
- * </strong>
- * </dt>
- * <dd>
- * Will create a {@code Predicate} that will evaluate the target object and return
- * {@code true</code> if the property specified by <code>propertyName} has a value which
+ * <dt><strong> {@code public BeanPropertyValueEqualsPredicate( String propertyName, Object propertyValue )} </strong></dt>
+ * <dd>Will create a {@code Predicate} that will evaluate the target object and return
+ * {@code true</code> if the property specified by <code>propertyName} has a value which
* is equal to the value specified by {@code propertyValue}. Or return
* {@code false} otherwise.
* </dd>
@@ -94,14 +88,8 @@ import org.apache.commons.logging.LogFactory;
* {@code personId</code> property value equals <code>456-12-1234}. Assuming...
* </p>
* <ul>
- * <li>
- * The top level object in the {@code peopleCollection} is an object which represents a
- * person.
- * </li>
- * <li>
- * The person object has a {@code getPersonId()} method which returns
- * the value for the object's {@code personId} property.
- * </li>
+ * <li>The top level object in the {@code peopleCollection} is an object which represents a person.</li>
+ * <li>The person object has a {@code getPersonId()} method which returns the value for the object's {@code personId} property.</li>
* </ul>
*
* @param <T> The type of the input to the predicate.
@@ -121,13 +109,14 @@ public class BeanPropertyValueEqualsPredicate<T, V> implements Predicate<T> {
private final String propertyName;
/**
- * The value that the property specified by {@code propertyName}
- * will be compared to when this {@code Predicate} executes.
+ * The value that the property specified by {@code propertyName} will be compared to when this {@code Predicate} executes.
*/
private final V propertyValue;
/**
- * <p>Should {@code null} objects in the property path be ignored?</p>
+ * <p>
+ * Should {@code null} objects in the property path be ignored?
+ * </p>
* <p>
* Determines whether {@code null} objects in the property path will generate an
* {@code IllegalArgumentException</code> or not. If set to <code>true} then if any objects
@@ -135,17 +124,15 @@ public class BeanPropertyValueEqualsPredicate<T, V> implements Predicate<T> {
* {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged but
* not re-thrown and {@code false</code> will be returned. If set to <code>false} then if
* any objects in the property path evaluate to {@code null} then the
- * {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged and
- * re-thrown.
+ * {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged and re-thrown.
* </p>
*/
private final boolean ignoreNull;
/**
- * Constructor which takes the name of the property, its expected value to be used in evaluation,
- * and assumes {@code ignoreNull</code> to be <code>false}.
+ * Constructor which takes the name of the property, its expected value to be used in evaluation, and assumes {@code ignoreNull</code> to be <code>false}.
*
- * @param propertyName The name of the property that will be evaluated against the expected value.
+ * @param propertyName The name of the property that will be evaluated against the expected value.
* @param propertyValue The value to use in object evaluation.
* @throws IllegalArgumentException If the property name provided is null or empty.
*/
@@ -154,18 +141,15 @@ public class BeanPropertyValueEqualsPredicate<T, V> implements Predicate<T> {
}
/**
- * Constructor which takes the name of the property, its expected value
- * to be used in evaluation, and a boolean which determines whether {@code null} objects in
- * the property path will generate an {@code IllegalArgumentException} or not.
+ * Constructor which takes the name of the property, its expected value to be used in evaluation, and a boolean which determines whether {@code null}
+ * objects in the property path will generate an {@code IllegalArgumentException} or not.
*
- * @param propertyName The name of the property that will be evaluated against the expected value.
+ * @param propertyName The name of the property that will be evaluated against the expected value.
* @param propertyValue The value to use in object evaluation.
- * @param ignoreNull Determines whether {@code null} objects in the property path will
- * generate an {@code IllegalArgumentException} or not.
+ * @param ignoreNull Determines whether {@code null} objects in the property path will generate an {@code IllegalArgumentException} or not.
* @throws IllegalArgumentException If the property name provided is null or empty.
*/
- public BeanPropertyValueEqualsPredicate(final String propertyName, final V propertyValue,
- final boolean ignoreNull) {
+ public BeanPropertyValueEqualsPredicate(final String propertyName, final V propertyValue, final boolean ignoreNull) {
if (propertyName == null || propertyName.isEmpty()) {
throw new IllegalArgumentException("propertyName cannot be null or empty");
}
@@ -175,11 +159,10 @@ public class BeanPropertyValueEqualsPredicate<T, V> implements Predicate<T> {
}
/**
- * Utility method which evaluates whether the actual property value equals the expected property
- * value.
+ * Utility method which evaluates whether the actual property value equals the expected property value.
*
* @param expected The expected value.
- * @param actual The actual value.
+ * @param actual The actual value.
* @return True if they are equal; false otherwise.
*/
protected boolean evaluateValue(final V expected, final Object actual) {
@@ -187,56 +170,48 @@ public class BeanPropertyValueEqualsPredicate<T, V> implements Predicate<T> {
}
/**
- * Returns the name of the property which will be evaluated when this {@code Predicate} is
- * executed.
+ * Returns the name of the property which will be evaluated when this {@code Predicate} is executed.
*
- * @return The name of the property which will be evaluated when this {@code Predicate} is
- * executed.
+ * @return The name of the property which will be evaluated when this {@code Predicate} is executed.
*/
public String getPropertyName() {
return propertyName;
}
/**
- * Returns the value that the property specified by {@code propertyName} will be compared to
- * when this {@code Predicate} executes.
+ * Returns the value that the property specified by {@code propertyName} will be compared to when this {@code Predicate} executes.
*
- * @return The value that the property specified by {@code propertyName} will be compared to
- * when this {@code Predicate} executes.
+ * @return The value that the property specified by {@code propertyName} will be compared to when this {@code Predicate} executes.
*/
public V getPropertyValue() {
return propertyValue;
}
/**
- * Returns the flag which determines whether {@code null} objects in the property path will
- * generate an {@code IllegalArgumentException</code> or not. If set to <code>true} then
+ * Returns the flag which determines whether {@code null} objects in the property path will generate an
+ * {@code IllegalArgumentException</code> or not. If set to <code>true} then
* if any objects in the property path evaluate to {@code null} then the
* {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged but
* not re-thrown and {@code false</code> will be returned. If set to <code>false} then if
* any objects in the property path evaluate to {@code null} then the
- * {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged and
- * re-thrown.
+ * {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged and re-thrown.
*
- * @return The flag which determines whether {@code null} objects in the property path will
- * generate an {@code IllegalArgumentException} or not.
+ * @return The flag which determines whether {@code null} objects in the property path will generate an {@code IllegalArgumentException} or not.
*/
public boolean isIgnoreNull() {
return ignoreNull;
}
/**
- * Evaluates the object provided against the criteria specified when this
- * {@code BeanPropertyValueEqualsPredicate} was constructed. Equality is based on
- * either reference or logical equality as defined by the property object's equals method. If
- * any object in the property path leading up to the target property is {@code null} then
- * the outcome will be based on the value of the {@code ignoreNull} attribute. By default,
+ * Evaluates the object provided against the criteria specified when this {@code BeanPropertyValueEqualsPredicate} was constructed. Equality is based on
+ * either reference or logical equality as defined by the property object's equals method. If any object in the property path leading up to the target
+ * property is {@code null} then the outcome will be based on the value of the {@code ignoreNull} attribute. By default,
* {@code ignoreNull</code> is <code>false} and would result in an
* {@code IllegalArgumentException} if an object in the property path leading up to the
* target property is {@code null}.
*
- * @param object The object to be evaluated.
- * @return True if the object provided meets all the criteria for this {@code Predicate};
+ * @param object The object to be evaluated.
+ * @return True if the object provided meets all the criteria for this {@code Predicate};
* false otherwise.
* @throws IllegalArgumentException If an IllegalAccessException, InvocationTargetException, or
* NoSuchMethodException is thrown when trying to access the property specified on the object
@@ -249,8 +224,7 @@ public class BeanPropertyValueEqualsPredicate<T, V> implements Predicate<T> {
boolean evaluation = false;
try {
- evaluation = evaluateValue(propertyValue,
- PropertyUtils.getProperty(object, propertyName));
+ evaluation = evaluateValue(propertyValue, PropertyUtils.getProperty(object, propertyName));
} catch (final IllegalArgumentException e) {
final String errorMsg = "Problem during evaluation. Null value encountered in property path...";
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformer.java b/src/main/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformer.java
index c0d2706d..f9b69c72 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformer.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformer.java
@@ -24,14 +24,15 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- * <p>{@code Transformer} that outputs a property value.</p>
+ * <p>
+ * {@code Transformer} that outputs a property value.
+ * </p>
*
- * <p>An implementation of {@link java.util.function.Function} that transforms
- * the object provided by returning the value of a specified property of the object. The
- * constructor for {@code BeanToPropertyValueTransformer} requires the name of the property
- * that will be used in the transformation. The property can be a simple, nested, indexed, or
- * mapped property as defined by {@code org.apache.commons.beanutils2.PropertyUtils}. If any
- * object in the property path specified by {@code propertyName</code> is <code>null} then the
+ * <p>
+ * An implementation of {@link java.util.function.Function} that transforms the object provided by returning the value of a specified property of the object.
+ * The constructor for {@code BeanToPropertyValueTransformer} requires the name of the property that will be used in the transformation. The property can be a
+ * simple, nested, indexed, or mapped property as defined by {@code org.apache.commons.beanutils2.PropertyUtils}. If any object in the property path specified
+ * by {@code propertyName</code> is <code>null} then the
* outcome is based on the value of the {@code ignoreNull} attribute.
* </p>
*
@@ -47,21 +48,12 @@ import org.apache.commons.logging.LogFactory;
* }</pre>
*
* <p>
- * This would take a {@code Collection</code> of person objects and return a <code>Collection}
- * of objects which represents the cities in which each person lived. Assuming...
+ * This would take a {@code Collection</code> of person objects and return a <code>Collection} of objects which represents the cities in which each person
+ * lived. Assuming...
* <ul>
- * <li>
- * The top level object in the {@code peopleCollection} is an object which represents a
- * person.
- * </li>
- * <li>
- * The person object has a {@code getAddress()} method which returns an object which
- * represents a person's address.
- * </li>
- * <li>
- * The address object has a {@code getCity()} method which returns an object which
- * represents the city in which a person lives.
- * </li>
+ * <li>The top level object in the {@code peopleCollection} is an object which represents a person.</li>
+ * <li>The person object has a {@code getAddress()} method which returns an object which represents a person's address.</li>
+ * <li>The address object has a {@code getCity()} method which returns an object which represents the city in which a person lives.</li>
* </ul>
*
* @param <T> the type of the input to the function
@@ -79,7 +71,9 @@ public class BeanToPropertyValueTransformer<T, R> implements Function<T, R> {
private final String propertyName;
/**
- * <p>Should null objects on the property path throw an {@code IllegalArgumentException}?</p>
+ * <p>
+ * Should null objects on the property path throw an {@code IllegalArgumentException}?
+ * </p>
* <p>
* Determines whether {@code null} objects in the property path will generate an
* {@code IllegalArgumentException</code> or not. If set to <code>true} then if any objects
@@ -87,56 +81,47 @@ public class BeanToPropertyValueTransformer<T, R> implements Function<T, R> {
* {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged but
* not re-thrown and {@code null</code> will be returned. If set to <code>false} then if any
* objects in the property path evaluate to {@code null} then the
- * {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged and
- * re-thrown.
+ * {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged and re-thrown.
* </p>
*/
private final boolean ignoreNull;
/**
- * Constructs a Transformer which does not ignore nulls.
- * Constructor which takes the name of the property that will be used in the transformation and
+ * Constructs a Transformer which does not ignore nulls. Constructor which takes the name of the property that will be used in the transformation and
* assumes {@code ignoreNull</code> to be <code>false}.
*
- * @param propertyName The name of the property that will be used in the transformation.
- * @throws IllegalArgumentException If the {@code propertyName</code> is <code>null} or
- * empty.
+ * @param propertyName The name of the property that will be used in the transformation.
+ * @throws IllegalArgumentException If the {@code propertyName</code> is <code>null} or empty.
*/
public BeanToPropertyValueTransformer(final String propertyName) {
this(propertyName, false);
}
/**
- * Constructs a Transformer and sets ignoreNull.
- * Constructor which takes the name of the property that will be used in the transformation and
- * a boolean which determines whether {@code null} objects in the property path will
- * generate an {@code IllegalArgumentException} or not.
+ * Constructs a Transformer and sets ignoreNull. Constructor which takes the name of the property that will be used in the transformation and a boolean
+ * which determines whether {@code null} objects in the property path will generate an {@code IllegalArgumentException} or not.
*
* @param propertyName The name of the property that will be used in the transformation.
- * @param ignoreNull Determines whether {@code null} objects in the property path will
- * generate an {@code IllegalArgumentException} or not.
- * @throws IllegalArgumentException If the {@code propertyName</code> is <code>null} or
- * empty.
+ * @param ignoreNull Determines whether {@code null} objects in the property path will generate an {@code IllegalArgumentException} or not.
+ * @throws IllegalArgumentException If the {@code propertyName</code> is <code>null} or empty.
*/
public BeanToPropertyValueTransformer(final String propertyName, final boolean ignoreNull) {
if (propertyName == null || propertyName.isEmpty()) {
- throw new IllegalArgumentException(
- "propertyName cannot be null or empty");
+ throw new IllegalArgumentException("propertyName cannot be null or empty");
}
this.propertyName = propertyName;
this.ignoreNull = ignoreNull;
}
/**
- * Returns the value of the property named in the transformer's constructor for
- * the object provided. If any object in the property path leading up to the target property is
- * {@code null</code> then the outcome will be based on the value of the <code>ignoreNull}
+ * Returns the value of the property named in the transformer's constructor for the object provided. If any object in the property path leading up to the
+ * target property is {@code null</code> then the outcome will be based on the value of the <code>ignoreNull}
* attribute. By default, {@code ignoreNull</code> is <code>false} and would result in an
* {@code IllegalArgumentException} if an object in the property path leading up to the
* target property is {@code null}.
*
- * @param object The object to be transformed.
- * @return The value of the property named in the transformer's constructor for the object
+ * @param object The object to be transformed.
+ * @return The value of the property named in the transformer's constructor for the object
* provided.
* @throws IllegalArgumentException If an IllegalAccessException, InvocationTargetException, or
* NoSuchMethodException is thrown when trying to access the property specified on the object
@@ -178,17 +163,15 @@ public class BeanToPropertyValueTransformer<T, R> implements Function<T, R> {
}
/**
- * Returns the flag which determines whether {@code null} objects in the property path will
- * generate an {@code IllegalArgumentException</code> or not. If set to <code>true} then
+ * Returns the flag which determines whether {@code null} objects in the property path will generate an
+ * {@code IllegalArgumentException</code> or not. If set to <code>true} then
* if any objects in the property path evaluate to {@code null} then the
* {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged but
* not re-thrown and {@code null</code> will be returned. If set to <code>false} then if any
* objects in the property path evaluate to {@code null} then the
- * {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged and
- * re-thrown.
+ * {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged and re-thrown.
*
- * @return The flag which determines whether {@code null} objects in the property path will
- * generate an {@code IllegalArgumentException} or not.
+ * @return The flag which determines whether {@code null} objects in the property path will generate an {@code IllegalArgumentException} or not.
*/
public boolean isIgnoreNull() {
return ignoreNull;
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanUtils.java b/src/main/java/org/apache/commons/beanutils2/BeanUtils.java
index 0022fbfb..dddcbca0 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanUtils.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanUtils.java
@@ -21,11 +21,14 @@ import java.lang.reflect.InvocationTargetException;
import java.util.Map;
/**
- * <p>Utility methods for populating JavaBeans properties via reflection.</p>
+ * <p>
+ * Utility methods for populating JavaBeans properties via reflection.
+ * </p>
*
- * <p>The implementations are provided by {@link BeanUtilsBean}.
- * These static utility methods use the default instance.
- * More sophisticated behavior can be provided by using a {@code BeanUtilsBean} instance.</p>
+ * <p>
+ * The implementations are provided by {@link BeanUtilsBean}. These static utility methods use the default instance. More sophisticated behavior can be provided
+ * by using a {@code BeanUtilsBean} instance.
+ * </p>
*
* @see BeanUtilsBean
*/
@@ -39,81 +42,77 @@ public class BeanUtils {
static final Object[] EMPTY_OBJECT_ARRAY = {};
/**
- * <p>Clone a bean based on the available property getters and setters,
- * even if the bean class itself does not implement Cloneable.</p>
+ * <p>
+ * Clone a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
* @param bean Bean to be cloned
* @return the cloned bean
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InstantiationException if a new instance of the bean's
- * class cannot be instantiated
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InstantiationException if a new instance of the bean's class cannot be instantiated
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
* @see BeanUtilsBean#cloneBean
*/
- public static Object cloneBean(final Object bean)
- throws IllegalAccessException, InstantiationException,
- InvocationTargetException, NoSuchMethodException {
+ public static Object cloneBean(final Object bean) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
return BeanUtilsBean.getInstance().cloneBean(bean);
}
/**
- * <p>Copy property values from the origin bean to the destination bean
- * for all cases where the property names are the same.</p>
+ * <p>
+ * Copy property values from the origin bean to the destination bean for all cases where the property names are the same.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
* @param dest Destination bean whose properties are modified
* @param orig Origin bean whose properties are retrieved
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws IllegalArgumentException if the {@code dest} or
- * {@code orig</code> argument is null or if the <code>dest}
- * property type is different from the source type and the relevant
- * converter has not been registered.
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws IllegalArgumentException if the {@code dest} or {@code orig</code> argument is null or if the <code>dest} property type is different from the
+ * source type and the relevant converter has not been registered.
+ * @throws InvocationTargetException if the property accessor method throws an exception
* @see BeanUtilsBean#copyProperties
*/
- public static void copyProperties(final Object dest, final Object orig)
- throws IllegalAccessException, InvocationTargetException {
+ public static void copyProperties(final Object dest, final Object orig) throws IllegalAccessException, InvocationTargetException {
BeanUtilsBean.getInstance().copyProperties(dest, orig);
}
/**
- * <p>Copy the specified property value to the specified destination bean,
- * performing any type conversion that is required.</p>
+ * <p>
+ * Copy the specified property value to the specified destination bean, performing any type conversion that is required.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
- * @param bean Bean on which setting is to be performed
- * @param name Property name (can be nested/indexed/mapped/combo)
+ * @param bean Bean on which setting is to be performed
+ * @param name Property name (can be nested/indexed/mapped/combo)
* @param value Value to be set
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
* @see BeanUtilsBean#copyProperty
*/
- public static void copyProperty(final Object bean, final String name, final Object value)
- throws IllegalAccessException, InvocationTargetException {
+ public static void copyProperty(final Object bean, final String name, final Object value) throws IllegalAccessException, InvocationTargetException {
BeanUtilsBean.getInstance().copyProperty(bean, name, value);
}
/**
* Create a cache.
+ *
* @param <K> the key type of the cache
* @param <V> the value type of the cache
* @return a new cache
@@ -124,286 +123,266 @@ public class BeanUtils {
}
/**
- * <p>Return the entire set of properties for which the specified bean
- * provides a read method.</p>
+ * <p>
+ * Return the entire set of properties for which the specified bean provides a read method.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
* @param bean Bean whose properties are to be extracted
* @return Map of property descriptors
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
* @see BeanUtilsBean#describe
*/
- public static Map<String, String> describe(final Object bean)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public static Map<String, String> describe(final Object bean) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return BeanUtilsBean.getInstance().describe(bean);
}
/**
- * <p>Return the value of the specified array property of the specified
- * bean, as a String array.</p>
+ * <p>
+ * Return the value of the specified array property of the specified bean, as a String array.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
* @param bean Bean whose property is to be extracted
* @param name Name of the property to be extracted
* @return The array property value
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
* @see BeanUtilsBean#getArrayProperty
*/
public static String[] getArrayProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return BeanUtilsBean.getInstance().getArrayProperty(bean, name);
}
/**
- * <p>Return the value of the specified indexed property of the specified
- * bean, as a String.</p>
+ * <p>
+ * Return the value of the specified indexed property of the specified bean, as a String.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
* @param bean Bean whose property is to be extracted
- * @param name {@code propertyname[index]} of the property value
- * to be extracted
+ * @param name {@code propertyname[index]} of the property value to be extracted
* @return The indexed property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
* @see BeanUtilsBean#getIndexedProperty(Object, String)
*/
public static String getIndexedProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return BeanUtilsBean.getInstance().getIndexedProperty(bean, name);
}
/**
- * Gets the value of the specified indexed property of the specified
- * bean, as a String. The index is specified as a method parameter and
- * must *not* be included in the property name expression
+ * Gets the value of the specified indexed property of the specified bean, as a String. The index is specified as a method parameter and must *not* be
+ * included in the property name expression
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
- * @param bean Bean whose property is to be extracted
- * @param name Simple property name of the property value to be extracted
+ * @param bean Bean whose property is to be extracted
+ * @param name Simple property name of the property value to be extracted
* @param index Index of the property value to be extracted
* @return The indexed property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
* @see BeanUtilsBean#getIndexedProperty(Object, String, int)
*/
- public static String getIndexedProperty(final Object bean,
- final String name, final int index)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public static String getIndexedProperty(final Object bean, final String name, final int index)
+ throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return BeanUtilsBean.getInstance().getIndexedProperty(bean, name, index);
}
/**
- * <p>Return the value of the specified indexed property of the specified
- * bean, as a String.</p>
+ * <p>
+ * Return the value of the specified indexed property of the specified bean, as a String.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
* @param bean Bean whose property is to be extracted
- * @param name {@code propertyname(index)} of the property value
- * to be extracted
+ * @param name {@code propertyname(index)} of the property value to be extracted
* @return The mapped property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
* @see BeanUtilsBean#getMappedProperty(Object, String)
*/
public static String getMappedProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return BeanUtilsBean.getInstance().getMappedProperty(bean, name);
}
/**
- * <p>Return the value of the specified mapped property of the specified
- * bean, as a String.</p>
+ * <p>
+ * Return the value of the specified mapped property of the specified bean, as a String.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
* @param bean Bean whose property is to be extracted
* @param name Simple property name of the property value to be extracted
- * @param key Lookup key of the property value to be extracted
+ * @param key Lookup key of the property value to be extracted
* @return The mapped property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
* @see BeanUtilsBean#getMappedProperty(Object, String, String)
*/
- public static String getMappedProperty(final Object bean,
- final String name, final String key)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public static String getMappedProperty(final Object bean, final String name, final String key)
+ throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return BeanUtilsBean.getInstance().getMappedProperty(bean, name, key);
}
/**
- * <p>Return the value of the (possibly nested) property of the specified
- * name, for the specified bean, as a String.</p>
+ * <p>
+ * Return the value of the (possibly nested) property of the specified name, for the specified bean, as a String.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
* @param bean Bean whose property is to be extracted
* @param name Possibly nested name of the property to be extracted
* @return The nested property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws IllegalArgumentException if a nested reference to a
- * property returns null
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws IllegalArgumentException if a nested reference to a property returns null
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
* @see BeanUtilsBean#getNestedProperty
*/
public static String getNestedProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return BeanUtilsBean.getInstance().getNestedProperty(bean, name);
}
/**
- * <p>Return the value of the specified property of the specified bean,
- * no matter which property reference format is used, as a String.</p>
+ * <p>
+ * Return the value of the specified property of the specified bean, no matter which property reference format is used, as a String.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
* @param bean Bean whose property is to be extracted
- * @param name Possibly indexed and/or nested name of the property
- * to be extracted
+ * @param name Possibly indexed and/or nested name of the property to be extracted
* @return The property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
* @see BeanUtilsBean#getProperty
*/
- public static String getProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public static String getProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return BeanUtilsBean.getInstance().getProperty(bean, name);
}
/**
- * <p>Return the value of the specified simple property of the specified
- * bean, converted to a String.</p>
+ * <p>
+ * Return the value of the specified simple property of the specified bean, converted to a String.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
* @param bean Bean whose property is to be extracted
* @param name Name of the property to be extracted
* @return The property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
* @see BeanUtilsBean#getSimpleProperty
*/
public static String getSimpleProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return BeanUtilsBean.getInstance().getSimpleProperty(bean, name);
}
/**
- * <p>Populate the JavaBeans properties of the specified bean, based on
- * the specified name/value pairs.</p>
+ * <p>
+ * Populate the JavaBeans properties of the specified bean, based on the specified name/value pairs.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
- * @param bean JavaBean whose properties are being populated
- * @param properties Map keyed by property name, with the
- * corresponding (String or String[]) value(s) to be set
+ * @param bean JavaBean whose properties are being populated
+ * @param properties Map keyed by property name, with the corresponding (String or String[]) value(s) to be set
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
* @see BeanUtilsBean#populate
*/
- public static void populate(final Object bean, final Map<String, ? extends Object> properties)
- throws IllegalAccessException, InvocationTargetException {
+ public static void populate(final Object bean, final Map<String, ? extends Object> properties) throws IllegalAccessException, InvocationTargetException {
BeanUtilsBean.getInstance().populate(bean, properties);
}
/**
- * <p>Set the specified property value, performing type conversions as
- * required to conform to the type of the destination property.</p>
+ * <p>
+ * Set the specified property value, performing type conversions as required to conform to the type of the destination property.
+ * </p>
*
- * <p>For more details see {@code BeanUtilsBean}.</p>
+ * <p>
+ * For more details see {@code BeanUtilsBean}.
+ * </p>
*
- * @param bean Bean on which setting is to be performed
- * @param name Property name (can be nested/indexed/mapped/combo)
+ * @param bean Bean on which setting is to be performed
+ * @param name Property name (can be nested/indexed/mapped/combo)
* @param value Value to be set
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
* @see BeanUtilsBean#setProperty
*/
- public static void setProperty(final Object bean, final String name, final Object value)
- throws IllegalAccessException, InvocationTargetException {
+ public static void setProperty(final Object bean, final String name, final Object value) throws IllegalAccessException, InvocationTargetException {
BeanUtilsBean.getInstance().setProperty(bean, name, value);
}
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanUtilsBean.java b/src/main/java/org/apache/commons/beanutils2/BeanUtilsBean.java
index fc733179..8bd0acc8 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanUtilsBean.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanUtilsBean.java
@@ -34,46 +34,43 @@ import org.apache.commons.logging.LogFactory;
/**
* TODO docs
*
- * <p>2.0</p>
+ * <p>
+ * 2.0
+ * </p>
*
- * <p>{@link BeanUtilsBean} implementation that creates a
- * {@link ConvertUtilsBean} and delegates conversion to
- * {@link ConvertUtilsBean#convert(Object, Class)}.
+ * <p>
+ * {@link BeanUtilsBean} implementation that creates a {@link ConvertUtilsBean} and delegates conversion to {@link ConvertUtilsBean#convert(Object, Class)}.
* </p>
*
* <p>
- * To configure this implementation for the current context ClassLoader invoke
- * {@code BeanUtilsBean.setInstance(new BeanUtilsBean2());}
+ * To configure this implementation for the current context ClassLoader invoke {@code BeanUtilsBean.setInstance(new BeanUtilsBean2());}
* </p>
*
* <p>
- * BeanUtils 1.7.0 delegated all conversion to String to the converter
- * registered for the {@code String.class}. One of the improvements in
- * BeanUtils 1.8.0 was to upgrade the {@link Converter} implementations so
- * that they could handle conversion to String for their type (e.g.
- * IntegerConverter now handles conversion from an Integer to a String as
- * well as String to Integer).
+ * BeanUtils 1.7.0 delegated all conversion to String to the converter registered for the {@code String.class}. One of the improvements in BeanUtils 1.8.0 was
+ * to upgrade the {@link Converter} implementations so that they could handle conversion to String for their type (e.g. IntegerConverter now handles conversion
+ * from an Integer to a String as well as String to Integer).
* </p>
*
* <p>
- * In order to take advantage of these improvements BeanUtils needs to change
- * how it gets the appropriate {@link Converter}. This functionality has been
- * implemented in the new {@link ConvertUtilsBean#lookup(Class, Class)} and
- * {@link ConvertUtilsBean#convert(Object, Class)} methods. However changing
- * {@link BeanUtilsBean} to use these methods could create compatibility
- * issues for existing users. In order to avoid that, this new
- * {@link BeanUtilsBean} implementation has been created (and the associated
- * {@link ConvertUtilsBean}).
+ * In order to take advantage of these improvements BeanUtils needs to change how it gets the appropriate {@link Converter}. This functionality has been
+ * implemented in the new {@link ConvertUtilsBean#lookup(Class, Class)} and {@link ConvertUtilsBean#convert(Object, Class)} methods. However changing
+ * {@link BeanUtilsBean} to use these methods could create compatibility issues for existing users. In order to avoid that, this new {@link BeanUtilsBean}
+ * implementation has been created (and the associated {@link ConvertUtilsBean}).
* </p>
*
- * <p>Pre-2.0</p>
+ * <p>
+ * Pre-2.0
+ * </p>
*
- * <p>JavaBean property population methods.</p>
+ * <p>
+ * JavaBean property population methods.
+ * </p>
*
- * <p>This class provides implementations for the utility methods in
- * {@link BeanUtils}.
- * Different instances can be used to isolate caches between class loaders
- * and to vary the value converters registered.</p>
+ * <p>
+ * This class provides implementations for the utility methods in {@link BeanUtils}. Different instances can be used to isolate caches between class loaders and
+ * to vary the value converters registered.
+ * </p>
*
* @see BeanUtils
* @since 1.7
@@ -83,14 +80,13 @@ public class BeanUtilsBean {
/**
* Contains {@code BeanUtilsBean} instances indexed by context classloader.
*/
- private static final ContextClassLoaderLocal<BeanUtilsBean>
- BEANS_BY_CLASSLOADER = new ContextClassLoaderLocal<BeanUtilsBean>() {
- // Creates the default instance used when the context classloader is unavailable
- @Override
- protected BeanUtilsBean initialValue() {
- return new BeanUtilsBean();
- }
- };
+ private static final ContextClassLoaderLocal<BeanUtilsBean> BEANS_BY_CLASSLOADER = new ContextClassLoaderLocal<BeanUtilsBean>() {
+ // Creates the default instance used when the context classloader is unavailable
+ @Override
+ protected BeanUtilsBean initialValue() {
+ return new BeanUtilsBean();
+ }
+ };
/**
* Logging for this instance
@@ -98,15 +94,13 @@ public class BeanUtilsBean {
private static final Log LOG = LogFactory.getLog(BeanUtilsBean.class);
/**
- * Determines the type of a {@code DynaProperty}. Here a special treatment
- * is needed for mapped properties.
+ * Determines the type of a {@code DynaProperty}. Here a special treatment is needed for mapped properties.
*
* @param dynaProperty the property descriptor
- * @param value the value object to be set for this property
+ * @param value the value object to be set for this property
* @return the type of this property
*/
- private static Class<?> dynaPropertyType(final DynaProperty dynaProperty,
- final Object value) {
+ private static Class<?> dynaPropertyType(final DynaProperty dynaProperty, final Object value) {
if (!dynaProperty.isMapped()) {
return dynaProperty.getType();
}
@@ -114,9 +108,8 @@ public class BeanUtilsBean {
}
/**
- * Gets the instance which provides the functionality for {@link BeanUtils}.
- * This is a pseudo-singleton - an single instance is provided per (thread) context classloader.
- * This mechanism provides isolation for web apps deployed in the same container.
+ * Gets the instance which provides the functionality for {@link BeanUtils}. This is a pseudo-singleton - an single instance is provided per (thread)
+ * context classloader. This mechanism provides isolation for web apps deployed in the same container.
*
* @return The (pseudo-singleton) BeanUtils bean instance
*/
@@ -125,9 +118,8 @@ public class BeanUtilsBean {
}
/**
- * Sets the instance which provides the functionality for {@link BeanUtils}.
- * This is a pseudo-singleton - an single instance is provided per (thread) context classloader.
- * This mechanism provides isolation for web apps deployed in the same container.
+ * Sets the instance which provides the functionality for {@link BeanUtils}. This is a pseudo-singleton - an single instance is provided per (thread)
+ * context classloader. This mechanism provides isolation for web apps deployed in the same container.
*
* @param newInstance The (pseudo-singleton) BeanUtils bean instance
*/
@@ -138,23 +130,24 @@ public class BeanUtilsBean {
/** Used to perform conversions between object types when setting properties */
private final ConvertUtilsBean convertUtilsBean;
- /** Used to access properties*/
+ /** Used to access properties */
private final PropertyUtilsBean propertyUtilsBean;
/**
- * <p>Constructs an instance using new property
- * and conversion instances.</p>
+ * <p>
+ * Constructs an instance using new property and conversion instances.
+ * </p>
*/
public BeanUtilsBean() {
this(new ConvertUtilsBean(), new PropertyUtilsBean());
}
/**
- * <p>Constructs an instance using given conversion instances
- * and new {@link PropertyUtilsBean} instance.</p>
+ * <p>
+ * Constructs an instance using given conversion instances and new {@link PropertyUtilsBean} instance.
+ * </p>
*
- * @param todoRemove use this {@code ConvertUtilsBean}
- * to perform conversions from one object to another
+ * @param todoRemove use this {@code ConvertUtilsBean} to perform conversions from one object to another
*
* @since 1.8.0
*/
@@ -163,44 +156,37 @@ public class BeanUtilsBean {
}
/**
- * <p>Constructs an instance using given property and conversion instances.</p>
+ * <p>
+ * Constructs an instance using given property and conversion instances.
+ * </p>
*
- * @param convertUtilsBean use this {@code ConvertUtilsBean}
- * to perform conversions from one object to another
- * @param propertyUtilsBean use this {@code PropertyUtilsBean}
- * to access properties
+ * @param convertUtilsBean use this {@code ConvertUtilsBean} to perform conversions from one object to another
+ * @param propertyUtilsBean use this {@code PropertyUtilsBean} to access properties
*/
- public BeanUtilsBean(final ConvertUtilsBean convertUtilsBean,
- final PropertyUtilsBean propertyUtilsBean) {
+ public BeanUtilsBean(final ConvertUtilsBean convertUtilsBean, final PropertyUtilsBean propertyUtilsBean) {
this.convertUtilsBean = convertUtilsBean;
this.propertyUtilsBean = propertyUtilsBean;
}
/**
- * <p>Clone a bean based on the available property getters and setters,
- * even if the bean class itself does not implement Cloneable.</p>
+ * <p>
+ * Clone a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable.
+ * </p>
*
* <p>
- * <strong>Note:</strong> this method creates a <strong>shallow</strong> clone.
- * In other words, any objects referred to by the bean are shared with the clone
- * rather than being cloned in turn.
+ * <strong>Note:</strong> this method creates a <strong>shallow</strong> clone. In other words, any objects referred to by the bean are shared with the
+ * clone rather than being cloned in turn.
* </p>
*
* @param bean Bean to be cloned
* @return the cloned bean
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InstantiationException if a new instance of the bean's
- * class cannot be instantiated
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InstantiationException if a new instance of the bean's class cannot be instantiated
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
*/
- public Object cloneBean(final Object bean)
- throws IllegalAccessException, InstantiationException,
- InvocationTargetException, NoSuchMethodException {
+ public Object cloneBean(final Object bean) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
if (LOG.isDebugEnabled()) {
LOG.debug("Cloning bean: " + bean.getClass().getName());
}
@@ -215,11 +201,12 @@ public class BeanUtilsBean {
}
/**
- * <p>Converts the value to an object of the specified class (if
- * possible).</p>
+ * <p>
+ * Converts the value to an object of the specified class (if possible).
+ * </p>
*
* @param value Value to be converted (may be null)
- * @param type Class of the value to be converted to
+ * @param type Class of the value to be converted to
* @return The converted value
*/
protected <R> Object convert(final Object value, final Class<R> type) {
@@ -227,12 +214,11 @@ public class BeanUtilsBean {
}
/**
- * Performs a type conversion of a property value before it is copied to a target
- * bean. This method delegates to {@link #convert(Object, Class)}, but <b>null</b>
- * values are not converted. This causes <b>null</b> values to be copied verbatim.
+ * Performs a type conversion of a property value before it is copied to a target bean. This method delegates to {@link #convert(Object, Class)}, but
+ * <b>null</b> values are not converted. This causes <b>null</b> values to be copied verbatim.
*
* @param value the value to be converted and copied
- * @param type the target type of the conversion
+ * @param type the target type of the conversion
* @return the converted value
*/
private Object convertForCopy(final Object value, final Class<?> type) {
@@ -240,66 +226,56 @@ public class BeanUtilsBean {
}
/**
- * <p>Copy property values from the origin bean to the destination bean
- * for all cases where the property names are the same. For each
- * property, a conversion is attempted as necessary. All combinations of
- * standard JavaBeans and DynaBeans as origin and destination are
- * supported. Properties that exist in the origin bean, but do not exist
- * in the destination bean (or are read-only in the destination bean) are
- * silently ignored.</p>
+ * <p>
+ * Copy property values from the origin bean to the destination bean for all cases where the property names are the same. For each property, a conversion is
+ * attempted as necessary. All combinations of standard JavaBeans and DynaBeans as origin and destination are supported. Properties that exist in the origin
+ * bean, but do not exist in the destination bean (or are read-only in the destination bean) are silently ignored.
+ * </p>
*
- * <p>If the origin "bean" is actually a {@code Map}, it is assumed
- * to contain String-valued <strong>simple</strong> property names as the keys, pointing at
- * the corresponding property values that will be converted (if necessary)
- * and set in the destination bean. <strong>Note</strong> that this method
- * is intended to perform a "shallow copy" of the properties and so complex
- * properties (for example, nested ones) will not be copied.</p>
+ * <p>
+ * If the origin "bean" is actually a {@code Map}, it is assumed to contain String-valued <strong>simple</strong> property names as the keys, pointing at
+ * the corresponding property values that will be converted (if necessary) and set in the destination bean. <strong>Note</strong> that this method is
+ * intended to perform a "shallow copy" of the properties and so complex properties (for example, nested ones) will not be copied.
+ * </p>
*
- * <p>This method differs from {@code populate()}, which
- * was primarily designed for populating JavaBeans from the map of request
- * parameters retrieved on an HTTP request, is that no scalar->indexed
- * or indexed->scalar manipulations are performed. If the origin property
- * is indexed, the destination property must be also.</p>
+ * <p>
+ * This method differs from {@code populate()}, which was primarily designed for populating JavaBeans from the map of request parameters retrieved on an
+ * HTTP request, is that no scalar->indexed or indexed->scalar manipulations are performed. If the origin property is indexed, the destination
+ * property must be also.
+ * </p>
*
- * <p>If you know that no type conversions are required, the
- * {@code copyProperties()} method in {@link PropertyUtils} will
- * execute faster than this method.</p>
+ * <p>
+ * If you know that no type conversions are required, the {@code copyProperties()} method in {@link PropertyUtils} will execute faster than this method.
+ * </p>
*
- * <p><strong>FIXME</strong> - Indexed and mapped properties that do not
- * have getter and setter methods for the underlying array or Map are not
- * copied by this method.</p>
+ * <p>
+ * <strong>FIXME</strong> - Indexed and mapped properties that do not have getter and setter methods for the underlying array or Map are not copied by this
+ * method.
+ * </p>
*
* @param dest Destination bean whose properties are modified
* @param orig Origin bean whose properties are retrieved
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws IllegalArgumentException if the {@code dest} or
- * {@code orig</code> argument is null or if the <code>dest}
- * property type is different from the source type and the relevant
- * converter has not been registered.
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws IllegalArgumentException if the {@code dest} or {@code orig</code> argument is null or if the <code>dest} property type is different from the
+ * source type and the relevant converter has not been registered.
+ * @throws InvocationTargetException if the property accessor method throws an exception
*/
- public void copyProperties(final Object dest, final Object orig)
- throws IllegalAccessException, InvocationTargetException {
+ public void copyProperties(final Object dest, final Object orig) throws IllegalAccessException, InvocationTargetException {
// Validate existence of the specified beans
Objects.requireNonNull(dest, "dest");
Objects.requireNonNull(orig, "orig");
if (LOG.isDebugEnabled()) {
- LOG.debug("BeanUtils.copyProperties(" + dest + ", " +
- orig + ")");
+ LOG.debug("BeanUtils.copyProperties(" + dest + ", " + orig + ")");
}
// Copy the properties, converting as necessary
if (orig instanceof DynaBean) {
- final DynaProperty[] origDescriptors =
- ((DynaBean) orig).getDynaClass().getDynaProperties();
+ final DynaProperty[] origDescriptors = ((DynaBean) orig).getDynaClass().getDynaProperties();
for (final DynaProperty origDescriptor : origDescriptors) {
final String name = origDescriptor.getName();
// Need to check isReadable() for WrapDynaBean
// (see Jira issue# BEANUTILS-61)
- if (getPropertyUtils().isReadable(orig, name) &&
- getPropertyUtils().isWriteable(dest, name)) {
+ if (getPropertyUtils().isReadable(orig, name) && getPropertyUtils().isWriteable(dest, name)) {
final Object value = ((DynaBean) orig).get(name);
copyProperty(dest, name, value);
}
@@ -316,18 +292,15 @@ public class BeanUtilsBean {
}
}
} else /* if (orig is a standard JavaBean) */ {
- final PropertyDescriptor[] origDescriptors =
- getPropertyUtils().getPropertyDescriptors(orig);
+ final PropertyDescriptor[] origDescriptors = getPropertyUtils().getPropertyDescriptors(orig);
for (final PropertyDescriptor origDescriptor : origDescriptors) {
final String name = origDescriptor.getName();
if ("class".equals(name)) {
continue; // No point in trying to set an object's class
}
- if (getPropertyUtils().isReadable(orig, name) &&
- getPropertyUtils().isWriteable(dest, name)) {
+ if (getPropertyUtils().isReadable(orig, name) && getPropertyUtils().isWriteable(dest, name)) {
try {
- final Object value =
- getPropertyUtils().getSimpleProperty(orig, name);
+ final Object value = getPropertyUtils().getSimpleProperty(orig, name);
copyProperty(dest, name, value);
} catch (final NoSuchMethodException e) {
// Should not happen
@@ -338,38 +311,29 @@ public class BeanUtilsBean {
}
/**
- * <p>Copy the specified property value to the specified destination bean,
- * performing any type conversion that is required. If the specified
- * bean does not have a property of the specified name, or the property
- * is read only on the destination bean, return without
- * doing anything. If you have custom destination property types, register
- * {@link Converter}s for them by calling the {@code register()}
- * method of {@link ConvertUtils}.</p>
+ * <p>
+ * Copy the specified property value to the specified destination bean, performing any type conversion that is required. If the specified bean does not have
+ * a property of the specified name, or the property is read only on the destination bean, return without doing anything. If you have custom destination
+ * property types, register {@link Converter}s for them by calling the {@code register()} method of {@link ConvertUtils}.
+ * </p>
*
- * <p><strong>IMPLEMENTATION RESTRICTIONS</strong>:</p>
+ * <p>
+ * <strong>IMPLEMENTATION RESTRICTIONS</strong>:
+ * </p>
* <ul>
- * <li>Does not support destination properties that are indexed,
- * but only an indexed setter (as opposed to an array setter)
- * is available.</li>
- * <li>Does not support destination properties that are mapped,
- * but only a keyed setter (as opposed to a Map setter)
- * is available.</li>
- * <li>The desired property type of a mapped setter cannot be
- * determined (since Maps support any data type), so no conversion
- * will be performed.</li>
+ * <li>Does not support destination properties that are indexed, but only an indexed setter (as opposed to an array setter) is available.</li>
+ * <li>Does not support destination properties that are mapped, but only a keyed setter (as opposed to a Map setter) is available.</li>
+ * <li>The desired property type of a mapped setter cannot be determined (since Maps support any data type), so no conversion will be performed.</li>
* </ul>
*
- * @param bean Bean on which setting is to be performed
- * @param name Property name (can be nested/indexed/mapped/combo)
+ * @param bean Bean on which setting is to be performed
+ * @param name Property name (can be nested/indexed/mapped/combo)
* @param value Value to be set
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
*/
- public void copyProperty(final Object bean, String name, Object value)
- throws IllegalAccessException, InvocationTargetException {
+ public void copyProperty(final Object bean, String name, Object value) throws IllegalAccessException, InvocationTargetException {
// Trace logging (if enabled)
if (LOG.isTraceEnabled()) {
final StringBuilder sb = new StringBuilder(" copyProperty(");
@@ -416,9 +380,9 @@ public class BeanUtilsBean {
// Declare local variables we will require
final String propName = resolver.getProperty(name); // Simple name of target property
- Class<?> type = null; // Java type of target property
- final int index = resolver.getIndex(name); // Indexed subscript value (if any)
- final String key = resolver.getKey(name); // Mapped key value (if any)
+ Class<?> type = null; // Java type of target property
+ final int index = resolver.getIndex(name); // Indexed subscript value (if any)
+ final String key = resolver.getKey(name); // Mapped key value (if any)
// Calculate the target property type
if (target instanceof DynaBean) {
@@ -431,8 +395,7 @@ public class BeanUtilsBean {
} else {
PropertyDescriptor descriptor = null;
try {
- descriptor =
- getPropertyUtils().getPropertyDescriptor(target, name);
+ descriptor = getPropertyUtils().getPropertyDescriptor(target, name);
if (descriptor == null) {
return; // Skip this property setter
}
@@ -443,64 +406,60 @@ public class BeanUtilsBean {
if (type == null) {
// Most likely an indexed setter on a POJB only
if (LOG.isTraceEnabled()) {
- LOG.trace(" target type for property '" +
- propName + "' is null, so skipping ths setter");
+ LOG.trace(" target type for property '" + propName + "' is null, so skipping ths setter");
}
return;
}
}
if (LOG.isTraceEnabled()) {
- LOG.trace(" target propName=" + propName + ", type=" +
- type + ", index=" + index + ", key=" + key);
+ LOG.trace(" target propName=" + propName + ", type=" + type + ", index=" + index + ", key=" + key);
}
// Convert the specified value to the required type and store it
- if (index >= 0) { // Destination must be indexed
+ if (index >= 0) { // Destination must be indexed
value = convertForCopy(value, type.getComponentType());
try {
- getPropertyUtils().setIndexedProperty(target, propName,
- index, value);
+ getPropertyUtils().setIndexedProperty(target, propName, index, value);
} catch (final NoSuchMethodException e) {
- throw new InvocationTargetException
- (e, "Cannot set " + propName);
+ throw new InvocationTargetException(e, "Cannot set " + propName);
}
- } else if (key != null) { // Destination must be mapped
+ } else if (key != null) { // Destination must be mapped
// Maps do not know what the preferred data type is,
// so perform no conversions at all
// FIXME - should we create or support a TypedMap?
try {
- getPropertyUtils().setMappedProperty(target, propName,
- key, value);
+ getPropertyUtils().setMappedProperty(target, propName, key, value);
} catch (final NoSuchMethodException e) {
- throw new InvocationTargetException
- (e, "Cannot set " + propName);
+ throw new InvocationTargetException(e, "Cannot set " + propName);
}
- } else { // Destination must be simple
+ } else { // Destination must be simple
value = convertForCopy(value, type);
try {
getPropertyUtils().setSimpleProperty(target, propName, value);
} catch (final NoSuchMethodException e) {
- throw new InvocationTargetException
- (e, "Cannot set " + propName);
+ throw new InvocationTargetException(e, "Cannot set " + propName);
}
}
}
/**
- * <p>Return the entire set of properties for which the specified bean
- * provides a read method. This map contains the to {@code String}
- * converted property values for all properties for which a read method
- * is provided (i.e. where the getReadMethod() returns non-null).</p>
+ * <p>
+ * Return the entire set of properties for which the specified bean provides a read method. This map contains the to {@code String} converted property
+ * values for all properties for which a read method is provided (i.e. where the getReadMethod() returns non-null).
+ * </p>
+ *
+ * <p>
+ * This map can be fed back to a call to {@code BeanUtils.populate()} to re-constitute the same set of properties, modulo differences for read-only and
+ * write-only properties, but only if there are no indexed properties.
+ * </p>
*
- * <p>This map can be fed back to a call to
- * {@code BeanUtils.populate()} to re-constitute the same set of
- * properties, modulo differences for read-only and write-only
- * properties, but only if there are no indexed properties.</p>
+ * <p>
+ * <strong>Warning:</strong> if any of the bean property implementations contain (directly or indirectly) a call to this method then a stack overflow may
+ * result. For example:
+ * </p>
*
- * <p><strong>Warning:</strong> if any of the bean property implementations
- * contain (directly or indirectly) a call to this method then
- * a stack overflow may result. For example:</p>
- * <pre><code>
+ * <pre>
+ * <code>
* class MyBean
* {
* public Map getParameterMap()
@@ -508,27 +467,23 @@ public class BeanUtilsBean {
* BeanUtils.describe(this);
* }
* }
- * </code></pre>
+ * </code>
+ * </pre>
* <p>
- * will result in an infinite regression when {@code getParametersMap}
- * is called. It is recommended that such methods are given alternative
- * names (for example, {@code parametersMap}).
+ * will result in an infinite regression when {@code getParametersMap} is called. It is recommended that such methods are given alternative names (for
+ * example, {@code parametersMap}).
* </p>
+ *
* @param bean Bean whose properties are to be extracted
* @return Map of property descriptors
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
*/
- public Map<String, String> describe(final Object bean)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public Map<String, String> describe(final Object bean) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (bean == null) {
- // return (Collections.EMPTY_MAP);
+ // return (Collections.EMPTY_MAP);
return new java.util.HashMap<>();
}
@@ -538,15 +493,13 @@ public class BeanUtilsBean {
final Map<String, String> description = new HashMap<>();
if (bean instanceof DynaBean) {
- final DynaProperty[] descriptors =
- ((DynaBean) bean).getDynaClass().getDynaProperties();
+ final DynaProperty[] descriptors = ((DynaBean) bean).getDynaClass().getDynaProperties();
for (final DynaProperty descriptor : descriptors) {
final String name = descriptor.getName();
description.put(name, getProperty(bean, name));
}
} else {
- final PropertyDescriptor[] descriptors =
- getPropertyUtils().getPropertyDescriptors(bean);
+ final PropertyDescriptor[] descriptors = getPropertyUtils().getPropertyDescriptors(bean);
final Class<?> clazz = bean.getClass();
for (final PropertyDescriptor descriptor : descriptors) {
final String name = descriptor.getName();
@@ -559,23 +512,17 @@ public class BeanUtilsBean {
}
/**
- * Gets the value of the specified array property of the specified
- * bean, as a String array.
+ * Gets the value of the specified array property of the specified bean, as a String array.
*
* @param bean Bean whose property is to be extracted
* @param name Name of the property to be extracted
* @return The array property value
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
*/
- public String[] getArrayProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public String[] getArrayProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
final Object value = getPropertyUtils().getProperty(bean, name);
if (value == null) {
return null;
@@ -612,150 +559,106 @@ public class BeanUtilsBean {
}
/**
- * Gets the value of the specified indexed property of the specified
- * bean, as a String. The zero-relative index of the
- * required value must be included (in square brackets) as a suffix to
- * the property name, or {@code IllegalArgumentException} will be
- * thrown.
+ * Gets the value of the specified indexed property of the specified bean, as a String. The zero-relative index of the required value must be included (in
+ * square brackets) as a suffix to the property name, or {@code IllegalArgumentException} will be thrown.
*
* @param bean Bean whose property is to be extracted
- * @param name {@code propertyname[index]} of the property value
- * to be extracted
+ * @param name {@code propertyname[index]} of the property value to be extracted
* @return The indexed property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
*/
- public String getIndexedProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public String getIndexedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
final Object value = getPropertyUtils().getIndexedProperty(bean, name);
return getConvertUtils().convert(value);
}
/**
- * Gets the value of the specified indexed property of the specified
- * bean, as a String. The index is specified as a method parameter and
- * must *not* be included in the property name expression
+ * Gets the value of the specified indexed property of the specified bean, as a String. The index is specified as a method parameter and must *not* be
+ * included in the property name expression
*
- * @param bean Bean whose property is to be extracted
- * @param name Simple property name of the property value to be extracted
+ * @param bean Bean whose property is to be extracted
+ * @param name Simple property name of the property value to be extracted
* @param index Index of the property value to be extracted
* @return The indexed property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
*/
- public String getIndexedProperty(final Object bean,
- final String name, final int index)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public String getIndexedProperty(final Object bean, final String name, final int index)
+ throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
final Object value = getPropertyUtils().getIndexedProperty(bean, name, index);
return getConvertUtils().convert(value);
}
/**
- * Gets the value of the specified indexed property of the specified
- * bean, as a String. The String-valued key of the required value
- * must be included (in parentheses) as a suffix to
- * the property name, or {@code IllegalArgumentException} will be
- * thrown.
+ * Gets the value of the specified indexed property of the specified bean, as a String. The String-valued key of the required value must be included (in
+ * parentheses) as a suffix to the property name, or {@code IllegalArgumentException} will be thrown.
*
* @param bean Bean whose property is to be extracted
- * @param name {@code propertyname(index)} of the property value
- * to be extracted
+ * @param name {@code propertyname(index)} of the property value to be extracted
* @return The mapped property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
*/
- public String getMappedProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public String getMappedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
final Object value = getPropertyUtils().getMappedProperty(bean, name);
return getConvertUtils().convert(value);
}
/**
- * Gets the value of the specified mapped property of the specified
- * bean, as a String. The key is specified as a method parameter and
- * must *not* be included in the property name expression
+ * Gets the value of the specified mapped property of the specified bean, as a String. The key is specified as a method parameter and must *not* be included
+ * in the property name expression
*
* @param bean Bean whose property is to be extracted
* @param name Simple property name of the property value to be extracted
- * @param key Lookup key of the property value to be extracted
+ * @param key Lookup key of the property value to be extracted
* @return The mapped property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
*/
- public String getMappedProperty(final Object bean,
- final String name, final String key)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public String getMappedProperty(final Object bean, final String name, final String key)
+ throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
final Object value = getPropertyUtils().getMappedProperty(bean, name, key);
return getConvertUtils().convert(value);
}
/**
- * Gets the value of the (possibly nested) property of the specified
- * name, for the specified bean, as a String.
+ * Gets the value of the (possibly nested) property of the specified name, for the specified bean, as a String.
*
* @param bean Bean whose property is to be extracted
* @param name Possibly nested name of the property to be extracted
* @return The nested property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws IllegalArgumentException if a nested reference to a
- * property returns null
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws IllegalArgumentException if a nested reference to a property returns null
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
*/
- public String getNestedProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public String getNestedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
final Object value = getPropertyUtils().getNestedProperty(bean, name);
return getConvertUtils().convert(value);
}
/**
- * Gets the value of the specified property of the specified bean,
- * no matter which property reference format is used, as a String.
+ * Gets the value of the specified property of the specified bean, no matter which property reference format is used, as a String.
*
* @param bean Bean whose property is to be extracted
- * @param name Possibly indexed and/or nested name of the property
- * to be extracted
+ * @param name Possibly indexed and/or nested name of the property to be extracted
* @return The property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
*/
- public String getProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public String getProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return getNestedProperty(bean, name);
}
@@ -769,75 +672,61 @@ public class BeanUtilsBean {
}
/**
- * Gets the value of the specified simple property of the specified
- * bean, converted to a String.
+ * Gets the value of the specified simple property of the specified bean, converted to a String.
*
* @param bean Bean whose property is to be extracted
* @param name Name of the property to be extracted
* @return The property's value, converted to a String
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
*/
- public String getSimpleProperty(final Object bean, final String name)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public String getSimpleProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
final Object value = getPropertyUtils().getSimpleProperty(bean, name);
return getConvertUtils().convert(value);
}
/**
- * <p>Populate the JavaBeans properties of the specified bean, based on
- * the specified name/value pairs. This method uses Java reflection APIs
- * to identify corresponding "property setter" method names, and deals
- * with setter arguments of type {@code String</code>, <code>boolean},
- * {@code int}, {@code long}, {@code float}, and
- * {@code double}. In addition, array setters for these types (or the
- * corresponding primitive types) can also be identified.</p>
+ * <p>
+ * Populate the JavaBeans properties of the specified bean, based on the specified name/value pairs. This method uses Java reflection APIs to identify
+ * corresponding "property setter" method names, and deals with setter arguments of type {@code String</code>, <code>boolean}, {@code int}, {@code long},
+ * {@code float}, and {@code double}. In addition, array setters for these types (or the corresponding primitive types) can also be identified.
+ * </p>
*
- * <p>The particular setter method to be called for each property is
- * determined using the usual JavaBeans introspection mechanisms. Thus,
- * you may identify custom setter methods using a BeanInfo class that is
- * associated with the class of the bean itself. If no such BeanInfo
- * class is available, the standard method name conversion ("set" plus
- * the capitalized name of the property in question) is used.</p>
+ * <p>
+ * The particular setter method to be called for each property is determined using the usual JavaBeans introspection mechanisms. Thus, you may identify
+ * custom setter methods using a BeanInfo class that is associated with the class of the bean itself. If no such BeanInfo class is available, the standard
+ * method name conversion ("set" plus the capitalized name of the property in question) is used.
+ * </p>
*
- * <p><strong>NOTE</strong>: It is contrary to the JavaBeans Specification
- * to have more than one setter method (with different argument
- * signatures) for the same property.</p>
+ * <p>
+ * <strong>NOTE</strong>: It is contrary to the JavaBeans Specification to have more than one setter method (with different argument signatures) for the
+ * same property.
+ * </p>
*
- * <p><strong>WARNING</strong> - The logic of this method is customized
- * for extracting String-based request parameters from an HTTP request.
- * It is probably not what you want for general property copying with
- * type conversion. For that purpose, check out the
- * {@code copyProperties()} method instead.</p>
+ * <p>
+ * <strong>WARNING</strong> - The logic of this method is customized for extracting String-based request parameters from an HTTP request. It is probably not
+ * what you want for general property copying with type conversion. For that purpose, check out the {@code copyProperties()} method instead.
+ * </p>
*
- * @param bean JavaBean whose properties are being populated
- * @param properties Map keyed by property name, with the
- * corresponding (String or String[]) value(s) to be set
+ * @param bean JavaBean whose properties are being populated
+ * @param properties Map keyed by property name, with the corresponding (String or String[]) value(s) to be set
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
*/
- public void populate(final Object bean, final Map<String, ? extends Object> properties)
- throws IllegalAccessException, InvocationTargetException {
+ public void populate(final Object bean, final Map<String, ? extends Object> properties) throws IllegalAccessException, InvocationTargetException {
// Do nothing unless both arguments have been specified
if (bean == null || properties == null) {
return;
}
if (LOG.isDebugEnabled()) {
- LOG.debug("BeanUtils.populate(" + bean + ", " +
- properties + ")");
+ LOG.debug("BeanUtils.populate(" + bean + ", " + properties + ")");
}
// Loop through the property name/value pairs to be set
- for(final Map.Entry<String, ? extends Object> entry : properties.entrySet()) {
+ for (final Map.Entry<String, ? extends Object> entry : properties.entrySet()) {
// Identify the property name and value(s) to be assigned
final String name = entry.getKey();
if (name == null) {
@@ -850,37 +739,36 @@ public class BeanUtilsBean {
}
/**
- * <p>Set the specified property value, performing type conversions as
- * required to conform to the type of the destination property.</p>
+ * <p>
+ * Set the specified property value, performing type conversions as required to conform to the type of the destination property.
+ * </p>
*
- * <p>If the property is read only then the method returns
- * without throwing an exception.</p>
+ * <p>
+ * If the property is read only then the method returns without throwing an exception.
+ * </p>
*
- * <p>If {@code null} is passed into a property expecting a primitive value,
- * then this will be converted as if it were a {@code null} string.</p>
+ * <p>
+ * If {@code null} is passed into a property expecting a primitive value, then this will be converted as if it were a {@code null} string.
+ * </p>
*
- * <p><strong>WARNING</strong> - The logic of this method is customized
- * to meet the needs of {@code populate()}, and is probably not what
- * you want for general property copying with type conversion. For that
- * purpose, check out the {@code copyProperty()} method instead.</p>
+ * <p>
+ * <strong>WARNING</strong> - The logic of this method is customized to meet the needs of {@code populate()}, and is probably not what you want for general
+ * property copying with type conversion. For that purpose, check out the {@code copyProperty()} method instead.
+ * </p>
*
- * <p><strong>WARNING</strong> - PLEASE do not modify the behavior of this
- * method without consulting with the Struts developer community. There
- * are some subtleties to its functionality that are not documented in the
- * Javadoc description above, yet are vital to the way that Struts utilizes
- * this method.</p>
+ * <p>
+ * <strong>WARNING</strong> - PLEASE do not modify the behavior of this method without consulting with the Struts developer community. There are some
+ * subtleties to its functionality that are not documented in the Javadoc description above, yet are vital to the way that Struts utilizes this method.
+ * </p>
*
- * @param bean Bean on which setting is to be performed
- * @param name Property name (can be nested/indexed/mapped/combo)
+ * @param bean Bean on which setting is to be performed
+ * @param name Property name (can be nested/indexed/mapped/combo)
* @param value Value to be set
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws InvocationTargetException if the property accessor method throws an exception
*/
- public void setProperty(final Object bean, String name, final Object value)
- throws IllegalAccessException, InvocationTargetException {
+ public void setProperty(final Object bean, String name, final Object value) throws IllegalAccessException, InvocationTargetException {
// Trace logging (if enabled)
if (LOG.isTraceEnabled()) {
final StringBuilder sb = new StringBuilder(" setProperty(");
@@ -930,9 +818,9 @@ public class BeanUtilsBean {
// Declare local variables we will require
final String propName = resolver.getProperty(name); // Simple name of target property
- Class<?> type = null; // Java type of target property
- final int index = resolver.getIndex(name); // Indexed subscript value (if any)
- final String key = resolver.getKey(name); // Mapped key value (if any)
+ Class<?> type = null; // Java type of target property
+ final int index = resolver.getIndex(name); // Indexed subscript value (if any)
+ final String key = resolver.getKey(name); // Mapped key value (if any)
// Calculate the property type
if (target instanceof DynaBean) {
@@ -952,8 +840,7 @@ public class BeanUtilsBean {
} else {
PropertyDescriptor descriptor = null;
try {
- descriptor =
- getPropertyUtils().getPropertyDescriptor(target, name);
+ descriptor = getPropertyUtils().getPropertyDescriptor(target, name);
if (descriptor == null) {
return; // Skip this property setter
}
@@ -967,8 +854,7 @@ public class BeanUtilsBean {
}
return; // Read-only, skip this property setter
}
- type = ((MappedPropertyDescriptor) descriptor).
- getMappedPropertyType();
+ type = ((MappedPropertyDescriptor) descriptor).getMappedPropertyType();
} else if (index >= 0 && descriptor instanceof IndexedPropertyDescriptor) {
if (((IndexedPropertyDescriptor) descriptor).getIndexedWriteMethod() == null) {
if (LOG.isDebugEnabled()) {
@@ -976,8 +862,7 @@ public class BeanUtilsBean {
}
return; // Read-only, skip this property setter
}
- type = ((IndexedPropertyDescriptor) descriptor).
- getIndexedPropertyType();
+ type = ((IndexedPropertyDescriptor) descriptor).getIndexedPropertyType();
} else if (index >= 0 && List.class.isAssignableFrom(descriptor.getPropertyType())) {
type = Object.class;
} else if (key != null) {
@@ -1013,31 +898,27 @@ public class BeanUtilsBean {
} else {
newValue = convert(value, type);
}
- } else if (type.isArray()) { // Indexed value into array
+ } else if (type.isArray()) { // Indexed value into array
if (value instanceof String || value == null) {
- newValue = getConvertUtils().convert((String) value,
- type.getComponentType());
+ newValue = getConvertUtils().convert((String) value, type.getComponentType());
} else if (value instanceof String[]) {
- newValue = getConvertUtils().convert(((String[]) value)[0],
- type.getComponentType());
+ newValue = getConvertUtils().convert(((String[]) value)[0], type.getComponentType());
} else {
newValue = convert(value, type.getComponentType());
}
} else if (value instanceof String) {
newValue = getConvertUtils().convert((String) value, type);
} else if (value instanceof String[]) {
- newValue = getConvertUtils().convert(((String[]) value)[0],
- type);
+ newValue = getConvertUtils().convert(((String[]) value)[0], type);
} else {
newValue = convert(value, type);
}
// Invoke the setter method
try {
- getPropertyUtils().setProperty(target, name, newValue);
+ getPropertyUtils().setProperty(target, name, newValue);
} catch (final NoSuchMethodException e) {
- throw new InvocationTargetException
- (e, "Cannot set " + propName);
+ throw new InvocationTargetException(e, "Cannot set " + propName);
}
}
}
diff --git a/src/main/java/org/apache/commons/beanutils2/ConstructorUtils.java b/src/main/java/org/apache/commons/beanutils2/ConstructorUtils.java
index 78ea73df..62206ca5 100644
--- a/src/main/java/org/apache/commons/beanutils2/ConstructorUtils.java
+++ b/src/main/java/org/apache/commons/beanutils2/ConstructorUtils.java
@@ -23,34 +23,36 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
/**
- * <p>Utility reflection methods focused on constructors, modeled after {@link MethodUtils}.</p>
+ * <p>
+ * Utility reflection methods focused on constructors, modeled after {@link MethodUtils}.
+ * </p>
*
* <h2>Known Limitations</h2>
* <h3>Accessing Public Constructors In A Default Access Superclass</h3>
- * <p>There is an issue when invoking public constructors contained in a default access superclass.
- * Reflection locates these constructors fine and correctly assigns them as public.
- * However, an {@code IllegalAccessException} is thrown if the constructors is invoked.</p>
+ * <p>
+ * There is an issue when invoking public constructors contained in a default access superclass. Reflection locates these constructors fine and correctly
+ * assigns them as public. However, an {@code IllegalAccessException} is thrown if the constructors is invoked.
+ * </p>
*
- * <p>{@code ConstructorUtils} contains a workaround for this situation.
- * It will attempt to call {@code setAccessible} on this constructor.
- * If this call succeeds, then the method can be invoked as normal.
- * This call will only succeed when the application has sufficient security privileges.
- * If this call fails then a warning will be logged and the method may fail.</p>
+ * <p>
+ * {@code ConstructorUtils} contains a workaround for this situation. It will attempt to call {@code setAccessible} on this constructor. If this call succeeds,
+ * then the method can be invoked as normal. This call will only succeed when the application has sufficient security privileges. If this call fails then a
+ * warning will be logged and the method may fail.
+ * </p>
*/
public class ConstructorUtils {
/**
* Returns a constructor with single argument.
- * @param <T> the type of the constructor
- * @param klass the class to be constructed
+ *
+ * @param <T> the type of the constructor
+ * @param klass the class to be constructed
* @param parameterType The constructor parameter type
* @return null if matching accessible constructor can not be found.
* @see Class#getConstructor
* @see #getAccessibleConstructor(java.lang.reflect.Constructor)
*/
- public static <T> Constructor<T> getAccessibleConstructor(
- final Class<T> klass,
- final Class<?> parameterType) {
+ public static <T> Constructor<T> getAccessibleConstructor(final Class<T> klass, final Class<?> parameterType) {
final Class<?>[] parameterTypes = { parameterType };
return getAccessibleConstructor(klass, parameterTypes);
@@ -58,20 +60,18 @@ public class ConstructorUtils {
/**
* Returns a constructor given a class and signature.
- * @param <T> the type to be constructed
- * @param klass the class to be constructed
+ *
+ * @param <T> the type to be constructed
+ * @param klass the class to be constructed
* @param parameterTypes the parameter array
* @return null if matching accessible constructor can not be found
* @see Class#getConstructor
* @see #getAccessibleConstructor(java.lang.reflect.Constructor)
*/
- public static <T> Constructor<T> getAccessibleConstructor(
- final Class<T> klass,
- final Class<?>[] parameterTypes) {
+ public static <T> Constructor<T> getAccessibleConstructor(final Class<T> klass, final Class<?>[] parameterTypes) {
try {
- return getAccessibleConstructor(
- klass.getConstructor(parameterTypes));
+ return getAccessibleConstructor(klass.getConstructor(parameterTypes));
} catch (final NoSuchMethodException e) {
return null;
}
@@ -79,7 +79,8 @@ public class ConstructorUtils {
/**
* Returns accessible version of the given constructor.
- * @param <T> the type of the constructor
+ *
+ * @param <T> the type of the constructor
* @param ctor prototype constructor object.
* @return {@code null} if accessible constructor can not be found.
* @see SecurityManager
@@ -107,24 +108,22 @@ public class ConstructorUtils {
}
/**
- * <p>Find an accessible constructor with compatible parameters.
- * Compatible parameters mean that every method parameter is assignable from
- * the given parameters. In other words, it finds constructor that will take
- * the parameters given.</p>
+ * <p>
+ * Find an accessible constructor with compatible parameters. Compatible parameters mean that every method parameter is assignable from the given
+ * parameters. In other words, it finds constructor that will take the parameters given.
+ * </p>
*
- * <p>First it checks if there is constructor matching the exact signature.
- * If no such, all the constructors of the class are tested if their signatures
- * are assignment compatible with the parameter types.
- * The first matching constructor is returned.</p>
+ * <p>
+ * First it checks if there is constructor matching the exact signature. If no such, all the constructors of the class are tested if their signatures are
+ * assignment compatible with the parameter types. The first matching constructor is returned.
+ * </p>
*
- * @param <T> the type of the class to be inspected
- * @param clazz find constructor for this class
+ * @param <T> the type of the class to be inspected
+ * @param clazz find constructor for this class
* @param parameterTypes find method with compatible parameters
* @return a valid Constructor object. If there's no matching constructor, returns {@code null}.
*/
- private static <T> Constructor<T> getMatchingAccessibleConstructor(
- final Class<T> clazz,
- final Class<?>[] parameterTypes) {
+ private static <T> Constructor<T> getMatchingAccessibleConstructor(final Class<T> clazz, final Class<?>[] parameterTypes) {
// see if we can find the method directly
// most of the time this works and it's much faster
try {
@@ -165,10 +164,7 @@ public class ConstructorUtils {
if (ctorParamSize == paramSize) {
boolean match = true;
for (int n = 0; n < ctorParamSize; n++) {
- if (!MethodUtils
- .isAssignmentCompatible(
- ctorParams[n],
- parameterTypes[n])) {
+ if (!MethodUtils.isAssignmentCompatible(ctorParams[n], parameterTypes[n])) {
match = false;
break;
}
@@ -181,8 +177,8 @@ public class ConstructorUtils {
try {
ctor.setAccessible(true);
} catch (final SecurityException se) {
- /* Swallow SecurityException
- * TODO: Why?
+ /*
+ * Swallow SecurityException TODO: Why?
*/
}
// Class.getConstructors() actually returns constructors
@@ -197,60 +193,58 @@ public class ConstructorUtils {
}
/**
- * <p>Convenience method returning new instance of {@code klazz} using a single argument constructor.
- * The formal parameter type is inferred from the actual values of {@code arg}.
- * See {@link #invokeExactConstructor(Class, Object[], Class[])} for more details.</p>
+ * <p>
+ * Convenience method returning new instance of {@code klazz} using a single argument constructor. The formal parameter type is inferred from the actual
+ * values of {@code arg}. See {@link #invokeExactConstructor(Class, Object[], Class[])} for more details.
+ * </p>
*
- * <p>The signatures should be assignment compatible.</p>
+ * <p>
+ * The signatures should be assignment compatible.
+ * </p>
*
- * @param <T> the type of the object to be constructed
+ * @param <T> the type of the object to be constructed
* @param klass the class to be constructed.
- * @param arg the actual argument. May be null (this will result in calling the default constructor).
+ * @param arg the actual argument. May be null (this will result in calling the default constructor).
* @return new instance of {@code klazz}
*
- * @throws NoSuchMethodException If the constructor cannot be found
- * @throws IllegalAccessException If an error occurs accessing the constructor
+ * @throws NoSuchMethodException If the constructor cannot be found
+ * @throws IllegalAccessException If an error occurs accessing the constructor
* @throws InvocationTargetException If an error occurs invoking the constructor
- * @throws InstantiationException If an error occurs instantiating the class
+ * @throws InstantiationException If an error occurs instantiating the class
*
* @see #invokeConstructor(Class, Object[], Class[])
*/
public static <T> T invokeConstructor(final Class<T> klass, final Object arg)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException,
- InstantiationException {
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
final Object[] args = toArray(arg);
return invokeConstructor(klass, args);
}
/**
- * <p>Returns new instance of {@code klazz</code> created using the actual arguments <code>args}.
- * The formal parameter types are inferred from the actual values of {@code args}.
- * See {@link #invokeExactConstructor(Class, Object[], Class[])} for more details.</p>
+ * <p>
+ * Returns new instance of {@code klazz</code> created using the actual arguments <code>args}. The formal parameter types are inferred from the actual
+ * values of {@code args}. See {@link #invokeExactConstructor(Class, Object[], Class[])} for more details.
+ * </p>
*
- * <p>The signatures should be assignment compatible.</p>
+ * <p>
+ * The signatures should be assignment compatible.
+ * </p>
*
- * @param <T> the type of the object to be constructed
+ * @param <T> the type of the object to be constructed
* @param klass the class to be constructed.
- * @param args actual argument array. May be null (this will result in calling the default constructor).
+ * @param args actual argument array. May be null (this will result in calling the default constructor).
* @return new instance of {@code klazz}
*
- * @throws NoSuchMethodException If the constructor cannot be found
- * @throws IllegalAccessException If an error occurs accessing the constructor
+ * @throws NoSuchMethodException If the constructor cannot be found
+ * @throws IllegalAccessException If an error occurs accessing the constructor
* @throws InvocationTargetException If an error occurs invoking the constructor
- * @throws InstantiationException If an error occurs instantiating the class
+ * @throws InstantiationException If an error occurs instantiating the class
*
* @see #invokeConstructor(Class, Object[], Class[])
*/
public static <T> T invokeConstructor(final Class<T> klass, Object[] args)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException,
- InstantiationException {
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
if (null == args) {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
@@ -264,32 +258,28 @@ public class ConstructorUtils {
}
/**
- * <p>Returns new instance of {@code klazz} created using constructor
- * with signature {@code parameterTypes</code> and actual arguments <code>args}.</p>
+ * <p>
+ * Returns new instance of {@code klazz} created using constructor with signature {@code parameterTypes</code> and actual arguments <code>args}.
+ * </p>
*
- * <p>The signatures should be assignment compatible.</p>
+ * <p>
+ * The signatures should be assignment compatible.
+ * </p>
*
- * @param <T> the type of the object to be constructed
- * @param klass the class to be constructed.
- * @param args actual argument array. May be null (this will result in calling the default constructor).
+ * @param <T> the type of the object to be constructed
+ * @param klass the class to be constructed.
+ * @param args actual argument array. May be null (this will result in calling the default constructor).
* @param parameterTypes parameter types array
* @return new instance of {@code klazz}
*
- * @throws NoSuchMethodException if matching constructor cannot be found
- * @throws IllegalAccessException thrown on the constructor's invocation
+ * @throws NoSuchMethodException if matching constructor cannot be found
+ * @throws IllegalAccessException thrown on the constructor's invocation
* @throws InvocationTargetException thrown on the constructor's invocation
- * @throws InstantiationException thrown on the constructor's invocation
+ * @throws InstantiationException thrown on the constructor's invocation
* @see Constructor#newInstance
*/
- public static <T> T invokeConstructor(
- final Class<T> klass,
- Object[] args,
- Class<?>[] parameterTypes)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException,
- InstantiationException {
+ public static <T> T invokeConstructor(final Class<T> klass, Object[] args, Class<?>[] parameterTypes)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
if (parameterTypes == null) {
parameterTypes = BeanUtils.EMPTY_CLASS_ARRAY;
@@ -298,70 +288,66 @@ public class ConstructorUtils {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
}
- final Constructor<T> ctor =
- getMatchingAccessibleConstructor(klass, parameterTypes);
+ final Constructor<T> ctor = getMatchingAccessibleConstructor(klass, parameterTypes);
if (null == ctor) {
- throw new NoSuchMethodException(
- "No such accessible constructor on object: " + klass.getName());
+ throw new NoSuchMethodException("No such accessible constructor on object: " + klass.getName());
}
return ctor.newInstance(args);
}
/**
- * <p>Convenience method returning new instance of {@code klazz} using a single argument constructor.
- * The formal parameter type is inferred from the actual values of {@code arg}.
- * See {@link #invokeExactConstructor(Class, Object[], Class[])} for more details.</p>
+ * <p>
+ * Convenience method returning new instance of {@code klazz} using a single argument constructor. The formal parameter type is inferred from the actual
+ * values of {@code arg}. See {@link #invokeExactConstructor(Class, Object[], Class[])} for more details.
+ * </p>
*
- * <p>The signatures should match exactly.</p>
+ * <p>
+ * The signatures should match exactly.
+ * </p>
*
- * @param <T> the type of the object to be constructed
+ * @param <T> the type of the object to be constructed
* @param klass the class to be constructed.
- * @param arg the actual argument. May be null (this will result in calling the default constructor).
+ * @param arg the actual argument. May be null (this will result in calling the default constructor).
* @return new instance of {@code klazz}
*
- * @throws NoSuchMethodException If the constructor cannot be found
- * @throws IllegalAccessException If an error occurs accessing the constructor
+ * @throws NoSuchMethodException If the constructor cannot be found
+ * @throws IllegalAccessException If an error occurs accessing the constructor
* @throws InvocationTargetException If an error occurs invoking the constructor
- * @throws InstantiationException If an error occurs instantiating the class
+ * @throws InstantiationException If an error occurs instantiating the class
*
* @see #invokeExactConstructor(Class, Object[], Class[])
*/
public static <T> T invokeExactConstructor(final Class<T> klass, final Object arg)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException,
- InstantiationException {
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
final Object[] args = toArray(arg);
return invokeExactConstructor(klass, args);
}
/**
- * <p>Returns new instance of {@code klazz</code> created using the actual arguments <code>args}.
- * The formal parameter types are inferred from the actual values of {@code args}.
- * See {@link #invokeExactConstructor(Class, Object[], Class[])} for more details.</p>
+ * <p>
+ * Returns new instance of {@code klazz</code> created using the actual arguments <code>args}. The formal parameter types are inferred from the actual
+ * values of {@code args}. See {@link #invokeExactConstructor(Class, Object[], Class[])} for more details.
+ * </p>
*
- * <p>The signatures should match exactly.</p>
+ * <p>
+ * The signatures should match exactly.
+ * </p>
*
- * @param <T> the type of the object to be constructed
+ * @param <T> the type of the object to be constructed
* @param klass the class to be constructed.
- * @param args actual argument array. May be null (this will result in calling the default constructor).
+ * @param args actual argument array. May be null (this will result in calling the default constructor).
* @return new instance of {@code klazz}
*
- * @throws NoSuchMethodException If the constructor cannot be found
- * @throws IllegalAccessException If an error occurs accessing the constructor
+ * @throws NoSuchMethodException If the constructor cannot be found
+ * @throws IllegalAccessException If an error occurs accessing the constructor
* @throws InvocationTargetException If an error occurs invoking the constructor
- * @throws InstantiationException If an error occurs instantiating the class
+ * @throws InstantiationException If an error occurs instantiating the class
*
* @see #invokeExactConstructor(Class, Object[], Class[])
*/
public static <T> T invokeExactConstructor(final Class<T> klass, Object[] args)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException,
- InstantiationException {
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
if (null == args) {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
@@ -375,33 +361,28 @@ public class ConstructorUtils {
}
/**
- * <p>Returns new instance of {@code klazz} created using constructor
- * with signature {@code parameterTypes} and actual arguments
- * {@code args}.</p>
+ * <p>
+ * Returns new instance of {@code klazz} created using constructor with signature {@code parameterTypes} and actual arguments {@code args}.
+ * </p>
*
- * <p>The signatures should match exactly.</p>
+ * <p>
+ * The signatures should match exactly.
+ * </p>
*
- * @param <T> the type of the object to be constructed
- * @param klass the class to be constructed.
- * @param args actual argument array. May be null (this will result in calling the default constructor).
+ * @param <T> the type of the object to be constructed
+ * @param klass the class to be constructed.
+ * @param args actual argument array. May be null (this will result in calling the default constructor).
* @param parameterTypes parameter types array
* @return new instance of {@code klazz}
*
- * @throws NoSuchMethodException if matching constructor cannot be found
- * @throws IllegalAccessException thrown on the constructor's invocation
+ * @throws NoSuchMethodException if matching constructor cannot be found
+ * @throws IllegalAccessException thrown on the constructor's invocation
* @throws InvocationTargetException thrown on the constructor's invocation
- * @throws InstantiationException thrown on the constructor's invocation
+ * @throws InstantiationException thrown on the constructor's invocation
* @see Constructor#newInstance
*/
- public static <T> T invokeExactConstructor(
- final Class<T> klass,
- Object[] args,
- Class<?>[] parameterTypes)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException,
- InstantiationException {
+ public static <T> T invokeExactConstructor(final Class<T> klass, Object[] args, Class<?>[] parameterTypes)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
if (args == null) {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
@@ -413,8 +394,7 @@ public class ConstructorUtils {
final Constructor<T> ctor = getAccessibleConstructor(klass, parameterTypes);
if (null == ctor) {
- throw new NoSuchMethodException(
- "No such accessible constructor on object: " + klass.getName());
+ throw new NoSuchMethodException("No such accessible constructor on object: " + klass.getName());
}
return ctor.newInstance(args);
}
@@ -422,10 +402,10 @@ public class ConstructorUtils {
/**
* Delegates to {@link Array#newInstance(Class, int)}.
*
- * @param <T> Component type.
+ * @param <T> Component type.
*
* @param componentType See {@link Array#newInstance(Class, int)}.
- * @param length See {@link Array#newInstance(Class, int)}.
+ * @param length See {@link Array#newInstance(Class, int)}.
* @return See {@link Array#newInstance(Class, int)}.
*/
@SuppressWarnings("unchecked")
diff --git a/src/main/java/org/apache/commons/beanutils2/ContextClassLoaderLocal.java b/src/main/java/org/apache/commons/beanutils2/ContextClassLoaderLocal.java
index 584ddb06..69437ffd 100644
--- a/src/main/java/org/apache/commons/beanutils2/ContextClassLoaderLocal.java
+++ b/src/main/java/org/apache/commons/beanutils2/ContextClassLoaderLocal.java
@@ -21,33 +21,32 @@ import java.util.Map;
import java.util.WeakHashMap;
/**
- * An instance of this class represents a value that is provided per (thread)
- * context classloader.
+ * An instance of this class represents a value that is provided per (thread) context classloader.
*
- * <p>Occasionally it is necessary to store data in "global" variables
- * (including uses of the Singleton pattern). In applications which have only
- * a single classloader such data can simply be stored as "static" members on
- * some class. When multiple class loaders are involved, however, this approach
- * can fail; in particular, this doesn't work when the code may be run within a
- * servlet container or a j2ee container, and the class on which the static
- * member is defined is loaded via a "shared" classloader that is visible to all
- * components running within the container. This class provides a mechanism for
- * associating data with a ClassLoader instance, which ensures that when the
- * code runs in such a container each component gets its own copy of the
- * "global" variable rather than unexpectedly sharing a single copy of the
- * variable with other components that happen to be running in the same
- * container at the same time (eg servlets or EJBs.)</p>
+ * <p>
+ * Occasionally it is necessary to store data in "global" variables (including uses of the Singleton pattern). In applications which have only a single
+ * classloader such data can simply be stored as "static" members on some class. When multiple class loaders are involved, however, this approach can fail; in
+ * particular, this doesn't work when the code may be run within a servlet container or a j2ee container, and the class on which the static member is defined is
+ * loaded via a "shared" classloader that is visible to all components running within the container. This class provides a mechanism for associating data with a
+ * ClassLoader instance, which ensures that when the code runs in such a container each component gets its own copy of the "global" variable rather than
+ * unexpectedly sharing a single copy of the variable with other components that happen to be running in the same container at the same time (eg servlets or
+ * EJBs.)
+ * </p>
*
- * <p>This class is strongly patterned after the java.lang.ThreadLocal
- * class, which performs a similar task in allowing data to be associated
- * with a particular thread.</p>
+ * <p>
+ * This class is strongly patterned after the java.lang.ThreadLocal class, which performs a similar task in allowing data to be associated with a particular
+ * thread.
+ * </p>
*
- * <p>When code that uses this class is run as a "normal" application, ie
- * not within a container, the effect is identical to just using a static
- * member variable to store the data, because Thread.getContextClassLoader
- * always returns the same classloader (the system classloader).</p>
+ * <p>
+ * When code that uses this class is run as a "normal" application, ie not within a container, the effect is identical to just using a static member variable to
+ * store the data, because Thread.getContextClassLoader always returns the same classloader (the system classloader).
+ * </p>
+ *
+ * <p>
+ * Expected usage is as follows:
+ * </p>
*
- * <p>Expected usage is as follows:</p>
* <pre>
* <code>
* public class SomeClass {
@@ -65,38 +64,31 @@ import java.util.WeakHashMap;
* </code>
* </pre>
*
- * <p><strong>Note:</strong> This class takes some care to ensure that when
- * a component which uses this class is "undeployed" by a container the
- * component-specific classloader and all its associated classes (and their
- * static variables) are garbage-collected. Unfortunately there is one
- * scenario in which this does <em>not</em> work correctly and there
- * is unfortunately no known workaround other than ensuring that the
- * component (or its container) calls the "unset" method on this class for
- * each instance of this class when the component is undeployed. The problem
- * occurs if:
+ * <p>
+ * <strong>Note:</strong> This class takes some care to ensure that when a component which uses this class is "undeployed" by a container the component-specific
+ * classloader and all its associated classes (and their static variables) are garbage-collected. Unfortunately there is one scenario in which this does
+ * <em>not</em> work correctly and there is unfortunately no known workaround other than ensuring that the component (or its container) calls the "unset" method
+ * on this class for each instance of this class when the component is undeployed. The problem occurs if:
* <ul>
- * <li>the class containing a static instance of this class was loaded via
- * a shared classloader, and</li>
- * <li>the value stored in the instance is an object whose class was loaded
- * via the component-specific classloader (or any of the objects it refers
- * to were loaded via that classloader).</li>
+ * <li>the class containing a static instance of this class was loaded via a shared classloader, and</li>
+ * <li>the value stored in the instance is an object whose class was loaded via the component-specific classloader (or any of the objects it refers to were
+ * loaded via that classloader).</li>
* </ul>
- * <p>The result is that the map managed by this object still contains a strong
- * reference to the stored object, which contains a strong reference to the
- * classloader that loaded it, meaning that although the container has
- * "undeployed" the component the component-specific classloader and all the
- * related classes and static variables cannot be garbage-collected. This is
- * not expected to be an issue with the commons-beanutils library as the only
- * classes which use this class are BeanUtilsBean and ConvertUtilsBean and
- * there is no obvious reason for a user of the BeanUtils library to subclass
- * either of those classes.</p>
+ * <p>
+ * The result is that the map managed by this object still contains a strong reference to the stored object, which contains a strong reference to the
+ * classloader that loaded it, meaning that although the container has "undeployed" the component the component-specific classloader and all the related classes
+ * and static variables cannot be garbage-collected. This is not expected to be an issue with the commons-beanutils library as the only classes which use this
+ * class are BeanUtilsBean and ConvertUtilsBean and there is no obvious reason for a user of the BeanUtils library to subclass either of those classes.
+ * </p>
*
- * <p><strong>Note:</strong> A WeakHashMap bug in several 1.3 JVMs results in
- * a memory leak for those JVMs.</p>
+ * <p>
+ * <strong>Note:</strong> A WeakHashMap bug in several 1.3 JVMs results in a memory leak for those JVMs.
+ * </p>
*
- * <p><strong>Note:</strong> Of course, all of this would be unnecessary if
- * containers required each component to load the full set of classes it
- * needs, that is, avoided providing classes loaded via a "shared" classloader.</p>
+ * <p>
+ * <strong>Note:</strong> Of course, all of this would be unnecessary if containers required each component to load the full set of classes it needs, that is,
+ * avoided providing classes loaded via a "shared" classloader.
+ * </p>
*
* @param <T> the type of data stored in an instance
* @see Thread#getContextClassLoader
@@ -113,9 +105,9 @@ public class ContextClassLoaderLocal<T> {
}
/**
- * Gets the instance which provides the functionality for {@link BeanUtils}.
- * This is a pseudo-singleton - an single instance is provided per (thread) context classloader.
- * This mechanism provides isolation for web apps deployed in the same container.
+ * Gets the instance which provides the functionality for {@link BeanUtils}. This is a pseudo-singleton - an single instance is provided per (thread)
+ * context classloader. This mechanism provides isolation for web apps deployed in the same container.
+ *
* @return the object currently associated with the context-classloader of the current thread.
*/
public synchronized T get() {
@@ -139,26 +131,22 @@ public class ContextClassLoaderLocal<T> {
}
- } catch (final SecurityException e) { /* SWALLOW - should we log this? */ }
+ } catch (final SecurityException e) {
+ /* SWALLOW - should we log this? */ }
// if none or exception, return the globalValue
if (!globalValueInitialized) {
globalValue = initialValue();
globalValueInitialized = true;
- }//else already set
+ } // else already set
return globalValue;
}
/**
- * Returns the initial value for this ContextClassLoaderLocal
- * variable. This method will be called once per Context ClassLoader for
- * each ContextClassLoaderLocal, the first time it is accessed
- * with get or set. If the programmer desires ContextClassLoaderLocal variables
- * to be initialized to some value other than null, ContextClassLoaderLocal must
- * be subclassed, and this method overridden. Typically, an anonymous
- * inner class will be used. Typical implementations of initialValue
- * will call an appropriate constructor and return the newly constructed
- * object.
+ * Returns the initial value for this ContextClassLoaderLocal variable. This method will be called once per Context ClassLoader for each
+ * ContextClassLoaderLocal, the first time it is accessed with get or set. If the programmer desires ContextClassLoaderLocal variables to be initialized to
+ * some value other than null, ContextClassLoaderLocal must be subclassed, and this method overridden. Typically, an anonymous inner class will be used.
+ * Typical implementations of initialValue will call an appropriate constructor and return the newly constructed object.
*
* @return a new Object to be used as an initial value for this ContextClassLoaderLocal
*/
@@ -167,8 +155,7 @@ public class ContextClassLoaderLocal<T> {
}
/**
- * Sets the value - a value is provided per (thread) context classloader.
- * This mechanism provides isolation for web apps deployed in the same container.
+ * Sets the value - a value is provided per (thread) context classloader. This mechanism provides isolation for web apps deployed in the same container.
*
* @param value the object to be associated with the entrant thread's context classloader
*/
@@ -186,7 +173,8 @@ public class ContextClassLoaderLocal<T> {
return;
}
- } catch (final SecurityException e) { /* SWALLOW - should we log this? */ }
+ } catch (final SecurityException e) {
+ /* SWALLOW - should we log this? */ }
// if in doubt, set the global value
globalValue = value;
@@ -202,14 +190,16 @@ public class ContextClassLoaderLocal<T> {
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
unset(contextClassLoader);
- } catch (final SecurityException e) { /* SWALLOW - should we log this? */ }
+ } catch (final SecurityException e) {
+ /* SWALLOW - should we log this? */ }
}
/**
* Unsets the value associated with the given classloader
+ *
* @param classLoader The classloader to <em>unset</em> for
*/
public synchronized void unset(final ClassLoader classLoader) {
valueByClassLoader.remove(classLoader);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/commons/beanutils2/ConversionException.java b/src/main/java/org/apache/commons/beanutils2/ConversionException.java
index 5dc808f2..8c2b7824 100644
--- a/src/main/java/org/apache/commons/beanutils2/ConversionException.java
+++ b/src/main/java/org/apache/commons/beanutils2/ConversionException.java
@@ -18,8 +18,7 @@
package org.apache.commons.beanutils2;
/**
- * A <strong>ConversionException</strong> indicates that a call to
- * {@code Converter.convert()} has failed to complete successfully.
+ * A <strong>ConversionException</strong> indicates that a call to {@code Converter.convert()} has failed to complete successfully.
*
* @since 1.3
*/
@@ -52,7 +51,7 @@ public class ConversionException extends RuntimeException {
* Constructs a new exception with the specified message and root cause.
*
* @param message The message describing this exception
- * @param cause The root cause of this exception
+ * @param cause The root cause of this exception
*/
public ConversionException(final String message, final Throwable cause) {
super(message, cause);
diff --git a/src/main/java/org/apache/commons/beanutils2/ConvertUtils.java b/src/main/java/org/apache/commons/beanutils2/ConvertUtils.java
index 5704e9cd..b5df4683 100644
--- a/src/main/java/org/apache/commons/beanutils2/ConvertUtils.java
+++ b/src/main/java/org/apache/commons/beanutils2/ConvertUtils.java
@@ -18,20 +18,26 @@
package org.apache.commons.beanutils2;
/**
- * <p>Utility methods for converting String scalar values to objects of the
- * specified Class, String arrays to arrays of the specified Class.</p>
+ * <p>
+ * Utility methods for converting String scalar values to objects of the specified Class, String arrays to arrays of the specified Class.
+ * </p>
*
- * <p>For more details, see {@code ConvertUtilsBean} which provides the
- * implementations for these methods.</p>
+ * <p>
+ * For more details, see {@code ConvertUtilsBean} which provides the implementations for these methods.
+ * </p>
*
* @see ConvertUtilsBean
*/
public class ConvertUtils {
/**
- * <p>Converts the specified value into a String.</p>
+ * <p>
+ * Converts the specified value into a String.
+ * </p>
*
- * <p>For more details see {@code ConvertUtilsBean}.</p>
+ * <p>
+ * For more details see {@code ConvertUtilsBean}.
+ * </p>
*
* @param value Value to be converted (may be null)
* @return The converted String value or null if value is null
@@ -43,10 +49,11 @@ public class ConvertUtils {
}
/**
- * <p>Converts the value to an object of the specified class (if
- * possible).</p>
+ * <p>
+ * Converts the value to an object of the specified class (if possible).
+ * </p>
*
- * @param value Value to be converted (may be null)
+ * @param value Value to be converted (may be null)
* @param targetType Class of the value to be converted to (must not be null)
* @return The converted value
*
@@ -57,10 +64,13 @@ public class ConvertUtils {
}
/**
- * <p>Converts the specified value to an object of the specified class (if
- * possible). Otherwise, return a String representation of the value.</p>
+ * <p>
+ * Converts the specified value to an object of the specified class (if possible). Otherwise, return a String representation of the value.
+ * </p>
*
- * <p>For more details see {@code ConvertUtilsBean}.</p>
+ * <p>
+ * For more details see {@code ConvertUtilsBean}.
+ * </p>
*
* @param value Value to be converted (may be null)
* @param clazz Java class to be converted to (must not be null)
@@ -73,13 +83,16 @@ public class ConvertUtils {
}
/**
- * <p>Convert an array of specified values to an array of objects of the
- * specified class (if possible).</p>
+ * <p>
+ * Convert an array of specified values to an array of objects of the specified class (if possible).
+ * </p>
*
- * <p>For more details see {@code ConvertUtilsBean}.</p>
+ * <p>
+ * For more details see {@code ConvertUtilsBean}.
+ * </p>
*
* @param values Array of values to be converted
- * @param clazz Java array or element class to be converted to (must not be null)
+ * @param clazz Java array or element class to be converted to (must not be null)
* @return The converted value
*
* @see ConvertUtilsBean#convert(String[], Class)
@@ -89,10 +102,13 @@ public class ConvertUtils {
}
/**
- * <p>Remove all registered {@link Converter}s, and re-establish the
- * standard Converters.</p>
+ * <p>
+ * Remove all registered {@link Converter}s, and re-establish the standard Converters.
+ * </p>
*
- * <p>For more details see {@code ConvertUtilsBean}.</p>
+ * <p>
+ * For more details see {@code ConvertUtilsBean}.
+ * </p>
*
* @see ConvertUtilsBean#deregister()
*/
@@ -101,10 +117,13 @@ public class ConvertUtils {
}
/**
- * <p>Remove any registered {@link Converter} for the specified destination
- * {@code Class}.</p>
+ * <p>
+ * Remove any registered {@link Converter} for the specified destination {@code Class}.
+ * </p>
*
- * <p>For more details see {@code ConvertUtilsBean}.</p>
+ * <p>
+ * For more details see {@code ConvertUtilsBean}.
+ * </p>
*
* @param clazz Class for which to remove a registered Converter
* @see ConvertUtilsBean#deregister(Class)
@@ -114,11 +133,10 @@ public class ConvertUtils {
}
/**
- * Look up and return any registered {@link Converter} for the specified
- * source and destination class; if there is no registered Converter,
- * return {@code null}.
+ * Look up and return any registered {@link Converter} for the specified source and destination class; if there is no registered Converter, return
+ * {@code null}.
*
- * @param <T> The converter type.
+ * @param <T> The converter type.
* @param sourceType Class of the value being converted
* @param targetType Class of the value to be converted to
* @return The registered {@link Converter} or {@code null} if not found
@@ -128,13 +146,15 @@ public class ConvertUtils {
}
/**
- * <p>Look up and return any registered {@link Converter} for the specified
- * destination class; if there is no registered Converter, return
- * {@code null}.</p>
+ * <p>
+ * Look up and return any registered {@link Converter} for the specified destination class; if there is no registered Converter, return {@code null}.
+ * </p>
*
- * <p>For more details see {@code ConvertUtilsBean}.</p>
+ * <p>
+ * For more details see {@code ConvertUtilsBean}.
+ * </p>
*
- * @param <T> The converter type.
+ * @param <T> The converter type.
* @param clazz Class for which to return a registered Converter
* @return The registered {@link Converter} or {@code null} if not found
* @see ConvertUtilsBean#lookup(Class)
@@ -144,11 +164,10 @@ public class ConvertUtils {
}
/**
- * Change primitive Class types to the associated wrapper class. This is
- * useful for concrete converter implementations which typically treat
- * primitive types like their corresponding wrapper types.
+ * Change primitive Class types to the associated wrapper class. This is useful for concrete converter implementations which typically treat primitive types
+ * like their corresponding wrapper types.
*
- * @param <T> The type to be checked.
+ * @param <T> The type to be checked.
* @param type The class type to check.
* @return The converted type.
* @since 1.9
@@ -189,15 +208,17 @@ public class ConvertUtils {
}
/**
- * <p>Register a custom {@link Converter} for the specified destination
- * {@code Class}, replacing any previously registered Converter.</p>
+ * <p>
+ * Register a custom {@link Converter} for the specified destination {@code Class}, replacing any previously registered Converter.
+ * </p>
*
- * <p>For more details see {@code ConvertUtilsBean}.</p>
+ * <p>
+ * For more details see {@code ConvertUtilsBean}.
+ * </p>
*
- * @param <T> The converter type.
+ * @param <T> The converter type.
* @param converter Converter to be registered
- * @param clazz Destination class for conversions performed by this
- * Converter
+ * @param clazz Destination class for conversions performed by this Converter
* @see ConvertUtilsBean#register(Converter, Class)
*/
public static <T> void register(final Converter<T> converter, final Class<T> clazz) {
diff --git a/src/main/java/org/apache/commons/beanutils2/ConvertUtilsBean.java b/src/main/java/org/apache/commons/beanutils2/ConvertUtilsBean.java
index 5a569a72..770d9510 100644
--- a/src/main/java/org/apache/commons/beanutils2/ConvertUtilsBean.java
+++ b/src/main/java/org/apache/commons/beanutils2/ConvertUtilsBean.java
@@ -98,24 +98,25 @@ import org.apache.commons.logging.LogFactory;
/**
* TODO DOCS
- * <p>2.0</p>
+ * <p>
+ * 2.0
+ * </p>
*
- * {@link ConvertUtilsBean} implementation that delegates {@code convert()}
- * methods to the new {@link ConvertUtilsBean#convert(Object, Class)} method.
+ * {@link ConvertUtilsBean} implementation that delegates {@code convert()} methods to the new {@link ConvertUtilsBean#convert(Object, Class)} method.
*
* <p>
- * To configure this implementation for the current context ClassLoader invoke
- * {@code BeanUtilsBean.setInstance(new BeanUtilsBean2());}
+ * To configure this implementation for the current context ClassLoader invoke {@code BeanUtilsBean.setInstance(new BeanUtilsBean2());}
* </p>
*
- * <p>Pre-2.0</p>
+ * <p>
+ * Pre-2.0
+ * </p>
*
- * <p>Utility methods for converting String scalar values to objects of the
- * specified Class, String arrays to arrays of the specified Class. The
- * actual {@link Converter} instance to be used can be registered for each
- * possible destination Class. Unless you override them, standard
- * {@link Converter} instances are provided for all of the following
- * destination Classes:</p>
+ * <p>
+ * Utility methods for converting String scalar values to objects of the specified Class, String arrays to arrays of the specified Class. The actual
+ * {@link Converter} instance to be used can be registered for each possible destination Class. Unless you override them, standard {@link Converter} instances
+ * are provided for all of the following destination Classes:
+ * </p>
* <ul>
* <li>java.lang.BigDecimal (no default value)</li>
* <li>java.lang.BigInteger (no default value)</li>
@@ -159,44 +160,35 @@ import org.apache.commons.logging.LogFactory;
* <li>java.time.ZoneOffset (no default value)</li>
* </ul>
*
- * <p>For backwards compatibility, the standard Converters for primitive
- * types (and the corresponding wrapper classes) return a defined
- * default value when a conversion error occurs. If you prefer to have a
- * {@link ConversionException} thrown instead, replace the standard Converter
- * instances with instances created with the zero-arguments constructor. For
- * example, to cause the Converters for integers to throw an exception on
- * conversion errors, you could do this:</p>
+ * <p>
+ * For backwards compatibility, the standard Converters for primitive types (and the corresponding wrapper classes) return a defined default value when a
+ * conversion error occurs. If you prefer to have a {@link ConversionException} thrown instead, replace the standard Converter instances with instances created
+ * with the zero-arguments constructor. For example, to cause the Converters for integers to throw an exception on conversion errors, you could do this:
+ * </p>
+ *
* <pre>
- * // No-args constructor gets the version that throws exceptions
- * Converter myConverter =
- * new org.apache.commons.beanutils2.converter.IntegerConverter();
- * ConvertUtils.register(myConverter, Integer.TYPE); // Native type
- * ConvertUtils.register(myConverter, Integer.class); // Wrapper class
+ * // No-args constructor gets the version that throws exceptions
+ * Converter myConverter = new org.apache.commons.beanutils2.converter.IntegerConverter();
+ * ConvertUtils.register(myConverter, Integer.TYPE); // Native type
+ * ConvertUtils.register(myConverter, Integer.class); // Wrapper class
* </pre>
*
* <p>
- * Converters generally treat null input as if it were invalid
- * input, that is, they return their default value if one was specified when the
- * converter was constructed, and throw an exception otherwise. If you prefer
- * nulls to be preserved for converters that are converting to objects (not
- * primitives) then register a converter as above, passing a default value of
- * null to the converter constructor (and of course registering that converter
- * only for the .class target).
+ * Converters generally treat null input as if it were invalid input, that is, they return their default value if one was specified when the converter was
+ * constructed, and throw an exception otherwise. If you prefer nulls to be preserved for converters that are converting to objects (not primitives) then
+ * register a converter as above, passing a default value of null to the converter constructor (and of course registering that converter only for the .class
+ * target).
* </p>
*
* <p>
- * When a converter is listed above as having no default value, then that
- * converter will throw an exception when passed null or an invalid value
- * as its input. In particular, by default the BigInteger and BigDecimal
- * converters have no default (and are therefore somewhat inconsistent
- * with the other numerical converters which all have zero as their default).
+ * When a converter is listed above as having no default value, then that converter will throw an exception when passed null or an invalid value as its input.
+ * In particular, by default the BigInteger and BigDecimal converters have no default (and are therefore somewhat inconsistent with the other numerical
+ * converters which all have zero as their default).
* </p>
*
* <p>
- * Converters that generate <em>arrays</em> of each of the primitive types are
- * also automatically configured (including String[]). When passed null
- * or invalid input, these return an empty array (not null). See class
- * AbstractArrayConverter for the supported input formats for these converters.
+ * Converters that generate <em>arrays</em> of each of the primitive types are also automatically configured (including String[]). When passed null or invalid
+ * input, these return an empty array (not null). See class AbstractArrayConverter for the supported input formats for these converters.
* </p>
*
* @since 1.7
@@ -213,6 +205,7 @@ public class ConvertUtilsBean {
/**
* Gets singleton instance
+ *
* @return The singleton instance
*/
protected static ConvertUtilsBean getInstance() {
@@ -220,8 +213,7 @@ public class ConvertUtilsBean {
}
/**
- * The set of {@link Converter}s that can be used to convert Strings
- * into objects of a specified Class, keyed by the destination Class.
+ * The set of {@link Converter}s that can be used to convert Strings into objects of a specified Class, keyed by the destination Class.
*/
private final WeakFastHashMap<Class<?>, Converter<?>> converters = new WeakFastHashMap<>();
@@ -233,8 +225,7 @@ public class ConvertUtilsBean {
}
/**
- * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)}
- * method.
+ * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} method.
*
* @param value Value to be converted (may be null)
* @return The converted String value or null if value is null
@@ -246,12 +237,11 @@ public class ConvertUtilsBean {
}
/**
- * Converts the value to an object of the specified class (if
- * possible). If no converter for the desired target type is registered,
- * the passed in object is returned unchanged.
+ * Converts the value to an object of the specified class (if possible). If no converter for the desired target type is registered, the passed in object is
+ * returned unchanged.
*
- * @param <T> The Class type.
- * @param value Value to be converted (may be null)
+ * @param <T> The Class type.
+ * @param value Value to be converted (may be null)
* @param targetType Class of the value to be converted to (must not be null)
* @return The converted value
*
@@ -265,8 +255,7 @@ public class ConvertUtilsBean {
if (nullValue) {
LOG.debug("Convert null value to type '" + targetType.getName() + "'");
} else {
- LOG.debug("Convert type '" + sourceType.getName() + "' value '" + value + "' to type '"
- + targetType.getName() + "'");
+ LOG.debug("Convert type '" + sourceType.getName() + "' value '" + value + "' to type '" + targetType.getName() + "'");
}
}
@@ -301,8 +290,7 @@ public class ConvertUtilsBean {
}
/**
- * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)}
- * method.
+ * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} method.
*
* @param value Value to be converted (may be null)
* @param clazz Java class to be converted to (must not be null)
@@ -315,8 +303,7 @@ public class ConvertUtilsBean {
}
/**
- * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)}
- * method.
+ * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} method.
*
* @param value Array of values to be converted
* @param clazz Java array or element class to be converted to (must not be null)
@@ -340,8 +327,7 @@ public class ConvertUtilsBean {
}
/**
- * Deregisters all registered {@link Converter}s, and re-establish the
- * standard Converters.
+ * Deregisters all registered {@link Converter}s, and re-establish the standard Converters.
*/
public void deregister() {
@@ -356,8 +342,7 @@ public class ConvertUtilsBean {
}
/**
- * Remove any registered {@link Converter} for the specified destination
- * {@code Class}.
+ * Remove any registered {@link Converter} for the specified destination {@code Class}.
*
* @param clazz Class for which to remove a registered Converter
*/
@@ -366,11 +351,10 @@ public class ConvertUtilsBean {
}
/**
- * Looks up and return any registered {@link Converter} for the specified
- * source and destination class; if there is no registered Converter,
- * return {@code null}.
+ * Looks up and return any registered {@link Converter} for the specified source and destination class; if there is no registered Converter, return
+ * {@code null}.
*
- * @param <T> The converter type.
+ * @param <T> The converter type.
* @param sourceType Class of the value being converted
* @param targetType Class of the value to be converted to
* @return The registered {@link Converter} or {@code null} if not found
@@ -384,8 +368,7 @@ public class ConvertUtilsBean {
// Convert --> String
if (targetType == String.class) {
converter = lookup(sourceType);
- if (converter == null && (sourceType.isArray() ||
- Collection.class.isAssignableFrom(sourceType))) {
+ if (converter == null && (sourceType.isArray() || Collection.class.isAssignableFrom(sourceType))) {
converter = lookup(String[].class);
}
if (converter == null) {
@@ -410,11 +393,9 @@ public class ConvertUtilsBean {
}
/**
- * Looks up and return any registered {@link Converter} for the specified
- * destination class; if there is no registered Converter, return
- * {@code null}.
+ * Looks up and return any registered {@link Converter} for the specified destination class; if there is no registered Converter, return {@code null}.
*
- * @param <T> The converter type.
+ * @param <T> The converter type.
* @param clazz Class for which to return a registered Converter
* @return The registered {@link Converter} or {@code null} if not found
*/
@@ -426,17 +407,14 @@ public class ConvertUtilsBean {
/**
* Registers the provided converters with the specified defaults.
*
- * @param throwException {@code true} if the converters should
- * throw an exception when a conversion error occurs, otherwise
- * {@code false} if a default value should be used.
- * @param defaultNull {@code true}if the <em>standard</em> converters
- * (see {@link ConvertUtilsBean#registerStandard(boolean, boolean)})
- * should use a default value of {@code null</code>, otherwise <code>false}.
+ * @param throwException {@code true} if the converters should throw an exception when a conversion error occurs, otherwise {@code false} if a default
+ * value should be used.
+ * @param defaultNull {@code true}if the <em>standard</em> converters (see {@link ConvertUtilsBean#registerStandard(boolean, boolean)}) should use a
+ * default value of {@code null</code>, otherwise <code>false}.
* N.B. This values is ignored if {@code throwException</code> is <code>true}
* @param defaultArraySize The size of the default array value for array converters
- * (N.B. This values is ignored if {@code throwException</code> is <code>true}).
- * Specifying a value less than zero causes a {@code null} value to be used for
- * the default.
+ * (N.B. This values is ignored if {@code throwException</code> is <code>true}). Specifying a value less than zero causes a {@code null} value to be used
+ * for the default.
*/
public void register(final boolean throwException, final boolean defaultNull, final int defaultArraySize) {
registerPrimitives(throwException);
@@ -451,29 +429,26 @@ public class ConvertUtilsBean {
}
/**
- * Registers a custom {@link Converter} for the specified destination
- * {@code Class}, replacing any previously registered Converter.
+ * Registers a custom {@link Converter} for the specified destination {@code Class}, replacing any previously registered Converter.
*
* @param converter Converter to be registered
- * @param clazz Destination class for conversions performed by this
- * Converter
+ * @param clazz Destination class for conversions performed by this Converter
*/
public void register(final Converter converter, final Class<?> clazz) {
converters.put(clazz, converter);
}
/**
- * Registers a new ArrayConverter with the specified element delegate converter
- * that returns a default array of the specified size in the event of conversion errors.
+ * Registers a new ArrayConverter with the specified element delegate converter that returns a default array of the specified size in the event of
+ * conversion errors.
*
- * @param componentType The component type of the array
+ * @param componentType The component type of the array
* @param componentConverter The converter to delegate to for the array elements
- * @param throwException Whether a conversion exception should be thrown or a default
- * value used in the event of a conversion error
- * @param defaultArraySize The size of the default array
+ * @param throwException Whether a conversion exception should be thrown or a default value used in the event of a conversion error
+ * @param defaultArraySize The size of the default array
*/
- private <T> void registerArrayConverter(final Class<T> componentType, final Converter<T> componentConverter,
- final boolean throwException, final int defaultArraySize) {
+ private <T> void registerArrayConverter(final Class<T> componentType, final Converter<T> componentConverter, final boolean throwException,
+ final int defaultArraySize) {
final Class<T[]> arrayType = (Class<T[]>) Array.newInstance(componentType, 0).getClass();
final Converter<T[]> arrayConverter;
if (throwException) {
@@ -487,13 +462,11 @@ public class ConvertUtilsBean {
/**
* Registers array converters.
*
- * @param throwException {@code true} if the converters should
- * throw an exception when a conversion error occurs, otherwise
- * {@code false} if a default value should be used.
- * @param defaultArraySize The size of the default array value for array converters
- * (N.B. This values is ignored if {@code throwException</code> is <code>true}).
- * Specifying a value less than zero causes a {@code null} value to be used for
- * the default.
+ * @param throwException {@code true} if the converters should throw an exception when a conversion error occurs, otherwise {@code false} if a default
+ * value should be used.
+ * @param defaultArraySize The size of the default array value for array converters (N.B. This values is ignored if
+ * {@code throwException</code> is <code>true}). Specifying a value less than zero causes a {@code null} value to be used for the
+ * default.
*/
private void registerArrays(final boolean throwException, final int defaultArraySize) {
// @formatter:off
@@ -561,35 +534,35 @@ public class ConvertUtilsBean {
* </p>
* This method registers the following converters:
* <ul>
- * <li>{@code Class.class} - {@link ClassConverter}</li>
- * <li>{@code Enum.class} - {@link EnumConverter}</li>
- * <li>{@code java.util.Date.class} - {@link DateConverter}</li>
- * <li>{@code java.util.Calendar.class} - {@link CalendarConverter}</li>
- * <li>{@code File.class} - {@link FileConverter}</li>
- * <li>{@code Path.class} - {@link PathConverter}</li>
- * <li>{@code java.sql.Date.class} - {@link SqlDateConverter}</li>
- * <li>{@code java.sql.Time.class} - {@link SqlTimeConverter}</li>
- * <li>{@code java.sql.Timestamp.class} - {@link SqlTimestampConverter}</li>
- * <li>{@code URL.class} - {@link URLConverter}</li>
- * <li>{@code URI.class} - {@link URIConverter}</li>
- * <li>{@code UUID.class} - {@link UUIDConverter}</li>
- * <li>{@code LocalDate.class} - {@link LocalDateConverter}</li>
- * <li>{@code LocalDateTime.class} - {@link LocalDateTimeConverter}</li>
- * <li>{@code LocalTime.class} - {@link LocalTimeConverter}</li>
- * <li>{@code OffsetDateTime.class} - {@link OffsetDateTimeConverter}</li>
- * <li>{@code OffsetTime.class} - {@link OffsetTimeConverter}</li>
- * <li>{@code ZonedDateTime.class} - {@link ZonedDateTimeConverter}</li>
- * <li>{@code Duration.class} - {@link DurationConverter}</li>
- * <li>{@code MonthDay.class} - {@link MonthDayConverter}</li>
- * <li>{@code Period.class} - {@link PeriodConverter}</li>
- * <li>{@code Year.class} - {@link YearConverter}</li>
- * <li>{@code YearMonth.class} - {@link YearMonthConverter}</li>
- * <li>{@code ZoneId.class} - {@link ZoneIdConverter}</li>
- * <li>{@code ZoneOffset.class} - {@link ZoneOffsetConverter}</li>
+ * <li>{@code Class.class} - {@link ClassConverter}</li>
+ * <li>{@code Enum.class} - {@link EnumConverter}</li>
+ * <li>{@code java.util.Date.class} - {@link DateConverter}</li>
+ * <li>{@code java.util.Calendar.class} - {@link CalendarConverter}</li>
+ * <li>{@code File.class} - {@link FileConverter}</li>
+ * <li>{@code Path.class} - {@link PathConverter}</li>
+ * <li>{@code java.sql.Date.class} - {@link SqlDateConverter}</li>
+ * <li>{@code java.sql.Time.class} - {@link SqlTimeConverter}</li>
+ * <li>{@code java.sql.Timestamp.class} - {@link SqlTimestampConverter}</li>
+ * <li>{@code URL.class} - {@link URLConverter}</li>
+ * <li>{@code URI.class} - {@link URIConverter}</li>
+ * <li>{@code UUID.class} - {@link UUIDConverter}</li>
+ * <li>{@code LocalDate.class} - {@link LocalDateConverter}</li>
+ * <li>{@code LocalDateTime.class} - {@link LocalDateTimeConverter}</li>
+ * <li>{@code LocalTime.class} - {@link LocalTimeConverter}</li>
+ * <li>{@code OffsetDateTime.class} - {@link OffsetDateTimeConverter}</li>
+ * <li>{@code OffsetTime.class} - {@link OffsetTimeConverter}</li>
+ * <li>{@code ZonedDateTime.class} - {@link ZonedDateTimeConverter}</li>
+ * <li>{@code Duration.class} - {@link DurationConverter}</li>
+ * <li>{@code MonthDay.class} - {@link MonthDayConverter}</li>
+ * <li>{@code Period.class} - {@link PeriodConverter}</li>
+ * <li>{@code Year.class} - {@link YearConverter}</li>
+ * <li>{@code YearMonth.class} - {@link YearMonthConverter}</li>
+ * <li>{@code ZoneId.class} - {@link ZoneIdConverter}</li>
+ * <li>{@code ZoneOffset.class} - {@link ZoneOffsetConverter}</li>
* </ul>
- * @param throwException {@code true} if the converters should
- * throw an exception when a conversion error occurs, otherwise <code>
- * {@code false} if a default value should be used.
+ *
+ * @param throwException {@code true} if the converters should throw an exception when a conversion error occurs, otherwise <code> {@code false} if a
+ * default value should be used.
*/
private void registerOther(final boolean throwException) {
// @formatter:off
@@ -632,28 +605,28 @@ public class ConvertUtilsBean {
* </p>
* This method registers the following converters:
* <ul>
- * <li>{@code Boolean.TYPE} - {@link BooleanConverter}</li>
- * <li>{@code Byte.TYPE} - {@link ByteConverter}</li>
- * <li>{@code Character.TYPE} - {@link CharacterConverter}</li>
- * <li>{@code Double.TYPE} - {@link DoubleConverter}</li>
- * <li>{@code Float.TYPE} - {@link FloatConverter}</li>
- * <li>{@code Integer.TYPE} - {@link IntegerConverter}</li>
- * <li>{@code Long.TYPE} - {@link LongConverter}</li>
- * <li>{@code Short.TYPE} - {@link ShortConverter}</li>
+ * <li>{@code Boolean.TYPE} - {@link BooleanConverter}</li>
+ * <li>{@code Byte.TYPE} - {@link ByteConverter}</li>
+ * <li>{@code Character.TYPE} - {@link CharacterConverter}</li>
+ * <li>{@code Double.TYPE} - {@link DoubleConverter}</li>
+ * <li>{@code Float.TYPE} - {@link FloatConverter}</li>
+ * <li>{@code Integer.TYPE} - {@link IntegerConverter}</li>
+ * <li>{@code Long.TYPE} - {@link LongConverter}</li>
+ * <li>{@code Short.TYPE} - {@link ShortConverter}</li>
* </ul>
- * @param throwException {@code true} if the converters should
- * throw an exception when a conversion error occurs, otherwise <code>
- * {@code false} if a default value should be used.
+ *
+ * @param throwException {@code true} if the converters should throw an exception when a conversion error occurs, otherwise <code> {@code false} if a
+ * default value should be used.
*/
private void registerPrimitives(final boolean throwException) {
- register(Boolean.TYPE, throwException ? new BooleanConverter() : new BooleanConverter(Boolean.FALSE));
- register(Byte.TYPE, throwException ? new ByteConverter() : new ByteConverter(ZERO));
- register(Character.TYPE, throwException ? new CharacterConverter() : new CharacterConverter(SPACE));
- register(Double.TYPE, throwException ? new DoubleConverter() : new DoubleConverter(ZERO));
- register(Float.TYPE, throwException ? new FloatConverter() : new FloatConverter(ZERO));
- register(Integer.TYPE, throwException ? new IntegerConverter() : new IntegerConverter(ZERO));
- register(Long.TYPE, throwException ? new LongConverter() : new LongConverter(ZERO));
- register(Short.TYPE, throwException ? new ShortConverter() : new ShortConverter(ZERO));
+ register(Boolean.TYPE, throwException ? new BooleanConverter() : new BooleanConverter(Boolean.FALSE));
+ register(Byte.TYPE, throwException ? new ByteConverter() : new ByteConverter(ZERO));
+ register(Character.TYPE, throwException ? new CharacterConverter() : new CharacterConverter(SPACE));
+ register(Double.TYPE, throwException ? new DoubleConverter() : new DoubleConverter(ZERO));
+ register(Float.TYPE, throwException ? new FloatConverter() : new FloatConverter(ZERO));
+ register(Integer.TYPE, throwException ? new IntegerConverter() : new IntegerConverter(ZERO));
+ register(Long.TYPE, throwException ? new LongConverter() : new LongConverter(ZERO));
+ register(Short.TYPE, throwException ? new ShortConverter() : new ShortConverter(ZERO));
}
/**
@@ -661,21 +634,21 @@ public class ConvertUtilsBean {
* </p>
* This method registers the following converters:
* <ul>
- * <li>{@code BigDecimal.class} - {@link BigDecimalConverter}</li>
- * <li>{@code BigInteger.class} - {@link BigIntegerConverter}</li>
- * <li>{@code Boolean.class} - {@link BooleanConverter}</li>
- * <li>{@code Byte.class} - {@link ByteConverter}</li>
- * <li>{@code Character.class} - {@link CharacterConverter}</li>
- * <li>{@code Double.class} - {@link DoubleConverter}</li>
- * <li>{@code Float.class} - {@link FloatConverter}</li>
- * <li>{@code Integer.class} - {@link IntegerConverter}</li>
- * <li>{@code Long.class} - {@link LongConverter}</li>
- * <li>{@code Short.class} - {@link ShortConverter}</li>
- * <li>{@code String.class} - {@link StringConverter}</li>
+ * <li>{@code BigDecimal.class} - {@link BigDecimalConverter}</li>
+ * <li>{@code BigInteger.class} - {@link BigIntegerConverter}</li>
+ * <li>{@code Boolean.class} - {@link BooleanConverter}</li>
+ * <li>{@code Byte.class} - {@link ByteConverter}</li>
+ * <li>{@code Character.class} - {@link CharacterConverter}</li>
+ * <li>{@code Double.class} - {@link DoubleConverter}</li>
+ * <li>{@code Float.class} - {@link FloatConverter}</li>
+ * <li>{@code Integer.class} - {@link IntegerConverter}</li>
+ * <li>{@code Long.class} - {@link LongConverter}</li>
+ * <li>{@code Short.class} - {@link ShortConverter}</li>
+ * <li>{@code String.class} - {@link StringConverter}</li>
* </ul>
- * @param throwException {@code true} if the converters should
- * throw an exception when a conversion error occurs, otherwise <code>
- * {@code false} if a default value should be used.
+ *
+ * @param throwException {@code true} if the converters should throw an exception when a conversion error occurs, otherwise <code>
+ * {@code false} if a default value should be used.
* @param defaultNull {@code true}if the <em>standard</em> converters
* (see {@link ConvertUtilsBean#registerStandard(boolean, boolean)})
* should use a default value of {@code null</code>, otherwise <code>false}.
@@ -683,24 +656,24 @@ public class ConvertUtilsBean {
*/
private void registerStandard(final boolean throwException, final boolean defaultNull) {
- final Number defaultNumber = defaultNull ? null : ZERO;
- final BigDecimal bigDecDeflt = defaultNull ? null : new BigDecimal("0.0");
- final BigInteger bigIntDeflt = defaultNull ? null : new BigInteger("0");
- final Boolean booleanDefault = defaultNull ? null : Boolean.FALSE;
- final Character charDefault = defaultNull ? null : SPACE;
- final String stringDefault = defaultNull ? null : "";
+ final Number defaultNumber = defaultNull ? null : ZERO;
+ final BigDecimal bigDecDeflt = defaultNull ? null : new BigDecimal("0.0");
+ final BigInteger bigIntDeflt = defaultNull ? null : new BigInteger("0");
+ final Boolean booleanDefault = defaultNull ? null : Boolean.FALSE;
+ final Character charDefault = defaultNull ? null : SPACE;
+ final String stringDefault = defaultNull ? null : "";
register(BigDecimal.class, throwException ? new BigDecimalConverter() : new BigDecimalConverter(bigDecDeflt));
register(BigInteger.class, throwException ? new BigIntegerConverter() : new BigIntegerConverter(bigIntDeflt));
- register(Boolean.class, throwException ? new BooleanConverter() : new BooleanConverter(booleanDefault));
- register(Byte.class, throwException ? new ByteConverter() : new ByteConverter(defaultNumber));
- register(Character.class, throwException ? new CharacterConverter() : new CharacterConverter(charDefault));
- register(Double.class, throwException ? new DoubleConverter() : new DoubleConverter(defaultNumber));
- register(Float.class, throwException ? new FloatConverter() : new FloatConverter(defaultNumber));
- register(Integer.class, throwException ? new IntegerConverter() : new IntegerConverter(defaultNumber));
- register(Long.class, throwException ? new LongConverter() : new LongConverter(defaultNumber));
- register(Short.class, throwException ? new ShortConverter() : new ShortConverter(defaultNumber));
- register(String.class, throwException ? new StringConverter() : new StringConverter(stringDefault));
+ register(Boolean.class, throwException ? new BooleanConverter() : new BooleanConverter(booleanDefault));
+ register(Byte.class, throwException ? new ByteConverter() : new ByteConverter(defaultNumber));
+ register(Character.class, throwException ? new CharacterConverter() : new CharacterConverter(charDefault));
+ register(Double.class, throwException ? new DoubleConverter() : new DoubleConverter(defaultNumber));
+ register(Float.class, throwException ? new FloatConverter() : new FloatConverter(defaultNumber));
+ register(Integer.class, throwException ? new IntegerConverter() : new IntegerConverter(defaultNumber));
+ register(Long.class, throwException ? new LongConverter() : new LongConverter(defaultNumber));
+ register(Short.class, throwException ? new ShortConverter() : new ShortConverter(defaultNumber));
+ register(String.class, throwException ? new StringConverter() : new StringConverter(stringDefault));
}
}
diff --git a/src/main/java/org/apache/commons/beanutils2/Converter.java b/src/main/java/org/apache/commons/beanutils2/Converter.java
index 20af059c..55b6eaf6 100644
--- a/src/main/java/org/apache/commons/beanutils2/Converter.java
+++ b/src/main/java/org/apache/commons/beanutils2/Converter.java
@@ -18,17 +18,20 @@
package org.apache.commons.beanutils2;
/**
- * <p>General purpose data type converter that can be registered and used
- * within the BeanUtils package to manage the conversion of objects from
- * one type to another.</p>
+ * <p>
+ * General purpose data type converter that can be registered and used within the BeanUtils package to manage the conversion of objects from one type to
+ * another.
+ * </p>
*
- * <p>Converter subclasses bundled with the BeanUtils library are required
- * to be thread-safe, as users of the library may call conversion methods
- * from more than one thread simultaneously.</p>
+ * <p>
+ * Converter subclasses bundled with the BeanUtils library are required to be thread-safe, as users of the library may call conversion methods from more than
+ * one thread simultaneously.
+ * </p>
*
- * <p>Custom converter subclasses created by users of the library can be
- * non-thread-safe if the application using them is single-threaded. However
- * it is recommended that they be written in a thread-safe manner anyway.</p>
+ * <p>
+ * Custom converter subclasses created by users of the library can be non-thread-safe if the application using them is single-threaded. However it is
+ * recommended that they be written in a thread-safe manner anyway.
+ * </p>
*
* @param <T> the convert type.
* @since 1.3
@@ -37,16 +40,14 @@ package org.apache.commons.beanutils2;
public interface Converter<T> {
/**
- * Convert the specified input object into an output object of the
- * specified type.
+ * Convert the specified input object into an output object of the specified type.
*
- * @param <R> the result type.
- * @param type Data type to which this value should be converted
+ * @param <R> the result type.
+ * @param type Data type to which this value should be converted
* @param value The input value to be converted
* @return The converted value
*
- * @throws ConversionException if conversion cannot be performed
- * successfully
+ * @throws ConversionException if conversion cannot be performed successfully
*/
<R> R convert(Class<R> type, Object value);
diff --git a/src/main/java/org/apache/commons/beanutils2/ConvertingWrapDynaBean.java b/src/main/java/org/apache/commons/beanutils2/ConvertingWrapDynaBean.java
index 29211a70..99897349 100644
--- a/src/main/java/org/apache/commons/beanutils2/ConvertingWrapDynaBean.java
+++ b/src/main/java/org/apache/commons/beanutils2/ConvertingWrapDynaBean.java
@@ -20,22 +20,22 @@ package org.apache.commons.beanutils2;
import java.lang.reflect.InvocationTargetException;
/**
- * <p>Implements {@link DynaBean} to wrap a standard JavaBean
- * instance, so that DynaBean APIs can be used to access its properties,
- * though this implementation allows type conversion to occur when properties are set.
- * This means that (say) Strings can be passed in as values in setter methods and
- * this DynaBean will convert them to the correct primitive data types.</p>
+ * <p>
+ * Implements {@link DynaBean} to wrap a standard JavaBean instance, so that DynaBean APIs can be used to access its properties, though this implementation
+ * allows type conversion to occur when properties are set. This means that (say) Strings can be passed in as values in setter methods and this DynaBean will
+ * convert them to the correct primitive data types.
+ * </p>
*
- * <p><strong>IMPLEMENTATION NOTE</strong> - This implementation does not
- * support the {@code contains()</code> and <code>remove()} methods.</p>
+ * <p>
+ * <strong>IMPLEMENTATION NOTE</strong> - This implementation does not support the {@code contains()</code> and <code>remove()} methods.
+ * </p>
*/
public class ConvertingWrapDynaBean extends WrapDynaBean {
private static final long serialVersionUID = 1L;
/**
- * Constructs a new {@code DynaBean} associated with the specified
- * JavaBean instance.
+ * Constructs a new {@code DynaBean} associated with the specified JavaBean instance.
*
* @param instance JavaBean instance to be wrapped
*/
@@ -44,15 +44,13 @@ public class ConvertingWrapDynaBean extends WrapDynaBean {
}
/**
- * Sets the value of the property with the specified name
- * performing any type conversions if necessary. So this method
- * can accept String values for primitive numeric data types for example.
+ * Sets the value of the property with the specified name performing any type conversions if necessary. So this method can accept String values for
+ * primitive numeric data types for example.
*
- * @param name Name of the property whose value is to be set
+ * @param name Name of the property whose value is to be set
* @param value Value to which this property is to be set
*
- * @throws IllegalArgumentException if there are any problems
- * copying the property.
+ * @throws IllegalArgumentException if there are any problems copying the property.
*/
@Override
public void set(final String name, final Object value) {
diff --git a/src/main/java/org/apache/commons/beanutils2/DefaultBeanIntrospector.java b/src/main/java/org/apache/commons/beanutils2/DefaultBeanIntrospector.java
index c0512503..bfbebfc2 100644
--- a/src/main/java/org/apache/commons/beanutils2/DefaultBeanIntrospector.java
+++ b/src/main/java/org/apache/commons/beanutils2/DefaultBeanIntrospector.java
@@ -32,15 +32,12 @@ import org.apache.commons.logging.LogFactory;
* The default {@link BeanIntrospector} implementation.
* </p>
* <p>
- * This class implements a default bean introspection algorithm based on the JDK
- * classes in the {@link java.beans} package. It discovers properties
- * conforming to the Java Beans specification.
+ * This class implements a default bean introspection algorithm based on the JDK classes in the {@link java.beans} package. It discovers properties conforming
+ * to the Java Beans specification.
* </p>
* <p>
- * This class is a singleton. The single instance can be obtained using the
- * {@code INSTANCE} field. It does not define any state and thus can be
- * shared by arbitrary clients. {@link PropertyUtils} per default uses this
- * instance as its only {@code BeanIntrospector} object.
+ * This class is a singleton. The single instance can be obtained using the {@code INSTANCE} field. It does not define any state and thus can be shared by
+ * arbitrary clients. {@link PropertyUtils} per default uses this instance as its only {@code BeanIntrospector} object.
* </p>
*
* @since 1.9
@@ -63,11 +60,9 @@ public class DefaultBeanIntrospector implements BeanIntrospector {
}
/**
- * This method fixes an issue where IndexedPropertyDescriptor behaves
- * differently in different versions of the JDK for 'indexed' properties
- * which use java.util.List (rather than an array). It implements a
- * workaround for Bug 28358. If you have a Bean with the following
- * getters/setters for an indexed property:
+ * This method fixes an issue where IndexedPropertyDescriptor behaves differently in different versions of the JDK for 'indexed' properties which use
+ * java.util.List (rather than an array). It implements a workaround for Bug 28358. If you have a Bean with the following getters/setters for an indexed
+ * property:
*
* <pre>
* public List getFoo()
@@ -76,56 +71,40 @@ public class DefaultBeanIntrospector implements BeanIntrospector {
* public void setFoo(int index, Object foo)
* </pre>
*
- * then the IndexedPropertyDescriptor's getReadMethod() and getWriteMethod()
- * behave as follows:
+ * then the IndexedPropertyDescriptor's getReadMethod() and getWriteMethod() behave as follows:
* <ul>
* <li>JDK 1.3.1_04: returns valid Method objects from these methods.</li>
* <li>JDK 1.4.2_05: returns null from these methods.</li>
* </ul>
*
- * @param beanClass the current class to be inspected
+ * @param beanClass the current class to be inspected
* @param descriptors the array with property descriptors
*/
- private void handleIndexedPropertyDescriptors(final Class<?> beanClass,
- final PropertyDescriptor[] descriptors) {
+ private void handleIndexedPropertyDescriptors(final Class<?> beanClass, final PropertyDescriptor[] descriptors) {
for (final PropertyDescriptor pd : descriptors) {
if (pd instanceof IndexedPropertyDescriptor) {
final IndexedPropertyDescriptor descriptor = (IndexedPropertyDescriptor) pd;
- final String propName = descriptor.getName().substring(0, 1)
- .toUpperCase()
- + descriptor.getName().substring(1);
+ final String propName = descriptor.getName().substring(0, 1).toUpperCase() + descriptor.getName().substring(1);
if (descriptor.getReadMethod() == null) {
- final String methodName = descriptor.getIndexedReadMethod() != null ? descriptor
- .getIndexedReadMethod().getName() : "get"
- + propName;
- final Method readMethod = MethodUtils
- .getMatchingAccessibleMethod(beanClass, methodName,
- BeanUtils.EMPTY_CLASS_ARRAY);
+ final String methodName = descriptor.getIndexedReadMethod() != null ? descriptor.getIndexedReadMethod().getName() : "get" + propName;
+ final Method readMethod = MethodUtils.getMatchingAccessibleMethod(beanClass, methodName, BeanUtils.EMPTY_CLASS_ARRAY);
if (readMethod != null) {
try {
descriptor.setReadMethod(readMethod);
} catch (final Exception e) {
- log.error(
- "Error setting indexed property read method",
- e);
+ log.error("Error setting indexed property read method", e);
}
}
}
if (descriptor.getWriteMethod() == null) {
- final String methodName = descriptor.getIndexedWriteMethod() != null ? descriptor
- .getIndexedWriteMethod().getName() : "set"
- + propName;
- Method writeMethod = MethodUtils
- .getMatchingAccessibleMethod(beanClass, methodName,
- LIST_CLASS_PARAMETER);
+ final String methodName = descriptor.getIndexedWriteMethod() != null ? descriptor.getIndexedWriteMethod().getName() : "set" + propName;
+ Method writeMethod = MethodUtils.getMatchingAccessibleMethod(beanClass, methodName, LIST_CLASS_PARAMETER);
if (writeMethod == null) {
for (final Method m : beanClass.getMethods()) {
if (m.getName().equals(methodName)) {
final Class<?>[] parameterTypes = m.getParameterTypes();
- if (parameterTypes.length == 1
- && List.class
- .isAssignableFrom(parameterTypes[0])) {
+ if (parameterTypes.length == 1 && List.class.isAssignableFrom(parameterTypes[0])) {
writeMethod = m;
break;
}
@@ -136,9 +115,7 @@ public class DefaultBeanIntrospector implements BeanIntrospector {
try {
descriptor.setWriteMethod(writeMethod);
} catch (final Exception e) {
- log.error(
- "Error setting indexed property write method",
- e);
+ log.error("Error setting indexed property write method", e);
}
}
}
@@ -147,10 +124,8 @@ public class DefaultBeanIntrospector implements BeanIntrospector {
}
/**
- * Performs introspection of a specific Java class. This implementation uses
- * the {@code java.beans.Introspector.getBeanInfo()} method to obtain
- * all property descriptors for the current class and adds them to the
- * passed in introspection context.
+ * Performs introspection of a specific Java class. This implementation uses the {@code java.beans.Introspector.getBeanInfo()} method to obtain all property
+ * descriptors for the current class and adds them to the passed in introspection context.
*
* @param icontext the introspection context
*/
@@ -161,9 +136,7 @@ public class DefaultBeanIntrospector implements BeanIntrospector {
beanInfo = Introspector.getBeanInfo(icontext.getTargetClass());
} catch (final IntrospectionException e) {
// no descriptors are added to the context
- log.error(
- "Error when inspecting class " + icontext.getTargetClass(),
- e);
+ log.error("Error when inspecting class " + icontext.getTargetClass(), e);
return;
}
@@ -172,8 +145,7 @@ public class DefaultBeanIntrospector implements BeanIntrospector {
descriptors = PropertyDescriptors.EMPTY_ARRAY;
}
- handleIndexedPropertyDescriptors(icontext.getTargetClass(),
- descriptors);
+ handleIndexedPropertyDescriptors(icontext.getTargetClass(), descriptors);
icontext.addPropertyDescriptors(descriptors);
}
}
diff --git a/src/main/java/org/apache/commons/beanutils2/DefaultIntrospectionContext.java b/src/main/java/org/apache/commons/beanutils2/DefaultIntrospectionContext.java
index 28b649d2..ca30f59e 100644
--- a/src/main/java/org/apache/commons/beanutils2/DefaultIntrospectionContext.java
+++ b/src/main/java/org/apache/commons/beanutils2/DefaultIntrospectionContext.java
@@ -24,13 +24,11 @@ import java.util.Set;
/**
* <p>
- * An implementation of the {@code IntrospectionContext} interface used by
- * {@link PropertyUtilsBean} when doing introspection of a bean class.
+ * An implementation of the {@code IntrospectionContext} interface used by {@link PropertyUtilsBean} when doing introspection of a bean class.
* </p>
* <p>
- * This class implements the methods required by the
- * {@code IntrospectionContext} interface in a straight-forward manner
- * based on a map. It is used internally only. It is not thread-safe.
+ * This class implements the methods required by the {@code IntrospectionContext} interface in a straight-forward manner based on a map. It is used internally
+ * only. It is not thread-safe.
* </p>
*
* @since 1.9
@@ -44,8 +42,7 @@ final class DefaultIntrospectionContext implements IntrospectionContext {
/**
*
- * Creates a new instance of {@code DefaultIntrospectionContext} and sets
- * the current class for introspection.
+ * Creates a new instance of {@code DefaultIntrospectionContext} and sets the current class for introspection.
*
* @param cls the current class
*/
@@ -74,8 +71,7 @@ final class DefaultIntrospectionContext implements IntrospectionContext {
}
/**
- * Returns an array with all descriptors added to this context. This method
- * is used to obtain the results of introspection.
+ * Returns an array with all descriptors added to this context. This method is used to obtain the results of introspection.
*
* @return an array with all known property descriptors
*/
diff --git a/src/main/java/org/apache/commons/beanutils2/DynaBean.java b/src/main/java/org/apache/commons/beanutils2/DynaBean.java
index 35a7f66a..c71fd40e 100644
--- a/src/main/java/org/apache/commons/beanutils2/DynaBean.java
+++ b/src/main/java/org/apache/commons/beanutils2/DynaBean.java
@@ -18,25 +18,22 @@
package org.apache.commons.beanutils2;
/**
- * <p>A <strong>DynaBean</strong> is a Java object that supports properties
- * whose names and data types, as well as values, may be dynamically modified.
- * To the maximum degree feasible, other components of the BeanUtils package
- * will recognize such beans and treat them as standard JavaBeans for the
- * purpose of retrieving and setting property values.</p>
+ * <p>
+ * A <strong>DynaBean</strong> is a Java object that supports properties whose names and data types, as well as values, may be dynamically modified. To the
+ * maximum degree feasible, other components of the BeanUtils package will recognize such beans and treat them as standard JavaBeans for the purpose of
+ * retrieving and setting property values.
+ * </p>
*/
public interface DynaBean {
/**
- * Does the specified mapped property contain a value for the specified
- * key value?
+ * Does the specified mapped property contain a value for the specified key value?
*
* @param name Name of the property to check
- * @param key Name of the key to check
- * @return {@code true} if the mapped property contains a value for
- * the specified key, otherwise {@code false}
+ * @param key Name of the key to check
+ * @return {@code true} if the mapped property contains a value for the specified key, otherwise {@code false}
*
- * @throws IllegalArgumentException if there is no property
- * of the specified name
+ * @throws IllegalArgumentException if there is no property of the specified name
*/
boolean contains(String name, String key);
@@ -46,111 +43,89 @@ public interface DynaBean {
* @param name Name of the property whose value is to be retrieved
* @return The property's value
*
- * @throws IllegalArgumentException if there is no property
- * of the specified name
+ * @throws IllegalArgumentException if there is no property of the specified name
*/
Object get(String name);
/**
* Gets the value of an indexed property with the specified name.
*
- * @param name Name of the property whose value is to be retrieved
+ * @param name Name of the property whose value is to be retrieved
* @param index Index of the value to be retrieved
* @return The indexed property's value
*
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws IllegalArgumentException if the specified property
- * exists, but is not indexed
- * @throws IndexOutOfBoundsException if the specified index
- * is outside the range of the underlying property
- * @throws NullPointerException if no array or List has been
- * initialized for this property
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws IllegalArgumentException if the specified property exists, but is not indexed
+ * @throws IndexOutOfBoundsException if the specified index is outside the range of the underlying property
+ * @throws NullPointerException if no array or List has been initialized for this property
*/
Object get(String name, int index);
/**
- * Gets the value of a mapped property with the specified name,
- * or {@code null} if there is no value for the specified key.
+ * Gets the value of a mapped property with the specified name, or {@code null} if there is no value for the specified key.
*
* @param name Name of the property whose value is to be retrieved
- * @param key Key of the value to be retrieved
+ * @param key Key of the value to be retrieved
* @return The mapped property's value
*
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws IllegalArgumentException if the specified property
- * exists, but is not mapped
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws IllegalArgumentException if the specified property exists, but is not mapped
*/
Object get(String name, String key);
/**
- * Gets the {@code DynaClass} instance that describes the set of
- * properties available for this DynaBean.
+ * Gets the {@code DynaClass} instance that describes the set of properties available for this DynaBean.
*
* @return The associated DynaClass
*/
DynaClass getDynaClass();
/**
- * Remove any existing value for the specified key on the
- * specified mapped property.
+ * Remove any existing value for the specified key on the specified mapped property.
*
- * @param name Name of the property for which a value is to
- * be removed
- * @param key Key of the value to be removed
+ * @param name Name of the property for which a value is to be removed
+ * @param key Key of the value to be removed
*
- * @throws IllegalArgumentException if there is no property
- * of the specified name
+ * @throws IllegalArgumentException if there is no property of the specified name
*/
void remove(String name, String key);
/**
* Sets the value of an indexed property with the specified name.
*
- * @param name Name of the property whose value is to be set
+ * @param name Name of the property whose value is to be set
* @param index Index of the property to be set
* @param value Value to which this property is to be set
*
- * @throws ConversionException if the specified value cannot be
- * converted to the type required for this property
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws IllegalArgumentException if the specified property
- * exists, but is not indexed
- * @throws IndexOutOfBoundsException if the specified index
- * is outside the range of the underlying property
+ * @throws ConversionException if the specified value cannot be converted to the type required for this property
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws IllegalArgumentException if the specified property exists, but is not indexed
+ * @throws IndexOutOfBoundsException if the specified index is outside the range of the underlying property
*/
void set(String name, int index, Object value);
/**
* Sets the value of a simple property with the specified name.
*
- * @param name Name of the property whose value is to be set
+ * @param name Name of the property whose value is to be set
* @param value Value to which this property is to be set
*
- * @throws ConversionException if the specified value cannot be
- * converted to the type required for this property
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws NullPointerException if an attempt is made to set a
- * primitive property to null
+ * @throws ConversionException if the specified value cannot be converted to the type required for this property
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws NullPointerException if an attempt is made to set a primitive property to null
*/
void set(String name, Object value);
/**
* Sets the value of a mapped property with the specified name.
*
- * @param name Name of the property whose value is to be set
- * @param key Key of the property to be set
+ * @param name Name of the property whose value is to be set
+ * @param key Key of the property to be set
* @param value Value to which this property is to be set
*
- * @throws ConversionException if the specified value cannot be
- * converted to the type required for this property
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws IllegalArgumentException if the specified property
- * exists, but is not mapped
+ * @throws ConversionException if the specified value cannot be converted to the type required for this property
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws IllegalArgumentException if the specified property exists, but is not mapped
*/
void set(String name, String key, Object value);
diff --git a/src/main/java/org/apache/commons/beanutils2/DynaBeanPropertyMapDecorator.java b/src/main/java/org/apache/commons/beanutils2/DynaBeanPropertyMapDecorator.java
index 750488f7..fd53ee3f 100644
--- a/src/main/java/org/apache/commons/beanutils2/DynaBeanPropertyMapDecorator.java
+++ b/src/main/java/org/apache/commons/beanutils2/DynaBeanPropertyMapDecorator.java
@@ -17,52 +17,67 @@
package org.apache.commons.beanutils2;
/**
- * <p>Decorates a {@link DynaBean} to provide {@code Map} behavior.</p>
+ * <p>
+ * Decorates a {@link DynaBean} to provide {@code Map} behavior.
+ * </p>
*
- * <p>The motivation for this implementation is to provide access to {@link DynaBean}
- * properties in technologies that are unaware of BeanUtils and {@link DynaBean}s -
- * such as the expression languages of JSTL and JSF.</p>
+ * <p>
+ * The motivation for this implementation is to provide access to {@link DynaBean} properties in technologies that are unaware of BeanUtils and
+ * {@link DynaBean}s - such as the expression languages of JSTL and JSF.
+ * </p>
*
- * <p>This can be achieved either by wrapping the {@link DynaBean} prior to
- * providing it to the technology to process or by providing a {@code Map}
- * accessor method on the DynaBean implementation:</p>
- * <pre><code>
+ * <p>
+ * This can be achieved either by wrapping the {@link DynaBean} prior to providing it to the technology to process or by providing a {@code Map} accessor method
+ * on the DynaBean implementation:
+ * </p>
+ *
+ * <pre>
+ * <code>
* public Map<String, Object> getMap() {
* return new DynaBeanPropertyMapDecorator(this);
- * }</code></pre>
+ * }</code>
+ * </pre>
*
- * <p>This, for example, could be used in JSTL in the following way to access
- * a DynaBean's {@code fooProperty}:</p>
- * <ul><li>{@code ${myDynaBean.<b>map</b>.fooProperty}}</li></ul>
+ * <p>
+ * This, for example, could be used in JSTL in the following way to access a DynaBean's {@code fooProperty}:
+ * </p>
+ * <ul>
+ * <li>{@code ${myDynaBean.<b>map</b>.fooProperty}}</li>
+ * </ul>
*
* <h2>Usage</h2>
*
- * <p>To decorate a {@link DynaBean} simply instantiate this class with the
- * target {@link DynaBean}:</p>
+ * <p>
+ * To decorate a {@link DynaBean} simply instantiate this class with the target {@link DynaBean}:
+ * </p>
*
- * <ul><li>{@code Map<String, Object> fooMap = new DynaBeanPropertyMapDecorator(fooDynaBean);}</li></ul>
+ * <ul>
+ * <li>{@code Map<String, Object> fooMap = new DynaBeanPropertyMapDecorator(fooDynaBean);}</li>
+ * </ul>
*
- * <p>The above example creates a <b><em>read only</em></b> {@code Map}.
- * To create a {@code Map} which can be modified, construct a
- * {@code DynaBeanPropertyMapDecorator} with the <b><em>read only</em></b>
- * attribute set to {@code false}:</p>
+ * <p>
+ * The above example creates a <b><em>read only</em></b> {@code Map}. To create a {@code Map} which can be modified, construct a
+ * {@code DynaBeanPropertyMapDecorator} with the <b><em>read only</em></b> attribute set to {@code false}:
+ * </p>
*
- * <ul><li>{@code Map<String, Object> fooMap =
- * new DynaBeanPropertyMapDecorator(fooDynaBean, false);}</li></ul>
+ * <ul>
+ * <li>{@code Map<String, Object> fooMap =
+ * new DynaBeanPropertyMapDecorator(fooDynaBean, false);}</li>
+ * </ul>
*
* <h2>Limitations</h2>
- * <p>In this implementation the {@code entrySet()</code>, <code>keySet()}
+ * <p>
+ * In this implementation the {@code entrySet()</code>, <code>keySet()}
* and {@code values()} methods create an <b><em>unmodifiable</em></b>
- * {@code Set</code> and it does not support the Map's <code>clear()}
- * and {@code remove()} operations.</p>
+ * {@code Set</code> and it does not support the Map's <code>clear()} and {@code remove()} operations.
+ * </p>
*
* @since 1.9.0
*/
public class DynaBeanPropertyMapDecorator extends BaseDynaBeanMapDecorator<String> {
/**
- * Constructs a read only Map for the specified
- * {@link DynaBean}.
+ * Constructs a read only Map for the specified {@link DynaBean}.
*
* @param dynaBean The dyna bean being decorated
* @throws IllegalArgumentException if the {@link DynaBean} is null.
@@ -75,8 +90,7 @@ public class DynaBeanPropertyMapDecorator extends BaseDynaBeanMapDecorator<Strin
* Constructs a Map for the specified {@link DynaBean}.
*
* @param dynaBean The dyna bean being decorated
- * @param readOnly {@code true} if the Map is read only
- * otherwise {@code false}
+ * @param readOnly {@code true} if the Map is read only otherwise {@code false}
* @throws IllegalArgumentException if the {@link DynaBean} is null.
*/
public DynaBeanPropertyMapDecorator(final DynaBean dynaBean, final boolean readOnly) {
diff --git a/src/main/java/org/apache/commons/beanutils2/DynaClass.java b/src/main/java/org/apache/commons/beanutils2/DynaClass.java
index 9694d3e0..320c8234 100644
--- a/src/main/java/org/apache/commons/beanutils2/DynaClass.java
+++ b/src/main/java/org/apache/commons/beanutils2/DynaClass.java
@@ -17,33 +17,32 @@
package org.apache.commons.beanutils2;
/**
- * <p>A <strong>DynaClass</strong> is a simulation of the functionality of
- * {@link Class} for classes implementing the
- * {@code DynaBean} interface. DynaBean instances that share the same
- * DynaClass all have the same set of available properties, along with any
- * associated data types, read-only states, and write-only states.</p>
+ * <p>
+ * A <strong>DynaClass</strong> is a simulation of the functionality of {@link Class} for classes implementing the {@code DynaBean} interface. DynaBean
+ * instances that share the same DynaClass all have the same set of available properties, along with any associated data types, read-only states, and write-only
+ * states.
+ * </p>
*/
public interface DynaClass {
/**
- * <p>Returns an array of {@code PropertyDescriptor} for the properties
- * currently defined in this DynaClass. If no properties are defined, a
- * zero-length array will be returned.</p>
+ * <p>
+ * Returns an array of {@code PropertyDescriptor} for the properties currently defined in this DynaClass. If no properties are defined, a zero-length array
+ * will be returned.
+ * </p>
*
- * <p><strong>FIXME</strong> - Should we really be implementing
- * {@code getBeanInfo()} instead, which returns property descriptors
- * and a bunch of other stuff?</p>
+ * <p>
+ * <strong>FIXME</strong> - Should we really be implementing {@code getBeanInfo()} instead, which returns property descriptors and a bunch of other stuff?
+ * </p>
*
* @return the set of properties for this DynaClass
*/
DynaProperty[] getDynaProperties();
/**
- * Returns a property descriptor for the specified property, if it exists;
- * otherwise, return {@code null}.
+ * Returns a property descriptor for the specified property, if it exists; otherwise, return {@code null}.
*
- * @param name Name of the dynamic property for which a descriptor
- * is requested
+ * @param name Name of the dynamic property for which a descriptor is requested
* @return The descriptor for the specified property
*
* @throws IllegalArgumentException if no property name is specified
@@ -51,26 +50,21 @@ public interface DynaClass {
DynaProperty getDynaProperty(String name);
/**
- * Returns the name of this DynaClass (analogous to the
- * {@code getName()} method of {@link Class}, which
- * allows the same {@code DynaClass} implementation class to support
- * different dynamic classes, with different sets of properties.
+ * Returns the name of this DynaClass (analogous to the {@code getName()} method of {@link Class}, which allows the same {@code DynaClass} implementation
+ * class to support different dynamic classes, with different sets of properties.
*
* @return the name of the DynaClass
*/
String getName();
/**
- * Instantiates and return a new DynaBean instance, associated
- * with this DynaClass.
+ * Instantiates and return a new DynaBean instance, associated with this DynaClass.
*
* @return A new {@code DynaBean} instance
*
- * @throws IllegalAccessException if the Class or the appropriate
- * constructor is not accessible
- * @throws InstantiationException if this Class represents an abstract
- * class, an array class, a primitive type, or void; or if instantiation
- * fails for some other reason
+ * @throws IllegalAccessException if the Class or the appropriate constructor is not accessible
+ * @throws InstantiationException if this Class represents an abstract class, an array class, a primitive type, or void; or if instantiation fails for some
+ * other reason
*/
DynaBean newInstance() throws IllegalAccessException, InstantiationException;
diff --git a/src/main/java/org/apache/commons/beanutils2/DynaProperty.java b/src/main/java/org/apache/commons/beanutils2/DynaProperty.java
index 4a375d98..4c5ee77f 100644
--- a/src/main/java/org/apache/commons/beanutils2/DynaProperty.java
+++ b/src/main/java/org/apache/commons/beanutils2/DynaProperty.java
@@ -22,24 +22,22 @@ import java.util.Map;
import java.util.Objects;
/**
- * <p>The metadata describing an individual property of a DynaBean.</p>
+ * <p>
+ * The metadata describing an individual property of a DynaBean.
+ * </p>
*
- * <p>The meta contains an <em>optional</em> content type property ({@link #getContentType})
- * for use by mapped and iterated properties.
- * A mapped or iterated property may choose to indicate the type it expects.
- * The DynaBean implementation may choose to enforce this type on its entries.
- * Alternatively, an implementation may choose to ignore this property.
- * All keys for maps must be of type String so no meta data is needed for map keys.</p>
+ * <p>
+ * The meta contains an <em>optional</em> content type property ({@link #getContentType}) for use by mapped and iterated properties. A mapped or iterated
+ * property may choose to indicate the type it expects. The DynaBean implementation may choose to enforce this type on its entries. Alternatively, an
+ * implementation may choose to ignore this property. All keys for maps must be of type String so no meta data is needed for map keys.
+ * </p>
*/
public class DynaProperty {
/*
- * There are issues with serializing primitive class types on certain JVM versions
- * (including Java 1.3).
- * This class uses a custom serialization implementation that writes an integer
- * for these primitive class.
- * This list of constants are the ones used in serialization.
- * If these values are changed, then older versions will no longer be read correctly
+ * There are issues with serializing primitive class types on certain JVM versions (including Java 1.3). This class uses a custom serialization
+ * implementation that writes an integer for these primitive class. This list of constants are the ones used in serialization. If these values are changed,
+ * then older versions will no longer be read correctly
*/
private static final int BOOLEAN_TYPE = 1;
private static final int BYTE_TYPE = 2;
@@ -63,6 +61,7 @@ public class DynaProperty {
/** The <em>(optional)</em> type of content elements for indexed {@code DynaProperty} */
protected transient Class<?> contentType;
+
/**
* Constructs a property that accepts any data type.
*
@@ -87,11 +86,10 @@ public class DynaProperty {
}
/**
- * Constructs an indexed or mapped {@code DynaProperty} that supports (pseudo)-introspection
- * of the content type.
+ * Constructs an indexed or mapped {@code DynaProperty} that supports (pseudo)-introspection of the content type.
*
- * @param name Name of the property being described
- * @param type Java class representing the property data type
+ * @param name Name of the property being described
+ * @param type Java class representing the property data type
* @param contentType Class that all indexed or mapped elements are instances of
*/
public DynaProperty(final String name, final Class<?> type, final Class<?> contentType) {
@@ -101,11 +99,11 @@ public class DynaProperty {
}
/**
- * Checks this instance against the specified Object for equality. Overrides the
- * default reference test for equality provided by {@link Object#equals(Object)}
+ * Checks this instance against the specified Object for equality. Overrides the default reference test for equality provided by
+ * {@link Object#equals(Object)}
+ *
* @param obj The object to compare to
- * @return {@code true} if object is a dyna property with the same name
- * type and content type, otherwise {@code false}
+ * @return {@code true} if object is a dyna property with the same name type and content type, otherwise {@code false}
* @since 1.8.0
*/
@Override
@@ -116,25 +114,21 @@ public class DynaProperty {
if (!result && obj instanceof DynaProperty) {
final DynaProperty that = (DynaProperty) obj;
- result =
- Objects.equals(this.name, that.name) &&
- Objects.equals(this.type, that.type) &&
- Objects.equals(this.contentType, that.contentType);
+ result = Objects.equals(this.name, that.name) && Objects.equals(this.type, that.type) && Objects.equals(this.contentType, that.contentType);
}
return result;
}
/**
- * Gets the <em>(optional)</em> type of the indexed content for {@code DynaProperty}'s
- * that support this feature.
+ * Gets the <em>(optional)</em> type of the indexed content for {@code DynaProperty}'s that support this feature.
*
- * <p>There are issues with serializing primitive class types on certain JVM versions
- * (including Java 1.3).
- * Therefore, this field <strong>must not be serialized using the standard methods</strong>.</p>
+ * <p>
+ * There are issues with serializing primitive class types on certain JVM versions (including Java 1.3). Therefore, this field <strong>must not be
+ * serialized using the standard methods</strong>.
+ * </p>
*
- * @return the Class for the content type if this is an indexed {@code DynaProperty}
- * and this feature is supported. Otherwise null.
+ * @return the Class for the content type if this is an indexed {@code DynaProperty} and this feature is supported. Otherwise null.
*/
public Class<?> getContentType() {
return contentType;
@@ -142,6 +136,7 @@ public class DynaProperty {
/**
* Gets the name of this property.
+ *
* @return the name of the property
*/
public String getName() {
@@ -149,14 +144,18 @@ public class DynaProperty {
}
/**
- * <p>Gets the Java class representing the data type of the underlying property
- * values.</p>
+ * <p>
+ * Gets the Java class representing the data type of the underlying property values.
+ * </p>
*
- * <p>There are issues with serializing primitive class types on certain JVM versions
- * (including Java 1.3).
- * Therefore, this field <strong>must not be serialized using the standard methods</strong>.</p>
+ * <p>
+ * There are issues with serializing primitive class types on certain JVM versions (including Java 1.3). Therefore, this field <strong>must not be
+ * serialized using the standard methods</strong>.
+ * </p>
*
- * <p><strong>Please leave this field as {@code transient}</strong></p>
+ * <p>
+ * <strong>Please leave this field as {@code transient}</strong>
+ * </p>
*
* @return the property type
*/
@@ -171,20 +170,19 @@ public class DynaProperty {
*/
@Override
public int hashCode() {
- int result = 1;
+ int result = 1;
- result = result * 31 + (name == null ? 0 : name.hashCode());
- result = result * 31 + (type == null ? 0 : type.hashCode());
- result = result * 31 + (contentType == null ? 0 : contentType.hashCode());
+ result = result * 31 + (name == null ? 0 : name.hashCode());
+ result = result * 31 + (type == null ? 0 : type.hashCode());
+ result = result * 31 + (contentType == null ? 0 : contentType.hashCode());
- return result;
+ return result;
}
/**
* Does this property represent an indexed value (ie an array or List)?
*
- * @return {@code true} if the property is indexed (i.e. is a List or
- * array), otherwise {@code false}
+ * @return {@code true} if the property is indexed (i.e. is a List or array), otherwise {@code false}
*/
public boolean isIndexed() {
if (type == null) {
@@ -199,8 +197,7 @@ public class DynaProperty {
/**
* Does this property represent a mapped value (ie a Map)?
*
- * @return {@code true} if the property is a Map
- * otherwise {@code false}
+ * @return {@code true} if the property is a Map otherwise {@code false}
*/
public boolean isMapped() {
if (type == null) {
@@ -212,6 +209,7 @@ public class DynaProperty {
/**
* Gets a String representation of this Object.
+ *
* @return a String representation of the dyna property
*/
@Override
diff --git a/src/main/java/org/apache/commons/beanutils2/FluentPropertyBeanIntrospector.java b/src/main/java/org/apache/commons/beanutils2/FluentPropertyBeanIntrospector.java
index c9532ed7..d2b87944 100644
--- a/src/main/java/org/apache/commons/beanutils2/FluentPropertyBeanIntrospector.java
+++ b/src/main/java/org/apache/commons/beanutils2/FluentPropertyBeanIntrospector.java
@@ -28,16 +28,14 @@ import org.apache.commons.logging.LogFactory;
/**
* <p>
- * An implementation of the {@code BeanIntrospector} interface which can
- * detect write methods for properties used in fluent API scenario.
+ * An implementation of the {@code BeanIntrospector} interface which can detect write methods for properties used in fluent API scenario.
* </p>
* <p>
- * A <em>fluent API</em> allows setting multiple properties using a single
- * statement by supporting so-called <em>method chaining</em>: Methods for
- * setting a property value do not return <b>void</b>, but an object which can
- * be called for setting another property. An example of such a fluent API could
- * look as follows:
+ * A <em>fluent API</em> allows setting multiple properties using a single statement by supporting so-called <em>method chaining</em>: Methods for setting a
+ * property value do not return <b>void</b>, but an object which can be called for setting another property. An example of such a fluent API could look as
+ * follows:
* </p>
+ *
* <pre>
* public class FooBuilder {
* public FooBuilder setFooProperty1(String value) {
@@ -52,26 +50,20 @@ import org.apache.commons.logging.LogFactory;
* }
* </pre>
*
- * <p>Per default, {@code PropertyUtils} does not detect methods like this
- * because, having a non-<b>void</b> return type, they violate the Java Beans
+ * <p>
+ * Per default, {@code PropertyUtils} does not detect methods like this because, having a non-<b>void</b> return type, they violate the Java Beans
* specification.
* </p>
* <p>
- * This class is more tolerant with regards to the return type of a set method.
- * It basically iterates over all methods of a class and filters them for a
- * configurable prefix (the default prefix is {@code set}). It then
- * generates corresponding {@code PropertyDescriptor} objects for the
- * methods found which use these methods as write methods.
+ * This class is more tolerant with regards to the return type of a set method. It basically iterates over all methods of a class and filters them for a
+ * configurable prefix (the default prefix is {@code set}). It then generates corresponding {@code PropertyDescriptor} objects for the methods found which use
+ * these methods as write methods.
* </p>
* <p>
- * An instance of this class is intended to collaborate with a
- * {@link DefaultBeanIntrospector} object. So best results are achieved by
- * adding this instance as custom {@code BeanIntrospector} after the
- * {@code DefaultBeanIntrospector} object. Then default introspection finds
- * read-only properties because it does not detect the write methods with a
- * non-<b>void</b> return type. {@code FluentPropertyBeanIntrospector}
- * completes the descriptors for these properties by setting the correct write
- * method.
+ * An instance of this class is intended to collaborate with a {@link DefaultBeanIntrospector} object. So best results are achieved by adding this instance as
+ * custom {@code BeanIntrospector} after the {@code DefaultBeanIntrospector} object. Then default introspection finds read-only properties because it does not
+ * detect the write methods with a non-<b>void</b> return type. {@code FluentPropertyBeanIntrospector} completes the descriptors for these properties by setting
+ * the correct write method.
* </p>
*
* @since 1.9
@@ -88,8 +80,7 @@ public class FluentPropertyBeanIntrospector implements BeanIntrospector {
/**
*
- * Creates a new instance of {@code FluentPropertyBeanIntrospector} and
- * sets the default prefix for write methods.
+ * Creates a new instance of {@code FluentPropertyBeanIntrospector} and sets the default prefix for write methods.
*/
public FluentPropertyBeanIntrospector() {
this(DEFAULT_WRITE_METHOD_PREFIX);
@@ -97,9 +88,8 @@ public class FluentPropertyBeanIntrospector implements BeanIntrospector {
/**
*
- * Creates a new instance of {@code FluentPropertyBeanIntrospector} and
- * initializes it with the prefix for write methods used by the classes to
- * be inspected.
+ * Creates a new instance of {@code FluentPropertyBeanIntrospector} and initializes it with the prefix for write methods used by the classes to be
+ * inspected.
*
* @param writePrefix the prefix for write methods (must not be <b>null</b>)
* @throws IllegalArgumentException if the prefix is <b>null</b>
@@ -111,13 +101,12 @@ public class FluentPropertyBeanIntrospector implements BeanIntrospector {
/**
* Creates a property descriptor for a fluent API property.
*
- * @param m the set method for the fluent API property
+ * @param m the set method for the fluent API property
* @param propertyName the name of the corresponding property
* @return the descriptor
* @throws IntrospectionException if an error occurs
*/
- private PropertyDescriptor createFluentPropertyDescritor(final Method m,
- final String propertyName) throws IntrospectionException {
+ private PropertyDescriptor createFluentPropertyDescritor(final Method m, final String propertyName) throws IntrospectionException {
return new PropertyDescriptor(propertyName(m), null, m);
}
@@ -131,38 +120,31 @@ public class FluentPropertyBeanIntrospector implements BeanIntrospector {
}
/**
- * Performs introspection. This method scans the current class's methods for
- * property write methods which have not been discovered by default
- * introspection.
+ * Performs introspection. This method scans the current class's methods for property write methods which have not been discovered by default introspection.
*
* @param icontext the introspection context
* @throws IntrospectionException if an error occurs
*/
@Override
- public void introspect(final IntrospectionContext icontext)
- throws IntrospectionException {
+ public void introspect(final IntrospectionContext icontext) throws IntrospectionException {
for (final Method m : icontext.getTargetClass().getMethods()) {
if (m.getName().startsWith(getWriteMethodPrefix())) {
final String propertyName = propertyName(m);
- final PropertyDescriptor pd = icontext
- .getPropertyDescriptor(propertyName);
+ final PropertyDescriptor pd = icontext.getPropertyDescriptor(propertyName);
try {
if (pd == null) {
- icontext.addPropertyDescriptor(createFluentPropertyDescritor(
- m, propertyName));
+ icontext.addPropertyDescriptor(createFluentPropertyDescritor(m, propertyName));
} else if (pd.getWriteMethod() == null) {
// We should not change statically cached PropertyDescriptor as it can be from super-type,
// it may affect other subclasses of targetClass supertype.
// See BEANUTILS-541 for more details.
- final PropertyDescriptor fluentPropertyDescriptor = new PropertyDescriptor(
- pd.getName(), pd.getReadMethod(), m);
+ final PropertyDescriptor fluentPropertyDescriptor = new PropertyDescriptor(pd.getName(), pd.getReadMethod(), m);
// replace existing (possibly inherited from super-class) to one specific to current class
icontext.addPropertyDescriptor(fluentPropertyDescriptor);
}
} catch (final IntrospectionException e) {
if (log.isDebugEnabled()) {
- log.debug("Error when creating PropertyDescriptor for " + m
- + "! Ignoring this property.", e);
+ log.debug("Error when creating PropertyDescriptor for " + m + "! Ignoring this property.", e);
}
}
}
@@ -176,9 +158,7 @@ public class FluentPropertyBeanIntrospector implements BeanIntrospector {
* @return the corresponding property name
*/
private String propertyName(final Method m) {
- final String methodName = m.getName().substring(
- getWriteMethodPrefix().length());
- return methodName.length() > 1 ? Introspector.decapitalize(methodName) : methodName
- .toLowerCase(Locale.ROOT);
+ final String methodName = m.getName().substring(getWriteMethodPrefix().length());
+ return methodName.length() > 1 ? Introspector.decapitalize(methodName) : methodName.toLowerCase(Locale.ROOT);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/commons/beanutils2/IntrospectionContext.java b/src/main/java/org/apache/commons/beanutils2/IntrospectionContext.java
index f83c49a4..780cac57 100644
--- a/src/main/java/org/apache/commons/beanutils2/IntrospectionContext.java
+++ b/src/main/java/org/apache/commons/beanutils2/IntrospectionContext.java
@@ -21,16 +21,12 @@ import java.util.Set;
/**
* <p>
- * A context interface used during introspection for querying and setting
- * property descriptors.
+ * A context interface used during introspection for querying and setting property descriptors.
* </p>
* <p>
- * An implementation of this interface is passed to {@link BeanIntrospector}
- * objects during processing of a bean class. It allows the
- * {@code BeanIntrospector} to deliver descriptors for properties it has
- * detected. It is also possible to find out which properties have already been
- * found by another {@code BeanIntrospector}; this allows multiple
- * {@code BeanIntrospector} instances to collaborate.
+ * An implementation of this interface is passed to {@link BeanIntrospector} objects during processing of a bean class. It allows the {@code BeanIntrospector}
+ * to deliver descriptors for properties it has detected. It is also possible to find out which properties have already been found by another
+ * {@code BeanIntrospector}; this allows multiple {@code BeanIntrospector} instances to collaborate.
* </p>
*
* @since 1.9
@@ -38,30 +34,25 @@ import java.util.Set;
public interface IntrospectionContext {
/**
- * Adds the given property descriptor to this context. This method is called
- * by a {@code BeanIntrospector} during introspection for each detected
- * property. If this context already contains a descriptor for the affected
- * property, it is overridden.
+ * Adds the given property descriptor to this context. This method is called by a {@code BeanIntrospector} during introspection for each detected property.
+ * If this context already contains a descriptor for the affected property, it is overridden.
*
* @param desc the property descriptor
*/
void addPropertyDescriptor(PropertyDescriptor desc);
/**
- * Adds an array of property descriptors to this context. Using this method
- * multiple descriptors can be added at once.
+ * Adds an array of property descriptors to this context. Using this method multiple descriptors can be added at once.
*
* @param descriptors the array of descriptors to be added
*/
void addPropertyDescriptors(PropertyDescriptor[] descriptors);
/**
- * Returns the descriptor for the property with the given name or
- * <b>null</b> if this property is unknown.
+ * Returns the descriptor for the property with the given name or <b>null</b> if this property is unknown.
*
* @param name the name of the property in question
- * @return the descriptor for this property or <b>null</b> if this property
- * is unknown
+ * @return the descriptor for this property or <b>null</b> if this property is unknown
*/
PropertyDescriptor getPropertyDescriptor(String name);
@@ -73,13 +64,11 @@ public interface IntrospectionContext {
Class<?> getTargetClass();
/**
- * Tests whether a descriptor for the property with the given name is
- * already contained in this context. This method can be used for instance
- * to prevent that an already existing property descriptor is overridden.
+ * Tests whether a descriptor for the property with the given name is already contained in this context. This method can be used for instance to prevent
+ * that an already existing property descriptor is overridden.
*
* @param name the name of the property in question
- * @return <b>true</b> if a descriptor for this property has already been
- * added, <b>false</b> otherwise
+ * @return <b>true</b> if a descriptor for this property has already been added, <b>false</b> otherwise
*/
boolean hasProperty(String name);
diff --git a/src/main/java/org/apache/commons/beanutils2/LazyDynaBean.java b/src/main/java/org/apache/commons/beanutils2/LazyDynaBean.java
index ac8317ae..3fbf6224 100644
--- a/src/main/java/org/apache/commons/beanutils2/LazyDynaBean.java
+++ b/src/main/java/org/apache/commons/beanutils2/LazyDynaBean.java
@@ -30,11 +30,13 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- * <p>DynaBean which automatically adds properties to the {@code DynaClass}
- * and provides <em>Lazy List</em> and <em>Lazy Map</em> features.</p>
+ * <p>
+ * DynaBean which automatically adds properties to the {@code DynaClass} and provides <em>Lazy List</em> and <em>Lazy Map</em> features.
+ * </p>
*
- * <p>DynaBeans deal with three types of properties - <em>simple</em>, <em>indexed</em> and <em>mapped</em> and
- * have the following {@code get()</code> and <code>set()} methods for
+ * <p>
+ * DynaBeans deal with three types of properties - <em>simple</em>, <em>indexed</em> and <em>mapped</em> and have the following
+ * {@code get()</code> and <code>set()} methods for
* each of these types:</p>
* <ul>
* <li><em>Simple</em> property methods - {@code get(name)} and
@@ -113,10 +115,10 @@ import org.apache.commons.logging.LogFactory;
* }</pre>
*
* <p><b><u><em>Restricted</em> DynaClass</u></b></p>
- * <p>{@code MutableDynaClass</code> have a facility to <em>restrict</em> the <code>DynaClass}
- * so that its properties cannot be modified. If the {@code MutableDynaClass} is
- * restricted then calling any of the {@code set()} methods for a property which
- * doesn't exist will result in a {@code IllegalArgumentException} being thrown.</p>
+ * <p>{@code MutableDynaClass</code> have a facility to <em>restrict</em> the <code>DynaClass} so that its properties cannot be modified. If the
+ * {@code MutableDynaClass} is restricted then calling any of the {@code set()} methods for a property which doesn't exist will result in a
+ * {@code IllegalArgumentException} being thrown.
+ * </p>
*
* @see LazyDynaClass
*/
@@ -124,9 +126,9 @@ public class LazyDynaBean implements DynaBean {
private static final long serialVersionUID = 1L;
- /**
- * Commons Logging
- */
+ /**
+ * Commons Logging
+ */
private static transient Log LOG = LogFactory.getLog(LazyDynaBean.class);
/** BigInteger Zero */
@@ -134,25 +136,24 @@ public class LazyDynaBean implements DynaBean {
/** BigDecimal Zero */
protected static final BigDecimal BigDecimal_ZERO = new BigDecimal("0");
/** Character Space */
- protected static final Character Character_SPACE = Character.valueOf(' ');
+ protected static final Character Character_SPACE = Character.valueOf(' ');
/** Byte Zero */
- protected static final Byte Byte_ZERO = Byte.valueOf((byte)0);
+ protected static final Byte Byte_ZERO = Byte.valueOf((byte) 0);
/** Short Zero */
- protected static final Short Short_ZERO = Short.valueOf((short)0);
+ protected static final Short Short_ZERO = Short.valueOf((short) 0);
/** Integer Zero */
- protected static final Integer Integer_ZERO = Integer.valueOf(0);
+ protected static final Integer Integer_ZERO = Integer.valueOf(0);
/** Long Zero */
- protected static final Long Long_ZERO = Long.valueOf(0);
+ protected static final Long Long_ZERO = Long.valueOf(0);
/** Float Zero */
- protected static final Float Float_ZERO = Float.valueOf((byte)0);
+ protected static final Float Float_ZERO = Float.valueOf((byte) 0);
/** Double Zero */
- protected static final Double Double_ZERO = Double.valueOf((byte)0);
+ protected static final Double Double_ZERO = Double.valueOf((byte) 0);
static final LazyDynaBean[] EMPTY_ARRAY = {};
/**
- * The {@code MutableDynaClass} "base class" that this DynaBean
- * is associated with.
+ * The {@code MutableDynaClass} "base class" that this DynaBean is associated with.
*/
protected Map<String, Object> values;
@@ -160,8 +161,7 @@ public class LazyDynaBean implements DynaBean {
private transient Map<String, Object> mapDecorator;
/**
- * The {@code MutableDynaClass} "base class" that this DynaBean
- * is associated with.
+ * The {@code MutableDynaClass} "base class" that this DynaBean is associated with.
*/
protected MutableDynaClass dynaClass;
@@ -173,9 +173,8 @@ public class LazyDynaBean implements DynaBean {
}
/**
- * Constructs a new {@code DynaBean} associated with the specified
- * {@code DynaClass</code> instance - if its not a <code>MutableDynaClass}
- * then a new {@code LazyDynaClass} is created and the properties copied.
+ * Constructs a new {@code DynaBean} associated with the specified {@code DynaClass</code> instance - if its not a <code>MutableDynaClass} then a new
+ * {@code LazyDynaClass} is created and the properties copied.
*
* @param dynaClass The DynaClass we are associated with
*/
@@ -183,7 +182,7 @@ public class LazyDynaBean implements DynaBean {
values = newMap();
if (dynaClass instanceof MutableDynaClass) {
- this.dynaClass = (MutableDynaClass)dynaClass;
+ this.dynaClass = (MutableDynaClass) dynaClass;
} else {
this.dynaClass = new LazyDynaClass(dynaClass.getName(), dynaClass.getDynaProperties());
}
@@ -199,13 +198,11 @@ public class LazyDynaBean implements DynaBean {
}
/**
- * Does the specified mapped property contain a value for the specified
- * key value?
+ * Does the specified mapped property contain a value for the specified key value?
*
* @param name Name of the property to check
- * @param key Name of the key to check
- * @return {@code true} if the mapped property contains a value for
- * the specified key, otherwise {@code false}
+ * @param key Name of the key to check
+ * @return {@code true} if the mapped property contains a value for the specified key, otherwise {@code false}
*
* @throws IllegalArgumentException if no property name is specified
*/
@@ -226,6 +223,7 @@ public class LazyDynaBean implements DynaBean {
/**
* Create a new Instance of a 'DynaBean' Property.
+ *
* @param name The name of the property
* @param type The class of the property
* @return The new value
@@ -233,11 +231,9 @@ public class LazyDynaBean implements DynaBean {
protected Object createDynaBeanProperty(final String name, final Class<?> type) {
try {
return type.newInstance();
- }
- catch (final Exception ex) {
+ } catch (final Exception ex) {
if (logger().isWarnEnabled()) {
- logger().warn("Error instantiating DynaBean property of type '" +
- type.getName() + "' for '" + name + "' ", ex);
+ logger().warn("Error instantiating DynaBean property of type '" + type.getName() + "' for '" + name + "' ", ex);
}
return null;
}
@@ -245,6 +241,7 @@ public class LazyDynaBean implements DynaBean {
/**
* Create a new Instance of an 'Indexed' Property
+ *
* @param name The name of the property
* @param type The class of the property
* @return The new value
@@ -267,17 +264,13 @@ public class LazyDynaBean implements DynaBean {
} else {
try {
indexedProperty = type.newInstance();
- }
- catch (final Exception ex) {
- throw new IllegalArgumentException
- ("Error instantiating indexed property of type '" +
- type.getName() + "' for '" + name + "' " + ex);
+ } catch (final Exception ex) {
+ throw new IllegalArgumentException("Error instantiating indexed property of type '" + type.getName() + "' for '" + name + "' " + ex);
}
}
} else {
- throw new IllegalArgumentException
- ("Non-indexed property of type '" + type.getName() + "' for '" + name + "'");
+ throw new IllegalArgumentException("Non-indexed property of type '" + type.getName() + "' for '" + name + "'");
}
return indexedProperty;
@@ -285,6 +278,7 @@ public class LazyDynaBean implements DynaBean {
/**
* Create a new Instance of a 'Mapped' Property
+ *
* @param name The name of the property
* @param type The class of the property
* @return The new value
@@ -300,16 +294,12 @@ public class LazyDynaBean implements DynaBean {
} else if (Map.class.isAssignableFrom(type)) {
try {
mappedProperty = type.newInstance();
- }
- catch (final Exception ex) {
- throw new IllegalArgumentException
- ("Error instantiating mapped property of type '" +
- type.getName() + "' for '" + name + "' " + ex);
+ } catch (final Exception ex) {
+ throw new IllegalArgumentException("Error instantiating mapped property of type '" + type.getName() + "' for '" + name + "' " + ex);
}
} else {
- throw new IllegalArgumentException
- ("Non-mapped property of type '" + type.getName() + "' for '" + name + "'");
+ throw new IllegalArgumentException("Non-mapped property of type '" + type.getName() + "' for '" + name + "'");
}
return mappedProperty;
@@ -317,6 +307,7 @@ public class LazyDynaBean implements DynaBean {
/**
* Create a new Instance of a {@link Number} Property.
+ *
* @param name The name of the property
* @param type The class of the property
* @return The new value
@@ -327,16 +318,13 @@ public class LazyDynaBean implements DynaBean {
/**
* Create a new Instance of other Property types
+ *
* @param name The name of the property
* @param type The class of the property
* @return The new value
*/
protected Object createOtherProperty(final String name, final Class<?> type) {
- if (type == Object.class ||
- type == String.class ||
- type == Boolean.class ||
- type == Character.class ||
- Date.class.isAssignableFrom(type)) {
+ if (type == Object.class || type == String.class || type == Boolean.class || type == Character.class || Date.class.isAssignableFrom(type)) {
return null;
@@ -344,8 +332,7 @@ public class LazyDynaBean implements DynaBean {
try {
return type.newInstance();
- }
- catch (final Exception ex) {
+ } catch (final Exception ex) {
if (logger().isWarnEnabled()) {
logger().warn("Error instantiating property of type '" + type.getName() + "' for '" + name + "' ", ex);
}
@@ -355,6 +342,7 @@ public class LazyDynaBean implements DynaBean {
/**
* Create a new Instance of a 'Primitive' Property.
+ *
* @param name The name of the property
* @param type The class of the property
* @return The new value
@@ -389,6 +377,7 @@ public class LazyDynaBean implements DynaBean {
/**
* Create a new Instance of a Property
+ *
* @param name The name of the property
* @param type The class of the property
* @return The new value
@@ -423,11 +412,13 @@ public class LazyDynaBean implements DynaBean {
}
/**
- * <p>Creates a new {@code ArrayList} for an 'indexed' property
- * which doesn't exist.</p>
+ * <p>
+ * Creates a new {@code ArrayList} for an 'indexed' property which doesn't exist.
+ * </p>
*
- * <p>This method should be overridden if an alternative {@code List}
- * or {@code Array} implementation is required for 'indexed' properties.</p>
+ * <p>
+ * This method should be overridden if an alternative {@code List} or {@code Array} implementation is required for 'indexed' properties.
+ * </p>
*
* @param name Name of the 'indexed property.
* @return The default value for an indexed property (java.util.ArrayList)
@@ -437,11 +428,13 @@ public class LazyDynaBean implements DynaBean {
}
/**
- * <p>Creates a new {@code HashMap} for a 'mapped' property
- * which doesn't exist.</p>
+ * <p>
+ * Creates a new {@code HashMap} for a 'mapped' property which doesn't exist.
+ * </p>
*
- * <p>This method can be overridden if an alternative {@code Map}
- * implementation is required for 'mapped' properties.</p>
+ * <p>
+ * This method can be overridden if an alternative {@code Map} implementation is required for 'mapped' properties.
+ * </p>
*
* @param name Name of the 'mapped property.
* @return The default value for a mapped property (java.util.HashMap)
@@ -451,10 +444,13 @@ public class LazyDynaBean implements DynaBean {
}
/**
- * <p>Return the value of a simple property with the specified name.</p>
+ * <p>
+ * Return the value of a simple property with the specified name.
+ * </p>
*
- * <p><strong>N.B.</strong> Returns {@code null} if there is no property
- * of the specified name.</p>
+ * <p>
+ * <strong>N.B.</strong> Returns {@code null} if there is no property of the specified name.
+ * </p>
*
* @param name Name of the property whose value is to be retrieved.
* @return The property's value
@@ -485,19 +481,20 @@ public class LazyDynaBean implements DynaBean {
}
/**
- * <p>Return the value of an indexed property with the specified name.</p>
+ * <p>
+ * Return the value of an indexed property with the specified name.
+ * </p>
*
- * <p><strong>N.B.</strong> Returns {@code null} if there is no 'indexed'
- * property of the specified name.</p>
+ * <p>
+ * <strong>N.B.</strong> Returns {@code null} if there is no 'indexed' property of the specified name.
+ * </p>
*
- * @param name Name of the property whose value is to be retrieved
+ * @param name Name of the property whose value is to be retrieved
* @param index Index of the value to be retrieved
* @return The indexed property's value
*
- * @throws IllegalArgumentException if the specified property
- * exists, but is not indexed
- * @throws IndexOutOfBoundsException if the specified index
- * is outside the range of the underlying property
+ * @throws IllegalArgumentException if the specified property exists, but is not indexed
+ * @throws IndexOutOfBoundsException if the specified index is outside the range of the underlying property
*/
@Override
public Object get(final String name, final int index) {
@@ -511,9 +508,7 @@ public class LazyDynaBean implements DynaBean {
// Check that the property is indexed
if (!dynaClass.getDynaProperty(name).isIndexed()) {
- throw new IllegalArgumentException
- ("Non-indexed property for '" + name + "[" + index + "]' "
- + dynaClass.getDynaProperty(name).getName());
+ throw new IllegalArgumentException("Non-indexed property for '" + name + "[" + index + "]' " + dynaClass.getDynaProperty(name).getName());
}
// Grow indexed property to appropriate size
@@ -524,25 +519,25 @@ public class LazyDynaBean implements DynaBean {
return Array.get(indexedProperty, index);
}
if (indexedProperty instanceof List) {
- return ((List<?>)indexedProperty).get(index);
+ return ((List<?>) indexedProperty).get(index);
}
- throw new IllegalArgumentException
- ("Non-indexed property for '" + name + "[" + index + "]' "
- + indexedProperty.getClass().getName());
+ throw new IllegalArgumentException("Non-indexed property for '" + name + "[" + index + "]' " + indexedProperty.getClass().getName());
}
/**
- * <p>Return the value of a mapped property with the specified name.</p>
+ * <p>
+ * Return the value of a mapped property with the specified name.
+ * </p>
*
- * <p><strong>N.B.</strong> Returns {@code null} if there is no 'mapped'
- * property of the specified name.</p>
+ * <p>
+ * <strong>N.B.</strong> Returns {@code null} if there is no 'mapped' property of the specified name.
+ * </p>
*
* @param name Name of the property whose value is to be retrieved
- * @param key Key of the value to be retrieved
+ * @param key Key of the value to be retrieved
* @return The mapped property's value
*
- * @throws IllegalArgumentException if the specified property
- * exists, but is not mapped
+ * @throws IllegalArgumentException if the specified property exists, but is not mapped
*/
@Override
public Object get(final String name, final String key) {
@@ -556,23 +551,18 @@ public class LazyDynaBean implements DynaBean {
// Check that the property is mapped
if (!dynaClass.getDynaProperty(name).isMapped()) {
- throw new IllegalArgumentException
- ("Non-mapped property for '" + name + "(" + key + ")' "
- + dynaClass.getDynaProperty(name).getType().getName());
+ throw new IllegalArgumentException("Non-mapped property for '" + name + "(" + key + ")' " + dynaClass.getDynaProperty(name).getType().getName());
}
// Get the value from the Map
if (mappedProperty instanceof Map) {
return ((Map<?, ?>) mappedProperty).get(key);
}
- throw new IllegalArgumentException
- ("Non-mapped property for '" + name + "(" + key + ")'"
- + mappedProperty.getClass().getName());
+ throw new IllegalArgumentException("Non-mapped property for '" + name + "(" + key + ")'" + mappedProperty.getClass().getName());
}
/**
- * Gets the {@code DynaClass} instance that describes the set of
- * properties available for this DynaBean.
+ * Gets the {@code DynaClass} instance that describes the set of properties available for this DynaBean.
*
* @return The associated DynaClass
*/
@@ -585,9 +575,10 @@ public class LazyDynaBean implements DynaBean {
* <p>
* Gets a Map representation of this DynaBean.
* </p>
- * This, for example, could be used in JSTL in the following way to access
- * a DynaBean's {@code fooProperty}:
- * <ul><li>{@code ${myDynaBean.<b>map</b>.fooProperty}}</li></ul>
+ * This, for example, could be used in JSTL in the following way to access a DynaBean's {@code fooProperty}:
+ * <ul>
+ * <li>{@code ${myDynaBean.<b>map</b>.fooProperty}}</li>
+ * </ul>
*
* @return a Map representation of this DynaBean
*/
@@ -601,10 +592,10 @@ public class LazyDynaBean implements DynaBean {
/**
* Grow the size of an indexed property
- * @param name The name of the property
+ *
+ * @param name The name of the property
* @param indexedProperty The current property value
- * @param index The indexed value to grow the property to (i.e. one less than
- * the required size)
+ * @param index The indexed value to grow the property to (i.e. one less than the required size)
* @return The new property value (grown to the appropriate size)
*/
protected Object growIndexedProperty(final String name, Object indexedProperty, final int index) {
@@ -614,12 +605,12 @@ public class LazyDynaBean implements DynaBean {
@SuppressWarnings("unchecked")
final
// Indexed properties are stored as List<Object>
- List<Object> list = (List<Object>)indexedProperty;
+ List<Object> list = (List<Object>) indexedProperty;
while (index >= list.size()) {
final Class<?> contentType = getDynaClass().getDynaProperty(name).getContentType();
Object value = null;
if (contentType != null) {
- value = createProperty(name+"["+list.size()+"]", contentType);
+ value = createProperty(name + "[" + list.size() + "]", contentType);
}
list.add(value);
}
@@ -638,7 +629,7 @@ public class LazyDynaBean implements DynaBean {
set(name, indexedProperty);
final int newLength = Array.getLength(indexedProperty);
for (int i = length; i < newLength; i++) {
- Array.set(indexedProperty, i, createProperty(name+"["+i+"]", componentType));
+ Array.set(indexedProperty, i, createProperty(name + "[" + i + "]", componentType));
}
}
}
@@ -649,21 +640,15 @@ public class LazyDynaBean implements DynaBean {
/**
* Is an object of the source class assignable to the destination class?
*
- * @param dest Destination class
+ * @param dest Destination class
* @param source Source class
- * @return {@code true} if the source class is assignable to the
- * destination class, otherwise {@code false}
+ * @return {@code true} if the source class is assignable to the destination class, otherwise {@code false}
*/
protected boolean isAssignable(final Class<?> dest, final Class<?> source) {
- if (dest.isAssignableFrom(source) ||
- dest == Boolean.TYPE && source == Boolean.class ||
- dest == Byte.TYPE && source == Byte.class ||
- dest == Character.TYPE && source == Character.class ||
- dest == Double.TYPE && source == Double.class ||
- dest == Float.TYPE && source == Float.class ||
- dest == Integer.TYPE && source == Integer.class ||
- dest == Long.TYPE && source == Long.class ||
- dest == Short.TYPE && source == Short.class) {
+ if (dest.isAssignableFrom(source) || dest == Boolean.TYPE && source == Boolean.class || dest == Byte.TYPE && source == Byte.class
+ || dest == Character.TYPE && source == Character.class || dest == Double.TYPE && source == Double.class
+ || dest == Float.TYPE && source == Float.class || dest == Integer.TYPE && source == Integer.class || dest == Long.TYPE && source == Long.class
+ || dest == Short.TYPE && source == Short.class) {
return true;
}
return false;
@@ -672,22 +657,23 @@ public class LazyDynaBean implements DynaBean {
/**
* Indicates if there is a property with the specified name.
+ *
* @param name The name of the property to check
- * @return {@code true} if there is a property of the
- * specified name, otherwise {@code false}
+ * @return {@code true} if there is a property of the specified name, otherwise {@code false}
*/
protected boolean isDynaProperty(final String name) {
Objects.requireNonNull(name, "name");
// Handle LazyDynaClasses
if (dynaClass instanceof LazyDynaClass) {
- return ((LazyDynaClass)dynaClass).isDynaProperty(name);
+ return ((LazyDynaClass) dynaClass).isDynaProperty(name);
}
// Handle other MutableDynaClass
return dynaClass.getDynaProperty(name) != null;
}
/**
- * <p>Returns the {@code Log}.
+ * <p>
+ * Returns the {@code Log}.
*/
private Log logger() {
if (LOG == null) {
@@ -697,7 +683,10 @@ public class LazyDynaBean implements DynaBean {
}
/**
- * <p>Creates a new instance of the {@code Map}.</p>
+ * <p>
+ * Creates a new instance of the {@code Map}.
+ * </p>
+ *
* @return a new Map instance
*/
protected Map<String, Object> newMap() {
@@ -705,15 +694,12 @@ public class LazyDynaBean implements DynaBean {
}
/**
- * Remove any existing value for the specified key on the
- * specified mapped property.
+ * Remove any existing value for the specified key on the specified mapped property.
*
- * @param name Name of the property for which a value is to
- * be removed
- * @param key Key of the value to be removed
+ * @param name Name of the property for which a value is to be removed
+ * @param key Key of the value to be removed
*
- * @throws IllegalArgumentException if there is no property
- * of the specified name
+ * @throws IllegalArgumentException if there is no property of the specified name
*/
@Override
public void remove(final String name, final String key) {
@@ -727,9 +713,7 @@ public class LazyDynaBean implements DynaBean {
}
if (!(value instanceof Map)) {
- throw new IllegalArgumentException
- ("Non-mapped property for '" + name + "(" + key + ")'"
- + value.getClass().getName());
+ throw new IllegalArgumentException("Non-mapped property for '" + name + "(" + key + ")'" + value.getClass().getName());
}
((Map<?, ?>) value).remove(key);
}
@@ -737,18 +721,14 @@ public class LazyDynaBean implements DynaBean {
/**
* Sets the value of an indexed property with the specified name.
*
- * @param name Name of the property whose value is to be set
+ * @param name Name of the property whose value is to be set
* @param index Index of the property to be set
* @param value Value to which this property is to be set
*
- * @throws ConversionException if the specified value cannot be
- * converted to the type required for this property
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws IllegalArgumentException if the specified property
- * exists, but is not indexed
- * @throws IndexOutOfBoundsException if the specified index
- * is outside the range of the underlying property
+ * @throws ConversionException if the specified value cannot be converted to the type required for this property
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws IllegalArgumentException if the specified property exists, but is not indexed
+ * @throws IndexOutOfBoundsException if the specified index is outside the range of the underlying property
*/
@Override
public void set(final String name, final int index, final Object value) {
@@ -762,9 +742,7 @@ public class LazyDynaBean implements DynaBean {
// Check that the property is indexed
if (!dynaClass.getDynaProperty(name).isIndexed()) {
- throw new IllegalArgumentException
- ("Non-indexed property for '" + name + "[" + index + "]'"
- + dynaClass.getDynaProperty(name).getType().getName());
+ throw new IllegalArgumentException("Non-indexed property for '" + name + "[" + index + "]'" + dynaClass.getDynaProperty(name).getType().getName());
}
// Grow indexed property to appropriate size
@@ -780,24 +758,19 @@ public class LazyDynaBean implements DynaBean {
List<Object> values = (List<Object>) indexedProperty;
values.set(index, value);
} else {
- throw new IllegalArgumentException
- ("Non-indexed property for '" + name + "[" + index + "]' "
- + indexedProperty.getClass().getName());
+ throw new IllegalArgumentException("Non-indexed property for '" + name + "[" + index + "]' " + indexedProperty.getClass().getName());
}
}
/**
* Sets the value of a simple property with the specified name.
*
- * @param name Name of the property whose value is to be set
+ * @param name Name of the property whose value is to be set
* @param value Value to which this property is to be set
*
- * @throws IllegalArgumentException if this is not an existing property
- * name for our DynaClass and the MutableDynaClass is restricted
- * @throws ConversionException if the specified value cannot be
- * converted to the type required for this property
- * @throws NullPointerException if an attempt is made to set a
- * primitive property to null
+ * @throws IllegalArgumentException if this is not an existing property name for our DynaClass and the MutableDynaClass is restricted
+ * @throws ConversionException if the specified value cannot be converted to the type required for this property
+ * @throws NullPointerException if an attempt is made to set a primitive property to null
*/
@Override
public void set(final String name, final Object value) {
@@ -805,8 +778,7 @@ public class LazyDynaBean implements DynaBean {
if (!isDynaProperty(name)) {
if (dynaClass.isRestricted()) {
- throw new IllegalArgumentException
- ("Invalid property name '" + name + "' (DynaClass is restricted)");
+ throw new IllegalArgumentException("Invalid property name '" + name + "' (DynaClass is restricted)");
}
if (value == null) {
dynaClass.add(name);
@@ -820,12 +792,11 @@ public class LazyDynaBean implements DynaBean {
if (value == null) {
if (descriptor.getType().isPrimitive()) {
- throw new NullPointerException
- ("Primitive value for '" + name + "'");
+ throw new NullPointerException("Primitive value for '" + name + "'");
}
} else if (!isAssignable(descriptor.getType(), value.getClass())) {
- throw ConversionException.format
- ("Cannot assign value of type '%s' to property '%s' of type '%s'", value.getClass().getName(), name, descriptor.getType().getName());
+ throw ConversionException.format("Cannot assign value of type '%s' to property '%s' of type '%s'", value.getClass().getName(), name,
+ descriptor.getType().getName());
}
// Set the property's value
@@ -835,16 +806,13 @@ public class LazyDynaBean implements DynaBean {
/**
* Sets the value of a mapped property with the specified name.
*
- * @param name Name of the property whose value is to be set
- * @param key Key of the property to be set
+ * @param name Name of the property whose value is to be set
+ * @param key Key of the property to be set
* @param value Value to which this property is to be set
*
- * @throws ConversionException if the specified value cannot be
- * converted to the type required for this property
- * @throws IllegalArgumentException if there is no property
- * of the specified name
- * @throws IllegalArgumentException if the specified property
- * exists, but is not mapped
+ * @throws ConversionException if the specified value cannot be converted to the type required for this property
+ * @throws IllegalArgumentException if there is no property of the specified name
+ * @throws IllegalArgumentException if the specified property exists, but is not mapped
*/
@SuppressWarnings("unchecked")
@Override
@@ -866,7 +834,9 @@ public class LazyDynaBean implements DynaBean {
}
/**
- * <p>Return the size of an indexed or mapped property.</p>
+ * <p>
+ * Return the size of an indexed or mapped property.
+ * </p>
*
* @param name Name of the property
* @return The indexed or mapped property size
@@ -880,11 +850,11 @@ public class LazyDynaBean implements DynaBean {
}
if (value instanceof Map) {
- return ((Map<?, ?>)value).size();
+ return ((Map<?, ?>) value).size();
}
if (value instanceof List) {
- return ((List<?>)value).size();
+ return ((List<?>) value).size();
}
if (value.getClass().isArray()) {
diff --git a/src/main/java/org/apache/commons/beanutils2/LazyDynaClass.java b/src/main/java/org/apache/commons/beanutils2/LazyDynaClass.java
index 9f81c954..f0bf2046 100644
--- a/src/main/java/org/apache/commons/beanutils2/LazyDynaClass.java
+++ b/src/main/java/org/apache/commons/beanutils2/LazyDynaClass.java
@@ -20,31 +20,31 @@ import java.util.Arrays;
import java.util.Objects;
/**
- * <p>DynaClass which implements the {@code MutableDynaClass} interface.</p>
+ * <p>
+ * DynaClass which implements the {@code MutableDynaClass} interface.
+ * </p>
*
- * <p>A {@code MutableDynaClass</code> is a specialized extension to <code>DynaClass}
+ * <p>
+ * A {@code MutableDynaClass</code> is a specialized extension to <code>DynaClass}
* that allows properties to be added or removed dynamically.</p>
*
* <p>This implementation has one slightly unusual default behavior - calling
* the {@code getDynaProperty(name)} method for a property which doesn't
- * exist returns a {@code DynaProperty</code> rather than <code>null}. The
- * reason for this is that {@code BeanUtils} calls this method to check if
- * a property exists before trying to set the value. This would defeat the object
- * of the {@code LazyDynaBean} which automatically adds missing properties
- * when any of its {@code set()} methods are called. For this reason the
- * {@code isDynaProperty(name)} method has been added to this implementation
- * in order to determine if a property actually exists. If the more <em>normal</em>
- * behavior of returning {@code null} is required, then this can be achieved
- * by calling the {@code setReturnNull(true)}.</p>
+ * exist returns a {@code DynaProperty</code> rather than <code>null}. The reason for this is that {@code BeanUtils} calls this method to check if a property
+ * exists before trying to set the value. This would defeat the object of the {@code LazyDynaBean} which automatically adds missing properties when any of its
+ * {@code set()} methods are called. For this reason the {@code isDynaProperty(name)} method has been added to this implementation in order to determine if a
+ * property actually exists. If the more <em>normal</em> behavior of returning {@code null} is required, then this can be achieved by calling the
+ * {@code setReturnNull(true)}.
+ * </p>
*
- * <p>The {@code add(name, type, readable, writable)} method is not implemented
- * and always throws an {@code UnsupportedOperationException}. I believe
- * this attributes need to be added to the {@code DynaProperty} class
- * in order to control read/write facilities.</p>
+ * <p>
+ * The {@code add(name, type, readable, writable)} method is not implemented and always throws an {@code UnsupportedOperationException}. I believe this
+ * attributes need to be added to the {@code DynaProperty} class in order to control read/write facilities.
+ * </p>
*
* @see LazyDynaBean
*/
-public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
+public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
private static final long serialVersionUID = 1L;
@@ -54,10 +54,12 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
protected boolean restricted;
/**
- * <p>Controls whether the {@code getDynaProperty()} method returns
- * null if a property doesn't exist - or creates a new one.</p>
+ * <p>
+ * Controls whether the {@code getDynaProperty()} method returns null if a property doesn't exist - or creates a new one.
+ * </p>
*
- * <p>Default is {@code false}.
+ * <p>
+ * Default is {@code false}.
*/
protected boolean returnNull;
@@ -65,7 +67,7 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
* Constructs a new LazyDynaClass with default parameters.
*/
public LazyDynaClass() {
- this(null, (DynaProperty[])null);
+ this(null, (DynaProperty[]) null);
}
/**
@@ -74,13 +76,13 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
* @param name Name of this DynaBean class
*/
public LazyDynaClass(final String name) {
- this(name, (DynaProperty[])null);
+ this(name, (DynaProperty[]) null);
}
/**
* Constructs a new LazyDynaClass with the specified name and DynaBean class.
*
- * @param name Name of this DynaBean class
+ * @param name Name of this DynaBean class
* @param dynaBeanClass The implementation class for new instances
*/
public LazyDynaClass(final String name, final Class<?> dynaBeanClass) {
@@ -90,9 +92,9 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
/**
* Constructs a new LazyDynaClass with the specified name, DynaBean class and properties.
*
- * @param name Name of this DynaBean class
+ * @param name Name of this DynaBean class
* @param dynaBeanClass The implementation class for new instances
- * @param properties Property descriptors for the supported properties
+ * @param properties Property descriptors for the supported properties
*/
public LazyDynaClass(final String name, final Class<?> dynaBeanClass, final DynaProperty[] properties) {
super(name, dynaBeanClass, properties);
@@ -101,7 +103,7 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
/**
* Constructs a new LazyDynaClass with the specified name and properties.
*
- * @param name Name of this DynaBean class
+ * @param name Name of this DynaBean class
* @param properties Property descriptors for the supported properties
*/
public LazyDynaClass(final String name, final DynaProperty[] properties) {
@@ -114,8 +116,7 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
* @param property Property the new dynamic property to add.
*
* @throws IllegalArgumentException if name is null
- * @throws IllegalStateException if this DynaClass is currently
- * restricted, so no new properties can be added
+ * @throws IllegalStateException if this DynaClass is currently restricted, so no new properties can be added
*/
protected void add(final DynaProperty property) {
Objects.requireNonNull(property, "property");
@@ -136,14 +137,12 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
}
/**
- * Add a new dynamic property with no restrictions on data type,
- * readability, or writeability.
+ * Add a new dynamic property with no restrictions on data type, readability, or writeability.
*
* @param name Name of the new dynamic property
*
* @throws IllegalArgumentException if name is null
- * @throws IllegalStateException if this DynaClass is currently
- * restricted, so no new properties can be added
+ * @throws IllegalStateException if this DynaClass is currently restricted, so no new properties can be added
*/
@Override
public void add(final String name) {
@@ -151,16 +150,13 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
}
/**
- * Add a new dynamic property with the specified data type, but with
- * no restrictions on readability or writeability.
+ * Add a new dynamic property with the specified data type, but with no restrictions on readability or writeability.
*
* @param name Name of the new dynamic property
- * @param type Data type of the new dynamic property (null for no
- * restrictions)
+ * @param type Data type of the new dynamic property (null for no restrictions)
*
* @throws IllegalArgumentException if name is null
- * @throws IllegalStateException if this DynaClass is currently
- * restricted, so no new properties can be added
+ * @throws IllegalStateException if this DynaClass is currently restricted, so no new properties can be added
*/
@Override
public void add(final String name, final Class<?> type) {
@@ -172,23 +168,24 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
}
/**
- * <p>Add a new dynamic property with the specified data type, readability,
- * and writeability.</p>
+ * <p>
+ * Add a new dynamic property with the specified data type, readability, and writeability.
+ * </p>
*
- * <p><strong>N.B.</strong>Support for readable/writable properties has not been implemented
- * and this method always throws a {@code UnsupportedOperationException}.</p>
+ * <p>
+ * <strong>N.B.</strong>Support for readable/writable properties has not been implemented and this method always throws a
+ * {@code UnsupportedOperationException}.
+ * </p>
*
- * <p>I'm not sure the intention of the original authors for this method, but it seems to
- * me that readable/writable should be attributes of the {@code DynaProperty} class
- * (which they are not) and is the reason this method has not been implemented.</p>
+ * <p>
+ * I'm not sure the intention of the original authors for this method, but it seems to me that readable/writable should be attributes of the
+ * {@code DynaProperty} class (which they are not) and is the reason this method has not been implemented.
+ * </p>
*
- * @param name Name of the new dynamic property
- * @param type Data type of the new dynamic property (null for no
- * restrictions)
- * @param readable Set to {@code true} if this property value
- * should be readable
- * @param writable Set to {@code true} if this property value
- * should be writable
+ * @param name Name of the new dynamic property
+ * @param type Data type of the new dynamic property (null for no restrictions)
+ * @param readable Set to {@code true} if this property value should be readable
+ * @param writable Set to {@code true} if this property value should be writable
*
* @throws UnsupportedOperationException anytime this method is called
*/
@@ -198,24 +195,26 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
}
/**
- * <p>Return a property descriptor for the specified property.</p>
+ * <p>
+ * Return a property descriptor for the specified property.
+ * </p>
*
- * <p>If the property is not found and the {@code returnNull} indicator is
- * {@code true</code>, this method always returns <code>null}.</p>
+ * <p>
+ * If the property is not found and the {@code returnNull} indicator is {@code true</code>, this method always returns <code>null}.
+ * </p>
*
- * <p>If the property is not found and the {@code returnNull} indicator is
- * {@code false} a new property descriptor is created and returned (although
- * its not actually added to the DynaClass's properties). This is the default
- * behavior.</p>
+ * <p>
+ * If the property is not found and the {@code returnNull} indicator is {@code false} a new property descriptor is created and returned (although its not
+ * actually added to the DynaClass's properties). This is the default behavior.
+ * </p>
*
- * <p>The reason for not returning a {@code null} property descriptor is that
- * {@code BeanUtils} uses this method to check if a property exists
- * before trying to set it - since these <em>Lazy</em> implementations automatically
- * add any new properties when they are set, returning {@code null} from
- * this method would defeat their purpose.</p>
+ * <p>
+ * The reason for not returning a {@code null} property descriptor is that {@code BeanUtils} uses this method to check if a property exists before trying to
+ * set it - since these <em>Lazy</em> implementations automatically add any new properties when they are set, returning {@code null} from this method would
+ * defeat their purpose.
+ * </p>
*
- * @param name Name of the dynamic property for which a descriptor
- * is requested
+ * @param name Name of the dynamic property for which a descriptor is requested
* @return The dyna property for the specified name
*
* @throws IllegalArgumentException if no property name is specified
@@ -233,16 +232,17 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
}
/**
- * <p>Indicate whether a property actually exists.</p>
+ * <p>
+ * Indicate whether a property actually exists.
+ * </p>
*
- * <p><strong>N.B.</strong> Using {@code getDynaProperty(name) == null}
- * doesn't work in this implementation because that method might
- * return a DynaProperty if it doesn't exist (depending on the
- * {@code returnNull} indicator).</p>
+ * <p>
+ * <strong>N.B.</strong> Using {@code getDynaProperty(name) == null} doesn't work in this implementation because that method might return a DynaProperty if
+ * it doesn't exist (depending on the {@code returnNull} indicator).
+ * </p>
*
* @param name The name of the property to check
- * @return {@code true} if there is a property of the
- * specified name, otherwise {@code false}
+ * @return {@code true} if there is a property of the specified name, otherwise {@code false}
* @throws IllegalArgumentException if no property name is specified
*/
public boolean isDynaProperty(final String name) {
@@ -250,11 +250,14 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
}
/**
- * <p>Is this DynaClass currently restricted.</p>
- * <p>If restricted, no changes to the existing registration of
- * property names, data types, readability, or writeability are allowed.</p>
- * @return {@code true} if this {@link MutableDynaClass} cannot be changed
- * otherwise {@code false}
+ * <p>
+ * Is this DynaClass currently restricted.
+ * </p>
+ * <p>
+ * If restricted, no changes to the existing registration of property names, data types, readability, or writeability are allowed.
+ * </p>
+ *
+ * @return {@code true} if this {@link MutableDynaClass} cannot be changed otherwise {@code false}
*/
@Override
public boolean isRestricted() {
@@ -262,30 +265,23 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
}
/**
- * Should this DynaClass return a {@code null} from
- * the {@code getDynaProperty(name)} method if the property
- * doesn't exist.
+ * Should this DynaClass return a {@code null} from the {@code getDynaProperty(name)} method if the property doesn't exist.
*
- * @return {@code true</code> if a <code>null} {@link DynaProperty}
- * should be returned if the property doesn't exist, otherwise
- * {@code false} if a new {@link DynaProperty} should be created.
+ * @return {@code true</code> if a <code>null} {@link DynaProperty} should be returned if the property doesn't exist, otherwise {@code false} if a new
+ * {@link DynaProperty} should be created.
*/
public boolean isReturnNull() {
return returnNull;
}
/**
- * Remove the specified dynamic property, and any associated data type,
- * readability, and writeability, from this dynamic class.
- * <strong>NOTE</strong> - This does <strong>NOT</strong> cause any
- * corresponding property values to be removed from DynaBean instances
- * associated with this DynaClass.
+ * Remove the specified dynamic property, and any associated data type, readability, and writeability, from this dynamic class. <strong>NOTE</strong> - This
+ * does <strong>NOT</strong> cause any corresponding property values to be removed from DynaBean instances associated with this DynaClass.
*
* @param name Name of the dynamic property to remove
*
* @throws IllegalArgumentException if name is null
- * @throws IllegalStateException if this DynaClass is currently
- * restricted, so no properties can be removed
+ * @throws IllegalStateException if this DynaClass is currently restricted, so no properties can be removed
*/
@Override
public void remove(final String name) {
@@ -301,7 +297,7 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
// Create a new property array of without the specified property
final DynaProperty[] oldProperties = getDynaProperties();
- final DynaProperty[] newProperties = new DynaProperty[oldProperties.length-1];
+ final DynaProperty[] newProperties = new DynaProperty[oldProperties.length - 1];
int j = 0;
for (final DynaProperty oldProperty : oldProperties) {
if (!name.equals(oldProperty.getName())) {
@@ -315,11 +311,14 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
}
/**
- * <p>Set whether this DynaClass is currently restricted.</p>
- * <p>If restricted, no changes to the existing registration of
- * property names, data types, readability, or writeability are allowed.</p>
- * @param restricted {@code true} if this {@link MutableDynaClass} cannot
- * be changed otherwise {@code false}
+ * <p>
+ * Set whether this DynaClass is currently restricted.
+ * </p>
+ * <p>
+ * If restricted, no changes to the existing registration of property names, data types, readability, or writeability are allowed.
+ * </p>
+ *
+ * @param restricted {@code true} if this {@link MutableDynaClass} cannot be changed otherwise {@code false}
*/
@Override
public void setRestricted(final boolean restricted) {
@@ -327,15 +326,13 @@ public class LazyDynaClass extends BasicDynaClass implements MutableDynaClass {
}
/**
- * Sets whether this DynaClass should return a {@code null} from
- * the {@code getDynaProperty(name)} method if the property
- * doesn't exist.
- * @param returnNull {@code true</code> if a <code>null} {@link DynaProperty}
- * should be returned if the property doesn't exist, otherwise
- * {@code false} if a new {@link DynaProperty} should be created.
+ * Sets whether this DynaClass should return a {@code null} from the {@code getDynaProperty(name)} method if the property doesn't exist.
+ *
+ * @param returnNull {@code true</code> if a <code>null} {@link DynaProperty} should be returned if the property doesn't exist, otherwise {@code false} if a
+ * new {@link DynaProperty} should be created.
*/
public void setReturnNull(final boolean returnNull) {
this.returnNull = returnNull;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/commons/beanutils2/LazyDynaList.java b/src/main/java/org/apache/commons/beanutils2/LazyDynaList.java
index 0de80d4e..0f423fd1 100644
--- a/src/main/java/org/apache/commons/beanutils2/LazyDynaList.java
+++ b/src/main/java/org/apache/commons/beanutils2/LazyDynaList.java
@@ -26,11 +26,12 @@ import java.util.Objects;
/**
* <h2><em>Lazy</em> DynaBean List.</h2>
*
- * <p>There are two main purposes for this class:</p>
- * <ul>
- * <li>To provide <em>Lazy List</em> behavior - automatically
- * <em>growing</em> and <em>populating</em> the {@code List}
- * with either {@code DynaBean</code>, <code>java.util.Map}
+ * <p>
+ * There are two main purposes for this class:
+ * </p>
+ * <ul>
+ * <li>To provide <em>Lazy List</em> behavior - automatically <em>growing</em> and <em>populating</em> the {@code List} with either
+ * {@code DynaBean</code>, <code>java.util.Map}
* or POJO Beans.</li>
* <li>To provide a straight forward way of putting a Collection
* or Array into the lazy list <em>and</em> a straight forward
@@ -129,31 +130,28 @@ import java.util.Objects;
* }</pre>
*
* <p><strong>N.B.</strong> You may wonder why control the type
- * using a {@code DynaClass</code> rather than the <code>Class}
- * as in the previous example - the reason is that some {@code DynaBean}
- * implementations don't have a <em>default</em> empty constructor and
- * therefore need to be instantiated using the {@code DynaClass.newInstance()}
- * method.</p>
+ * using a {@code DynaClass</code> rather than the <code>Class} as in the previous example - the reason is that some {@code DynaBean} implementations don't
+ * have a <em>default</em> empty constructor and therefore need to be instantiated using the {@code DynaClass.newInstance()} method.
+ * </p>
*
* <h2>Example 4</h2>
- * <p>A slight variation - set the element type using either
- * the {@code setElementType(Class)} method or the
- * {@code setElementDynaClass(DynaClass)} method - then populate
- * with the normal {@link java.util.List} methods (i.e.
- * {@code add()}, {@code addAll()} or {@code set()}).</p>
+ * <p>
+ * A slight variation - set the element type using either the {@code setElementType(Class)} method or the {@code setElementDynaClass(DynaClass)} method - then
+ * populate with the normal {@link java.util.List} methods (i.e. {@code add()}, {@code addAll()} or {@code set()}).
+ * </p>
*
* <pre>{@code
- * // Create a new LazyDynaList (100 element capacity)
- * LazyDynaList lazyList = new LazyDynaList(100);
+ * // Create a new LazyDynaList (100 element capacity)
+ * LazyDynaList lazyList = new LazyDynaList(100);
*
- * // Either Set the element type...
- * lazyList.setElementType(TreeMap.class);
+ * // Either Set the element type...
+ * lazyList.setElementType(TreeMap.class);
*
- * // ...or the element DynaClass...
- * lazyList.setElementDynaClass(new MyCustomDynaClass());
+ * // ...or the element DynaClass...
+ * lazyList.setElementDynaClass(new MyCustomDynaClass());
*
- * // Populate from a collection
- * lazyList.addAll(myCollection);
+ * // Populate from a collection
+ * lazyList.addAll(myCollection);
*
* }</pre>
*
@@ -169,12 +167,9 @@ public class LazyDynaList extends ArrayList<Object> {
private DynaClass elementDynaClass;
/**
- * The WrapDynaClass if the List's contains
- * POJO Bean elements.
+ * The WrapDynaClass if the List's contains POJO Bean elements.
*
- * N.B. WrapDynaClass isn't serializable, which
- * is why its stored separately in a
- * transient instance variable.
+ * N.B. WrapDynaClass isn't serializable, which is why its stored separately in a transient instance variable.
*/
private transient WrapDynaClass wrapDynaClass;
@@ -195,8 +190,7 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * Constructs a LazyDynaList with a
- * specified type for its elements.
+ * Constructs a LazyDynaList with a specified type for its elements.
*
* @param elementType The Type of the List's elements.
*/
@@ -205,8 +199,7 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * Constructs a LazyDynaList populated with the
- * elements of a Collection.
+ * Constructs a LazyDynaList populated with the elements of a Collection.
*
* @param collection The Collection to populate the List from.
*/
@@ -216,8 +209,7 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * Constructs a LazyDynaList with a
- * specified DynaClass for its elements.
+ * Constructs a LazyDynaList with a specified DynaClass for its elements.
*
* @param elementDynaClass The DynaClass of the List's elements.
*/
@@ -226,8 +218,7 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * Constructs a LazyDynaList with the
- * specified capacity.
+ * Constructs a LazyDynaList with the specified capacity.
*
* @param capacity The initial capacity of the list.
*/
@@ -237,8 +228,7 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * Constructs a LazyDynaList populated with the
- * elements of an Array.
+ * Constructs a LazyDynaList populated with the elements of an Array.
*
* @param array The Array to populate the List from.
*/
@@ -248,13 +238,15 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * <p>Insert an element at the specified index position.</p>
+ * <p>
+ * Insert an element at the specified index position.
+ * </p>
*
- * <p>If the index position is greater than the current
- * size of the List, then the List is automatically
- * <em>grown</em> to the appropriate size.</p>
+ * <p>
+ * If the index position is greater than the current size of the List, then the List is automatically <em>grown</em> to the appropriate size.
+ * </p>
*
- * @param index The index position to insert the new element.
+ * @param index The index position to insert the new element.
* @param element The new element to add.
*/
@Override
@@ -267,7 +259,9 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * <p>Add an element to the List.</p>
+ * <p>
+ * Add an element to the List.
+ * </p>
*
* @param element The new element to add.
* @return true.
@@ -280,7 +274,8 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * <p>Add all the elements from a Collection to the list.
+ * <p>
+ * Add all the elements from a Collection to the list.
*
* @param collection The Collection of new elements.
* @return true if elements were added.
@@ -299,15 +294,15 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * <p>Insert all the elements from a Collection into the
- * list at a specified position.
+ * <p>
+ * Insert all the elements from a Collection into the list at a specified position.
*
- * <p>If the index position is greater than the current
- * size of the List, then the List is automatically
- * <em>grown</em> to the appropriate size.</p>
+ * <p>
+ * If the index position is greater than the current size of the List, then the List is automatically <em>grown</em> to the appropriate size.
+ * </p>
*
* @param collection The Collection of new elements.
- * @param index The index position to insert the new elements at.
+ * @param index The index position to insert the new elements at.
* @return true if elements were added.
*/
@Override
@@ -350,11 +345,14 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * <p>Return the element at the specified position.</p>
+ * <p>
+ * Return the element at the specified position.
+ * </p>
*
- * <p>If the position requested is greater than the current
- * size of the List, then the List is automatically
- * <em>grown</em> (and populated) to the appropriate size.</p>
+ * <p>
+ * If the position requested is greater than the current size of the List, then the List is automatically <em>grown</em> (and populated) to the appropriate
+ * size.
+ * </p>
*
* @param index The index position to insert the new elements at.
* @return The element at the specified position.
@@ -374,9 +372,9 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * <p>Automatically <em>grown</em> the List
- * to the appropriate size, populating with
- * DynaBeans.</p>
+ * <p>
+ * Automatically <em>grown</em> the List to the appropriate size, populating with DynaBeans.
+ * </p>
*
* @param requiredSize the required size of the List.
*/
@@ -394,13 +392,16 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * <p>Set the element at the specified position.</p>
+ * <p>
+ * Set the element at the specified position.
+ * </p>
*
- * <p>If the position requested is greater than the current
- * size of the List, then the List is automatically
- * <em>grown</em> (and populated) to the appropriate size.</p>
+ * <p>
+ * If the position requested is greater than the current size of the List, then the List is automatically <em>grown</em> (and populated) to the appropriate
+ * size.
+ * </p>
*
- * @param index The index position to insert the new element at.
+ * @param index The index position to insert the new element at.
* @param element The new element.
* @return The new element.
*/
@@ -414,11 +415,12 @@ public class LazyDynaList extends ArrayList<Object> {
}
/**
- * <p>Set the element Type and DynaClass.</p>
+ * <p>
+ * Set the element Type and DynaClass.
+ * </p>
*
* @param elementDynaClass The DynaClass of the elements.
- * @throws IllegalArgumentException if the List already
- * contains elements or the DynaClass is null.
+ * @throws IllegalArgumentException if the List already contains elements or the DynaClass is null.
*/
public void setElementDynaClass(final DynaClass elementDynaClass) {
Objects.requireNonNull(elementDynaClass, "elementDynaClass");
@@ -428,32 +430,31 @@ public class LazyDynaList extends ArrayList<Object> {
// Try to create a new instance of the DynaBean
try {
- final DynaBean dynaBean = elementDynaClass.newInstance();
+ final DynaBean dynaBean = elementDynaClass.newInstance();
this.elementDynaBeanType = dynaBean.getClass();
if (WrapDynaBean.class.isAssignableFrom(elementDynaBeanType)) {
- this.elementType = ((WrapDynaBean)dynaBean).getInstance().getClass();
- this.wrapDynaClass = (WrapDynaClass)elementDynaClass;
+ this.elementType = ((WrapDynaBean) dynaBean).getInstance().getClass();
+ this.wrapDynaClass = (WrapDynaClass) elementDynaClass;
} else {
if (LazyDynaMap.class.isAssignableFrom(elementDynaBeanType)) {
- this.elementType = ((LazyDynaMap)dynaBean).getMap().getClass();
+ this.elementType = ((LazyDynaMap) dynaBean).getMap().getClass();
} else {
this.elementType = dynaBean.getClass();
}
this.elementDynaClass = elementDynaClass;
}
} catch (final Exception e) {
- throw new IllegalArgumentException(
- "Error creating DynaBean from " +
- elementDynaClass.getClass().getName() + " - " + e);
+ throw new IllegalArgumentException("Error creating DynaBean from " + elementDynaClass.getClass().getName() + " - " + e);
}
}
/**
- * <p>Set the element Type and DynaClass.</p>
+ * <p>
+ * Set the element Type and DynaClass.
+ * </p>
*
* @param elementType The type of the elements.
- * @throws IllegalArgumentException if the List already
- * contains elements or the DynaClass is null.
+ * @throws IllegalArgumentException if the List already contains elements or the DynaClass is null.
*/
public void setElementType(final Class<?> elementType) {
Objects.requireNonNull(elementType, "elementType");
@@ -469,8 +470,7 @@ public class LazyDynaList extends ArrayList<Object> {
try {
object = elementType.newInstance();
} catch (final Exception e) {
- throw new IllegalArgumentException("Error creating type: "
- + elementType.getName() + " - " + e);
+ throw new IllegalArgumentException("Error creating type: " + elementType.getName() + " - " + e);
}
// Create a DynaBean
@@ -479,35 +479,35 @@ public class LazyDynaList extends ArrayList<Object> {
dynaBean = createDynaBeanForMapProperty(object);
this.elementDynaClass = dynaBean.getDynaClass();
} else if (DynaBean.class.isAssignableFrom(elementType)) {
- dynaBean = (DynaBean)object;
+ dynaBean = (DynaBean) object;
this.elementDynaClass = dynaBean.getDynaClass();
} else {
dynaBean = new WrapDynaBean(object);
- this.wrapDynaClass = (WrapDynaClass)dynaBean.getDynaClass();
+ this.wrapDynaClass = (WrapDynaClass) dynaBean.getDynaClass();
}
this.elementDynaBeanType = dynaBean.getClass();
// Re-calculate the type
- if (WrapDynaBean.class.isAssignableFrom(elementDynaBeanType )) {
- this.elementType = ((WrapDynaBean)dynaBean).getInstance().getClass();
- } else if (LazyDynaMap.class.isAssignableFrom(elementDynaBeanType )) {
- this.elementType = ((LazyDynaMap)dynaBean).getMap().getClass();
+ if (WrapDynaBean.class.isAssignableFrom(elementDynaBeanType)) {
+ this.elementType = ((WrapDynaBean) dynaBean).getInstance().getClass();
+ } else if (LazyDynaMap.class.isAssignableFrom(elementDynaBeanType)) {
+ this.elementType = ((LazyDynaMap) dynaBean).getMap().getClass();
}
}
/**
- * <p>Converts the List to an Array.</p>
+ * <p>
+ * Converts the List to an Array.
+ * </p>
*
- * <p>The type of Array created depends on the contents
- * of the List:</p>
+ * <p>
+ * The type of Array created depends on the contents of the List:
+ * </p>
* <ul>
- * <li>If the List contains only LazyDynaMap type elements
- * then a java.util.Map[] array will be created.</li>
- * <li>If the List contains only elements which are
- * "wrapped" DynaBeans then an Object[] of the most
- * suitable type will be created.</li>
- * <li>...otherwise a DynaBean[] will be created.</li>
+ * <li>If the List contains only LazyDynaMap type elements then a java.util.Map[] array will be created.</li>
+ * <li>If the List contains only elements which are "wrapped" DynaBeans then an Object[] of the most suitable type will be created.</li>
+ * <li>...otherwise a DynaBean[] will be created.</li>
* </ul>
*
* @return An Array of the elements in this List.
@@ -518,31 +518,32 @@ public class LazyDynaList extends ArrayList<Object> {
return LazyDynaBean.EMPTY_ARRAY;
}
- final Object[] array = (Object[])Array.newInstance(elementType, size());
+ final Object[] array = (Object[]) Array.newInstance(elementType, size());
for (int i = 0; i < size(); i++) {
if (Map.class.isAssignableFrom(elementType)) {
- array[i] = ((LazyDynaMap)get(i)).getMap();
+ array[i] = ((LazyDynaMap) get(i)).getMap();
} else if (DynaBean.class.isAssignableFrom(elementType)) {
array[i] = get(i);
} else {
- array[i] = ((WrapDynaBean)get(i)).getInstance();
+ array[i] = ((WrapDynaBean) get(i)).getInstance();
}
}
return array;
}
/**
- * <p>Converts the List to an Array of the specified type.</p>
+ * <p>
+ * Converts the List to an Array of the specified type.
+ * </p>
*
- * @param <T> The type of the array elements
+ * @param <T> The type of the array elements
* @param model The model for the type of array to return
* @return An Array of the elements in this List.
*/
@Override
public <T> T[] toArray(final T[] model) {
final Class<?> arrayType = model.getClass().getComponentType();
- if (DynaBean.class.isAssignableFrom(arrayType)
- || isEmpty() && elementType == null) {
+ if (DynaBean.class.isAssignableFrom(arrayType) || isEmpty() && elementType == null) {
return super.toArray(model);
}
@@ -572,13 +573,13 @@ public class LazyDynaList extends ArrayList<Object> {
return array;
}
- throw new IllegalArgumentException("Invalid array type: "
- + arrayType.getName() + " - not compatible with '"
- + elementType.getName());
+ throw new IllegalArgumentException("Invalid array type: " + arrayType.getName() + " - not compatible with '" + elementType.getName());
}
/**
- * <p>Converts the List to an DynaBean Array.</p>
+ * <p>
+ * Converts the List to an DynaBean Array.
+ * </p>
*
* @return A DynaBean[] of the elements in this List.
*/
@@ -587,27 +588,28 @@ public class LazyDynaList extends ArrayList<Object> {
return LazyDynaBean.EMPTY_ARRAY;
}
- final DynaBean[] array = (DynaBean[])Array.newInstance(elementDynaBeanType, size());
+ final DynaBean[] array = (DynaBean[]) Array.newInstance(elementDynaBeanType, size());
for (int i = 0; i < size(); i++) {
- array[i] = (DynaBean)get(i);
+ array[i] = (DynaBean) get(i);
}
return array;
}
/**
- * <p>Transform the element into a DynaBean:</p>
+ * <p>
+ * Transform the element into a DynaBean:
+ * </p>
*
* <ul>
- * <li>Map elements are turned into LazyDynaMap's.</li>
- * <li>POJO Beans are "wrapped" in a WrapDynaBean.</li>
- * <li>DynaBeans are unchanged.</li>
- * </li>
+ * <li>Map elements are turned into LazyDynaMap's.</li>
+ * <li>POJO Beans are "wrapped" in a WrapDynaBean.</li>
+ * <li>DynaBeans are unchanged.</li></li>
*
* @param element The element to transformed.
* @return The DynaBean to store in the List.
*/
private DynaBean transform(final Object element) {
- DynaBean dynaBean = null;
+ DynaBean dynaBean = null;
Class<?> newDynaBeanType = null;
Class<?> newElementType;
@@ -630,9 +632,7 @@ public class LazyDynaList extends ArrayList<Object> {
dynaBean = getDynaClass().newInstance();
newDynaBeanType = dynaBean.getClass();
} catch (final Exception e) {
- throw new IllegalArgumentException("Error creating DynaBean: "
- + getDynaClass().getClass().getName()
- + " - " + e);
+ throw new IllegalArgumentException("Error creating DynaBean: " + getDynaClass().getClass().getName() + " - " + e);
}
} else {
@@ -642,7 +642,7 @@ public class LazyDynaList extends ArrayList<Object> {
if (Map.class.isAssignableFrom(element.getClass())) {
dynaBean = createDynaBeanForMapProperty(element);
} else if (DynaBean.class.isAssignableFrom(element.getClass())) {
- dynaBean = (DynaBean)element;
+ dynaBean = (DynaBean) element;
} else {
dynaBean = new WrapDynaBean(element);
}
@@ -654,16 +654,15 @@ public class LazyDynaList extends ArrayList<Object> {
// Re-calculate the element type
newElementType = dynaBean.getClass();
if (WrapDynaBean.class.isAssignableFrom(newDynaBeanType)) {
- newElementType = ((WrapDynaBean)dynaBean).getInstance().getClass();
+ newElementType = ((WrapDynaBean) dynaBean).getInstance().getClass();
} else if (LazyDynaMap.class.isAssignableFrom(newDynaBeanType)) {
- newElementType = ((LazyDynaMap)dynaBean).getMap().getClass();
+ newElementType = ((LazyDynaMap) dynaBean).getMap().getClass();
}
// Check the new element type, matches all the
// other elements in the List
if (elementType != null && !newElementType.equals(elementType)) {
- throw new IllegalArgumentException("Element Type " + newElementType
- + " doesn't match other elements " + elementType);
+ throw new IllegalArgumentException("Element Type " + newElementType + " doesn't match other elements " + elementType);
}
return dynaBean;
diff --git a/src/main/java/org/apache/commons/beanutils2/LazyDynaMap.java b/src/main/java/org/apache/commons/beanutils2/LazyDynaMap.java
index 6ccbfe07..fc17ab10 100644
--- a/src/main/java/org/apache/commons/beanutils2/LazyDynaMap.java
+++ b/src/main/java/org/apache/commons/beanutils2/LazyDynaMap.java
@@ -20,7 +20,8 @@ import java.util.Map;
import java.util.Objects;
/**
- * <p>Provides a <em>light weight</em> {@code DynaBean</code> facade to a <code>Map}
+ * <p>
+ * Provides a <em>light weight</em> {@code DynaBean</code> facade to a <code>Map}
* with <em>lazy</em> map/list processing.</p>
*
* <p>Its a <em>light weight</em> {@code DynaBean} implementation because there is no
@@ -39,18 +40,17 @@ import java.util.Objects;
*
* <p><b><u><em>Restricted</em> DynaClass</u></b></p>
* <p>This class implements the {@code MutableDynaClass} interface.
- * {@code MutableDynaClass</code> have a facility to <em>restrict</em> the <code>DynaClass}
- * so that its properties cannot be modified. If the {@code MutableDynaClass} is
- * restricted then calling any of the {@code set()} methods for a property which
- * doesn't exist will result in a {@code IllegalArgumentException} being thrown.</p>
+ * {@code MutableDynaClass</code> have a facility to <em>restrict</em> the <code>DynaClass} so that its properties cannot be modified. If the
+ * {@code MutableDynaClass} is restricted then calling any of the {@code set()} methods for a property which doesn't exist will result in a
+ * {@code IllegalArgumentException} being thrown.
+ * </p>
*/
public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
private static final long serialVersionUID = 1L;
/**
- * The name of this DynaClass (analogous to the
- * {@code getName()</code> method of <code>java.lang.Class}).
+ * The name of this DynaClass (analogous to the {@code getName()</code> method of <code>java.lang.Class}).
*/
protected String name;
@@ -60,10 +60,12 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
protected boolean restricted;
/**
- * <p>Controls whether the {@code getDynaProperty()} method returns
- * null if a property doesn't exist - or creates a new one.</p>
+ * <p>
+ * Controls whether the {@code getDynaProperty()} method returns null if a property doesn't exist - or creates a new one.
+ * </p>
*
- * <p>Default is {@code false}.
+ * <p>
+ * Default is {@code false}.
*/
protected boolean returnNull;
@@ -71,7 +73,7 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
* Default Constructor.
*/
public LazyDynaMap() {
- this(null, (Map<String, Object>)null);
+ this(null, (Map<String, Object>) null);
}
/**
@@ -107,17 +109,17 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
* @param name Name of this DynaBean class
*/
public LazyDynaMap(final String name) {
- this(name, (Map<String, Object>)null);
+ this(name, (Map<String, Object>) null);
}
/**
* Constructs a new {@code LazyDynaMap} with the specified name and properties.
*
- * @param name Name of this DynaBean class
+ * @param name Name of this DynaBean class
* @param properties Property descriptors for the supported properties
*/
public LazyDynaMap(final String name, final DynaProperty[] properties) {
- this(name, (Map<String, Object>)null);
+ this(name, (Map<String, Object>) null);
if (properties != null) {
for (final DynaProperty property : properties) {
add(property);
@@ -128,12 +130,12 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
/**
* Constructs a new {@code LazyDynaMap</code> with the specified name and <code>Map}.
*
- * @param name Name of this DynaBean class
+ * @param name Name of this DynaBean class
* @param values The Map backing this {@code LazyDynaMap}
*/
public LazyDynaMap(final String name, final Map<String, Object> values) {
- this.name = name == null ? "LazyDynaMap" : name;
- this.values = values == null ? newMap() : values;
+ this.name = name == null ? "LazyDynaMap" : name;
+ this.values = values == null ? newMap() : values;
this.dynaClass = this;
}
@@ -149,8 +151,7 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
}
/**
- * Add a new dynamic property with no restrictions on data type,
- * readability, or writeability.
+ * Add a new dynamic property with no restrictions on data type, readability, or writeability.
*
* @param name Name of the new dynamic property
*
@@ -162,16 +163,13 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
}
/**
- * Add a new dynamic property with the specified data type, but with
- * no restrictions on readability or writeability.
+ * Add a new dynamic property with the specified data type, but with no restrictions on readability or writeability.
*
* @param name Name of the new dynamic property
- * @param type Data type of the new dynamic property (null for no
- * restrictions)
+ * @param type Data type of the new dynamic property (null for no restrictions)
*
* @throws IllegalArgumentException if name is null
- * @throws IllegalStateException if this DynaClass is currently
- * restricted, so no new properties can be added
+ * @throws IllegalStateException if this DynaClass is currently restricted, so no new properties can be added
*/
@Override
public void add(final String name, final Class<?> type) {
@@ -184,23 +182,24 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
}
/**
- * <p>Add a new dynamic property with the specified data type, readability,
- * and writeability.</p>
+ * <p>
+ * Add a new dynamic property with the specified data type, readability, and writeability.
+ * </p>
*
- * <p><strong>N.B.</strong>Support for readable/writable properties has not been implemented
- * and this method always throws a {@code UnsupportedOperationException}.</p>
+ * <p>
+ * <strong>N.B.</strong>Support for readable/writable properties has not been implemented and this method always throws a
+ * {@code UnsupportedOperationException}.
+ * </p>
*
- * <p>I'm not sure the intention of the original authors for this method, but it seems to
- * me that readable/writable should be attributes of the {@code DynaProperty} class
- * (which they are not) and is the reason this method has not been implemented.</p>
+ * <p>
+ * I'm not sure the intention of the original authors for this method, but it seems to me that readable/writable should be attributes of the
+ * {@code DynaProperty} class (which they are not) and is the reason this method has not been implemented.
+ * </p>
*
- * @param name Name of the new dynamic property
- * @param type Data type of the new dynamic property (null for no
- * restrictions)
- * @param readable Set to {@code true} if this property value
- * should be readable
- * @param writable Set to {@code true} if this property value
- * should be writable
+ * @param name Name of the new dynamic property
+ * @param type Data type of the new dynamic property (null for no restrictions)
+ * @param readable Set to {@code true} if this property value should be readable
+ * @param writable Set to {@code true} if this property value should be writable
*
* @throws UnsupportedOperationException anytime this method is called
*/
@@ -210,13 +209,15 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
}
/**
- * <p>Return an array of {@code PropertyDescriptor} for the properties
- * currently defined in this DynaClass. If no properties are defined, a
- * zero-length array will be returned.</p>
+ * <p>
+ * Return an array of {@code PropertyDescriptor} for the properties currently defined in this DynaClass. If no properties are defined, a zero-length array
+ * will be returned.
+ * </p>
+ *
+ * <p>
+ * <strong>FIXME</strong> - Should we really be implementing {@code getBeanInfo()} instead, which returns property descriptors and a bunch of other stuff?
+ * </p>
*
- * <p><strong>FIXME</strong> - Should we really be implementing
- * {@code getBeanInfo()} instead, which returns property descriptors
- * and a bunch of other stuff?</p>
* @return the set of properties for this DynaClass
*/
@Override
@@ -226,32 +227,33 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
for (final Map.Entry<String, Object> e : values.entrySet()) {
final String name = e.getKey();
final Object value = values.get(name);
- properties[i++] = new DynaProperty(name, value == null ? null
- : value.getClass());
+ properties[i++] = new DynaProperty(name, value == null ? null : value.getClass());
}
return properties;
}
/**
- * <p>Return a property descriptor for the specified property.</p>
+ * <p>
+ * Return a property descriptor for the specified property.
+ * </p>
*
- * <p>If the property is not found and the {@code returnNull} indicator is
- * {@code true</code>, this method always returns <code>null}.</p>
+ * <p>
+ * If the property is not found and the {@code returnNull} indicator is {@code true</code>, this method always returns <code>null}.
+ * </p>
*
- * <p>If the property is not found and the {@code returnNull} indicator is
- * {@code false} a new property descriptor is created and returned (although
- * its not actually added to the DynaClass's properties). This is the default
- * behavior.</p>
+ * <p>
+ * If the property is not found and the {@code returnNull} indicator is {@code false} a new property descriptor is created and returned (although its not
+ * actually added to the DynaClass's properties). This is the default behavior.
+ * </p>
*
- * <p>The reason for not returning a {@code null} property descriptor is that
- * {@code BeanUtils} uses this method to check if a property exists
- * before trying to set it - since these <em>Map</em> implementations automatically
- * add any new properties when they are set, returning {@code null} from
- * this method would defeat their purpose.</p>
+ * <p>
+ * The reason for not returning a {@code null} property descriptor is that {@code BeanUtils} uses this method to check if a property exists before trying to
+ * set it - since these <em>Map</em> implementations automatically add any new properties when they are set, returning {@code null} from this method would
+ * defeat their purpose.
+ * </p>
*
- * @param name Name of the dynamic property for which a descriptor
- * is requested
+ * @param name Name of the dynamic property for which a descriptor is requested
* @return The descriptor for the specified property
*
* @throws IllegalArgumentException if no property name is specified
@@ -273,6 +275,7 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
/**
* Gets the underlying Map backing this {@code DynaBean}
+ *
* @return the underlying Map
* @since 1.8.0
*/
@@ -282,8 +285,7 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
}
/**
- * Gets the name of this DynaClass (analogous to the
- * {@code getName()</code> method of <code>java.lang.Class})
+ * Gets the name of this DynaClass (analogous to the {@code getName()</code> method of <code>java.lang.Class})
*
* @return the name of the DynaClass
*/
@@ -293,30 +295,33 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
}
/**
- * <p>Indicate whether a property actually exists.</p>
- *
- * <p><strong>N.B.</strong> Using {@code getDynaProperty(name) == null}
- * doesn't work in this implementation because that method might
- * return a DynaProperty if it doesn't exist (depending on the
- * {@code returnNull} indicator).</p>
- *
- * @param name Name of the dynamic property
- * @return {@code true} if the property exists,
- * otherwise {@code false}
- * @throws IllegalArgumentException if no property name is specified
- */
- @Override
- protected boolean isDynaProperty(final String name) {
- return values.containsKey(Objects.requireNonNull(name, "name"));
- }
+ * <p>
+ * Indicate whether a property actually exists.
+ * </p>
+ *
+ * <p>
+ * <strong>N.B.</strong> Using {@code getDynaProperty(name) == null} doesn't work in this implementation because that method might return a DynaProperty if
+ * it doesn't exist (depending on the {@code returnNull} indicator).
+ * </p>
+ *
+ * @param name Name of the dynamic property
+ * @return {@code true} if the property exists, otherwise {@code false}
+ * @throws IllegalArgumentException if no property name is specified
+ */
+ @Override
+ protected boolean isDynaProperty(final String name) {
+ return values.containsKey(Objects.requireNonNull(name, "name"));
+ }
/**
- * <p>Is this DynaClass currently restricted.</p>
- * <p>If restricted, no changes to the existing registration of
- * property names, data types, readability, or writeability are allowed.</p>
+ * <p>
+ * Is this DynaClass currently restricted.
+ * </p>
+ * <p>
+ * If restricted, no changes to the existing registration of property names, data types, readability, or writeability are allowed.
+ * </p>
*
- * @return {@code true} if this Mutable {@link DynaClass} is restricted,
- * otherwise {@code false}
+ * @return {@code true} if this Mutable {@link DynaClass} is restricted, otherwise {@code false}
*/
@Override
public boolean isRestricted() {
@@ -324,25 +329,22 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
}
/**
- * Should this DynaClass return a {@code null} from
- * the {@code getDynaProperty(name)} method if the property
- * doesn't exist.
+ * Should this DynaClass return a {@code null} from the {@code getDynaProperty(name)} method if the property doesn't exist.
*
- * @return {@code true</code> if a <code>null} {@link DynaProperty}
- * should be returned if the property doesn't exist, otherwise
- * {@code false} if a new {@link DynaProperty} should be created.
+ * @return {@code true</code> if a <code>null} {@link DynaProperty} should be returned if the property doesn't exist, otherwise {@code false} if a new
+ * {@link DynaProperty} should be created.
*/
public boolean isReturnNull() {
return returnNull;
}
/**
- * Instantiate and return a new DynaBean instance, associated
- * with this DynaClass.
+ * Instantiate and return a new DynaBean instance, associated with this DynaClass.
+ *
* @return A new {@code DynaBean} instance
*/
@Override
- public DynaBean newInstance() {
+ public DynaBean newInstance() {
// Create a new instance of the Map
Map<String, Object> newMap = null;
try {
@@ -366,17 +368,13 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
}
/**
- * Remove the specified dynamic property, and any associated data type,
- * readability, and writeability, from this dynamic class.
- * <strong>NOTE</strong> - This does <strong>NOT</strong> cause any
- * corresponding property values to be removed from DynaBean instances
- * associated with this DynaClass.
+ * Remove the specified dynamic property, and any associated data type, readability, and writeability, from this dynamic class. <strong>NOTE</strong> - This
+ * does <strong>NOT</strong> cause any corresponding property values to be removed from DynaBean instances associated with this DynaClass.
*
* @param name Name of the dynamic property to remove
*
* @throws IllegalArgumentException if name is null
- * @throws IllegalStateException if this DynaClass is currently
- * restricted, so no properties can be removed
+ * @throws IllegalStateException if this DynaClass is currently restricted, so no properties can be removed
*/
@Override
public void remove(final String name) {
@@ -390,14 +388,13 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
/**
* Sets the value of a simple property with the specified name.
*
- * @param name Name of the property whose value is to be set
+ * @param name Name of the property whose value is to be set
* @param value Value to which this property is to be set
*/
@Override
public void set(final String name, final Object value) {
if (isRestricted() && !values.containsKey(name)) {
- throw new IllegalArgumentException
- ("Invalid property name '" + name + "' (DynaClass is restricted)");
+ throw new IllegalArgumentException("Invalid property name '" + name + "' (DynaClass is restricted)");
}
values.put(name, value);
}
@@ -412,9 +409,12 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
}
/**
- * <p>Set whether this DynaClass is currently restricted.</p>
- * <p>If restricted, no changes to the existing registration of
- * property names, data types, readability, or writeability are allowed.</p>
+ * <p>
+ * Set whether this DynaClass is currently restricted.
+ * </p>
+ * <p>
+ * If restricted, no changes to the existing registration of property names, data types, readability, or writeability are allowed.
+ * </p>
*
* @param restricted The new restricted state
*/
@@ -423,17 +423,14 @@ public class LazyDynaMap extends LazyDynaBean implements MutableDynaClass {
this.restricted = restricted;
}
- /**
- * Sets whether this DynaClass should return a {@code null} from
- * the {@code getDynaProperty(name)} method if the property
- * doesn't exist.
- *
- * @param returnNull {@code true</code> if a <code>null} {@link DynaProperty}
- * should be returned if the property doesn't exist, otherwise
- * {@code false} if a new {@link DynaProperty} should be created.
- */
-public void setReturnNull(final boolean returnNull) {
- this.returnNull = returnNull;
-}
+ /**
+ * Sets whether this DynaClass should return a {@code null} from the {@code getDynaProperty(name)} method if the property doesn't exist.
+ *
+ * @param returnNull {@code true</code> if a <code>null} {@link DynaProperty} should be returned if the property doesn't exist, otherwise {@code false} if a
+ * new {@link DynaProperty} should be created.
+ */
+ public void setReturnNull(final boolean returnNull) {
+ this.returnNull = returnNull;
+ }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/commons/beanutils2/MappedPropertyDescriptor.java b/src/main/java/org/apache/commons/beanutils2/MappedPropertyDescriptor.java
index e3779314..328b04bb 100644
--- a/src/main/java/org/apache/commons/beanutils2/MappedPropertyDescriptor.java
+++ b/src/main/java/org/apache/commons/beanutils2/MappedPropertyDescriptor.java
@@ -26,25 +26,23 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
/**
- * A MappedPropertyDescriptor describes one mapped property.
- * Mapped properties are multivalued properties like indexed properties
- * but that are accessed with a String key instead of an index.
- * Such property values are typically stored in a Map collection.
- * For this class to work properly, a mapped value must have
+ * A MappedPropertyDescriptor describes one mapped property. Mapped properties are multivalued properties like indexed properties but that are accessed with a
+ * String key instead of an index. Such property values are typically stored in a Map collection. For this class to work properly, a mapped value must have
* getter and setter methods of the form
- * <p>{@code get<strong>Property</strong>(String key)} and
- * <p>{@code set<strong>Property</strong>(String key, Object value)},
- * <p>where {@code <strong>Property</strong>} must be replaced
- * by the name of the property.
+ * <p>
+ * {@code get<strong>Property</strong>(String key)} and
+ * <p>
+ * {@code set<strong>Property</strong>(String key, Object value)},
+ * <p>
+ * where {@code <strong>Property</strong>} must be replaced by the name of the property.
+ *
* @see java.beans.PropertyDescriptor
*/
public class MappedPropertyDescriptor extends PropertyDescriptor {
/**
- * Holds a {@link Method} in a {@link SoftReference} so that it
- * it doesn't prevent any ClassLoader being garbage collected, but
- * tries to re-create the method if the method reference has been
- * released.
+ * Holds a {@link Method} in a {@link SoftReference} so that it it doesn't prevent any ClassLoader being garbage collected, but tries to re-create the
+ * method if the method reference has been released.
*
* See https://issues.apache.org/jira/browse/BEANUTILS-291
*/
@@ -56,6 +54,7 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
private Reference<Class<?>> writeParamTypeRef0;
private Reference<Class<?>> writeParamTypeRef1;
private String[] writeParamClassNames;
+
MappedMethodReference(final Method m) {
if (m != null) {
className = m.getDeclaringClass().getName();
@@ -72,6 +71,7 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
}
}
}
+
private Method get() {
if (methodRef == null) {
return null;
@@ -86,8 +86,7 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
}
}
if (clazz == null) {
- throw new RuntimeException("Method " + methodName + " for " +
- className + " could not be reconstructed - class reference has gone");
+ throw new RuntimeException("Method " + methodName + " for " + className + " could not be reconstructed - class reference has gone");
}
Class<?>[] paramTypes = null;
if (writeParamClassNames != null) {
@@ -114,8 +113,7 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
// Un-comment following line for testing
// System.out.println("Recreated Method " + methodName + " for " + className);
} catch (final NoSuchMethodException e) {
- throw new RuntimeException("Method " + methodName + " for " +
- className + " could not be reconstructed - method not found");
+ throw new RuntimeException("Method " + methodName + " for " + className + " could not be reconstructed - method not found");
}
methodRef = new SoftReference<>(m);
}
@@ -158,7 +156,7 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
/**
* The parameter types array for the reader method signature.
*/
- private static final Class<?>[] STRING_CLASS_PARAMETER = new Class[]{String.class};
+ private static final Class<?>[] STRING_CLASS_PARAMETER = new Class[] { String.class };
/**
* Gets a capitalized version of the specified property name.
@@ -178,8 +176,7 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
/**
* Find a method on a class with a specified parameter list.
*/
- private static Method getMethod(final Class<?> clazz, final String methodName, final Class<?>[] parameterTypes)
- throws IntrospectionException {
+ private static Method getMethod(final Class<?> clazz, final String methodName, final Class<?>[] parameterTypes) throws IntrospectionException {
if (methodName == null) {
return null;
}
@@ -192,15 +189,13 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
final int parameterCount = parameterTypes == null ? 0 : parameterTypes.length;
// No Method found
- throw new IntrospectionException("No method \"" + methodName +
- "\" with " + parameterCount + " parameter(s) of matching types.");
+ throw new IntrospectionException("No method \"" + methodName + "\" with " + parameterCount + " parameter(s) of matching types.");
}
/**
* Find a method on a class with a specified number of parameters.
*/
- private static Method getMethod(final Class<?> clazz, final String methodName, final int parameterCount)
- throws IntrospectionException {
+ private static Method getMethod(final Class<?> clazz, final String methodName, final int parameterCount) throws IntrospectionException {
if (methodName == null) {
return null;
}
@@ -211,15 +206,13 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
}
// No Method found
- throw new IntrospectionException("No method \"" + methodName +
- "\" with " + parameterCount + " parameter(s)");
+ throw new IntrospectionException("No method \"" + methodName + "\" with " + parameterCount + " parameter(s)");
}
/**
* Find a method on a class with a specified number of parameters.
*/
- private static Method internalGetMethod(final Class<?> initial, final String methodName,
- final int parameterCount) {
+ private static Method internalGetMethod(final Class<?> initial, final String methodName, final int parameterCount) {
// For overridden methods we need to find the most derived version.
// So we start with the given class and walk up the superclass chain.
for (Class<?> clazz = initial; clazz != null; clazz = clazz.getSuperclass()) {
@@ -230,18 +223,16 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
}
// skip static methods.
final int mods = method.getModifiers();
- if (!Modifier.isPublic(mods) ||
- Modifier.isStatic(mods)) {
+ if (!Modifier.isPublic(mods) || Modifier.isStatic(mods)) {
continue;
}
- if (method.getName().equals(methodName) &&
- method.getParameterTypes().length == parameterCount) {
+ if (method.getName().equals(methodName) && method.getParameterTypes().length == parameterCount) {
return method;
}
}
}
- // Now check any inherited interfaces. This is necessary both when
+ // Now check any inherited interfaces. This is necessary both when
// the argument class is itself an interface, and when the argument
// class is an abstract class.
final Class<?>[] interfaces = initial.getInterfaces();
@@ -271,28 +262,20 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
private MappedMethodReference mappedWriteMethodRef;
/**
- * Constructs a MappedPropertyDescriptor for a property that follows
- * the standard Java convention by having getFoo and setFoo
- * accessor methods, with the addition of a String parameter (the key).
- * Thus if the argument name is "fred", it will
- * assume that the writer method is "setFred" and the reader method
- * is "getFred". Note that the property name should start with a lower
- * case character, which will be capitalized in the method names.
+ * Constructs a MappedPropertyDescriptor for a property that follows the standard Java convention by having getFoo and setFoo accessor methods, with the
+ * addition of a String parameter (the key). Thus if the argument name is "fred", it will assume that the writer method is "setFred" and the reader method
+ * is "getFred". Note that the property name should start with a lower case character, which will be capitalized in the method names.
*
* @param propertyName The programmatic name of the property.
- * @param beanClass The Class object for the target bean. For
- * example sun.beans.OurButton.class.
+ * @param beanClass The Class object for the target bean. For example sun.beans.OurButton.class.
*
- * @throws IntrospectionException if an exception occurs during
- * introspection.
+ * @throws IntrospectionException if an exception occurs during introspection.
*/
- public MappedPropertyDescriptor(final String propertyName, final Class<?> beanClass)
- throws IntrospectionException {
+ public MappedPropertyDescriptor(final String propertyName, final Class<?> beanClass) throws IntrospectionException {
super(propertyName, null, null);
if (propertyName == null || propertyName.isEmpty()) {
- throw new IntrospectionException("bad property name: " +
- propertyName + " on class: " + beanClass.getClass().getName());
+ throw new IntrospectionException("bad property name: " + propertyName + " on class: " + beanClass.getClass().getName());
}
setName(propertyName);
@@ -303,17 +286,15 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
Method mappedWriteMethod = null;
try {
try {
- mappedReadMethod = getMethod(beanClass, "get" + base,
- STRING_CLASS_PARAMETER);
+ mappedReadMethod = getMethod(beanClass, "get" + base, STRING_CLASS_PARAMETER);
} catch (final IntrospectionException e) {
- mappedReadMethod = getMethod(beanClass, "is" + base,
- STRING_CLASS_PARAMETER);
+ mappedReadMethod = getMethod(beanClass, "is" + base, STRING_CLASS_PARAMETER);
}
final Class<?>[] params = { String.class, mappedReadMethod.getReturnType() };
mappedWriteMethod = getMethod(beanClass, "set" + base, params);
} catch (final IntrospectionException e) {
- /* Swallow IntrospectionException
- * TODO: Why?
+ /*
+ * Swallow IntrospectionException TODO: Why?
*/
}
@@ -323,125 +304,96 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
}
if (mappedReadMethod == null && mappedWriteMethod == null) {
- throw new IntrospectionException("Property '" + propertyName +
- "' not found on " +
- beanClass.getName());
+ throw new IntrospectionException("Property '" + propertyName + "' not found on " + beanClass.getName());
}
- mappedReadMethodRef = new MappedMethodReference(mappedReadMethod);
+ mappedReadMethodRef = new MappedMethodReference(mappedReadMethod);
mappedWriteMethodRef = new MappedMethodReference(mappedWriteMethod);
findMappedPropertyType();
}
/**
- * This constructor takes the name of a mapped property, and method
- * names for reading and writing the property.
+ * This constructor takes the name of a mapped property, and method names for reading and writing the property.
*
- * @param propertyName The programmatic name of the property.
- * @param beanClass The Class object for the target bean. For
- * example sun.beans.OurButton.class.
- * @param mappedGetterName The name of the method used for
- * reading one of the property values. May be null if the
- * property is write-only.
- * @param mappedSetterName The name of the method used for writing
- * one of the property values. May be null if the property is
- * read-only.
+ * @param propertyName The programmatic name of the property.
+ * @param beanClass The Class object for the target bean. For example sun.beans.OurButton.class.
+ * @param mappedGetterName The name of the method used for reading one of the property values. May be null if the property is write-only.
+ * @param mappedSetterName The name of the method used for writing one of the property values. May be null if the property is read-only.
*
- * @throws IntrospectionException if an exception occurs during
- * introspection.
+ * @throws IntrospectionException if an exception occurs during introspection.
*/
- public MappedPropertyDescriptor(final String propertyName, final Class<?> beanClass,
- final String mappedGetterName, final String mappedSetterName)
+ public MappedPropertyDescriptor(final String propertyName, final Class<?> beanClass, final String mappedGetterName, final String mappedSetterName)
throws IntrospectionException {
super(propertyName, null, null);
if (propertyName == null || propertyName.isEmpty()) {
- throw new IntrospectionException("bad property name: " +
- propertyName);
+ throw new IntrospectionException("bad property name: " + propertyName);
}
setName(propertyName);
// search the mapped get and set methods
Method mappedReadMethod;
Method mappedWriteMethod = null;
- mappedReadMethod =
- getMethod(beanClass, mappedGetterName, STRING_CLASS_PARAMETER);
+ mappedReadMethod = getMethod(beanClass, mappedGetterName, STRING_CLASS_PARAMETER);
if (mappedReadMethod != null) {
final Class<?>[] params = { String.class, mappedReadMethod.getReturnType() };
- mappedWriteMethod =
- getMethod(beanClass, mappedSetterName, params);
+ mappedWriteMethod = getMethod(beanClass, mappedSetterName, params);
} else {
- mappedWriteMethod =
- getMethod(beanClass, mappedSetterName, 2);
+ mappedWriteMethod = getMethod(beanClass, mappedSetterName, 2);
}
- mappedReadMethodRef = new MappedMethodReference(mappedReadMethod);
+ mappedReadMethodRef = new MappedMethodReference(mappedReadMethod);
mappedWriteMethodRef = new MappedMethodReference(mappedWriteMethod);
findMappedPropertyType();
}
/**
- * This constructor takes the name of a mapped property, and Method
- * objects for reading and writing the property.
+ * This constructor takes the name of a mapped property, and Method objects for reading and writing the property.
*
* @param propertyName The programmatic name of the property.
- * @param mappedGetter The method used for reading one of
- * the property values. May be null if the property
- * is write-only.
- * @param mappedSetter The method used for writing one the
- * property values. May be null if the property is read-only.
+ * @param mappedGetter The method used for reading one of the property values. May be null if the property is write-only.
+ * @param mappedSetter The method used for writing one the property values. May be null if the property is read-only.
*
- * @throws IntrospectionException if an exception occurs during
- * introspection.
+ * @throws IntrospectionException if an exception occurs during introspection.
*/
- public MappedPropertyDescriptor(final String propertyName,
- final Method mappedGetter, final Method mappedSetter)
- throws IntrospectionException {
+ public MappedPropertyDescriptor(final String propertyName, final Method mappedGetter, final Method mappedSetter) throws IntrospectionException {
super(propertyName, mappedGetter, mappedSetter);
if (propertyName == null || propertyName.isEmpty()) {
- throw new IntrospectionException("bad property name: " +
- propertyName);
+ throw new IntrospectionException("bad property name: " + propertyName);
}
setName(propertyName);
- mappedReadMethodRef = new MappedMethodReference(mappedGetter);
+ mappedReadMethodRef = new MappedMethodReference(mappedGetter);
mappedWriteMethodRef = new MappedMethodReference(mappedSetter);
findMappedPropertyType();
}
/**
- * Introspect our bean class to identify the corresponding getter
- * and setter methods.
+ * Introspect our bean class to identify the corresponding getter and setter methods.
*/
private void findMappedPropertyType() throws IntrospectionException {
- final Method mappedReadMethod = getMappedReadMethod();
+ final Method mappedReadMethod = getMappedReadMethod();
final Method mappedWriteMethod = getMappedWriteMethod();
Class<?> mappedPropertyType = null;
if (mappedReadMethod != null) {
if (mappedReadMethod.getParameterTypes().length != 1) {
- throw new IntrospectionException
- ("bad mapped read method arg count");
+ throw new IntrospectionException("bad mapped read method arg count");
}
mappedPropertyType = mappedReadMethod.getReturnType();
if (mappedPropertyType == Void.TYPE) {
- throw new IntrospectionException
- ("mapped read method " +
- mappedReadMethod.getName() + " returns void");
+ throw new IntrospectionException("mapped read method " + mappedReadMethod.getName() + " returns void");
}
}
if (mappedWriteMethod != null) {
final Class<?>[] params = mappedWriteMethod.getParameterTypes();
if (params.length != 2) {
- throw new IntrospectionException
- ("bad mapped write method arg count");
+ throw new IntrospectionException("bad mapped write method arg count");
}
- if (mappedPropertyType != null &&
- mappedPropertyType != params[1]) {
- throw new IntrospectionException
- ("type mismatch between mapped read and write methods");
+ if (mappedPropertyType != null && mappedPropertyType != params[1]) {
+ throw new IntrospectionException("type mismatch between mapped read and write methods");
}
mappedPropertyType = params[1];
}
@@ -451,12 +403,10 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
/**
* Gets the Class object for the property values.
*
- * @return The Java type info for the property values. Note that
- * the "Class" object may describe a built-in Java type such as "int".
- * The result may be "null" if this is a mapped property that
- * does not support non-keyed access.
- * <p>
- * This is the type that will be returned by the mappedReadMethod.
+ * @return The Java type info for the property values. Note that the "Class" object may describe a built-in Java type such as "int". The result may be
+ * "null" if this is a mapped property that does not support non-keyed access.
+ * <p>
+ * This is the type that will be returned by the mappedReadMethod.
*/
public Class<?> getMappedPropertyType() {
return mappedPropertyTypeRef.get();
@@ -465,8 +415,7 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
/**
* Gets the method that should be used to read one of the property value.
*
- * @return The method that should be used to read the property value.
- * May return null if the property can't be read.
+ * @return The method that should be used to read the property value. May return null if the property can't be read.
*/
public Method getMappedReadMethod() {
return mappedReadMethodRef.get();
@@ -475,8 +424,7 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
/**
* Gets the method that should be used to write one of the property value.
*
- * @return The method that should be used to write one of the property value.
- * May return null if the property can't be written.
+ * @return The method that should be used to write one of the property value. May return null if the property can't be written.
*/
public Method getMappedWriteMethod() {
return mappedWriteMethodRef.get();
@@ -486,11 +434,9 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
* Sets the method that should be used to read one of the property value.
*
* @param mappedGetter The mapped getter method.
- * @throws IntrospectionException If an error occurs finding the
- * mapped property
+ * @throws IntrospectionException If an error occurs finding the mapped property
*/
- public void setMappedReadMethod(final Method mappedGetter)
- throws IntrospectionException {
+ public void setMappedReadMethod(final Method mappedGetter) throws IntrospectionException {
mappedReadMethodRef = new MappedMethodReference(mappedGetter);
findMappedPropertyType();
}
@@ -499,11 +445,9 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
* Sets the method that should be used to write the property value.
*
* @param mappedSetter The mapped setter method.
- * @throws IntrospectionException If an error occurs finding the
- * mapped property
+ * @throws IntrospectionException If an error occurs finding the mapped property
*/
- public void setMappedWriteMethod(final Method mappedSetter)
- throws IntrospectionException {
+ public void setMappedWriteMethod(final Method mappedSetter) throws IntrospectionException {
mappedWriteMethodRef = new MappedMethodReference(mappedSetter);
findMappedPropertyType();
}
diff --git a/src/main/java/org/apache/commons/beanutils2/MethodUtils.java b/src/main/java/org/apache/commons/beanutils2/MethodUtils.java
index 486859df..f44decad 100644
--- a/src/main/java/org/apache/commons/beanutils2/MethodUtils.java
+++ b/src/main/java/org/apache/commons/beanutils2/MethodUtils.java
@@ -33,19 +33,22 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- * <p>Utility reflection methods focused on methods in general rather than properties in particular.</p>
+ * <p>
+ * Utility reflection methods focused on methods in general rather than properties in particular.
+ * </p>
*
* <h2>Known Limitations</h2>
* <h3>Accessing Public Methods In A Default Access Superclass</h3>
- * <p>There is an issue when invoking public methods contained in a default access superclass.
- * Reflection locates these methods fine and correctly assigns them as public.
- * However, an {@code IllegalAccessException} is thrown if the method is invoked.</p>
+ * <p>
+ * There is an issue when invoking public methods contained in a default access superclass. Reflection locates these methods fine and correctly assigns them as
+ * public. However, an {@code IllegalAccessException} is thrown if the method is invoked.
+ * </p>
*
- * <p>{@code MethodUtils} contains a workaround for this situation.
- * It will attempt to call {@code setAccessible} on this method.
- * If this call succeeds, then the method can be invoked as normal.
- * This call will only succeed when the application has sufficient security privileges.
- * If this call fails then a warning will be logged and the method may fail.</p>
+ * <p>
+ * {@code MethodUtils} contains a workaround for this situation. It will attempt to call {@code setAccessible} on this method. If this call succeeds, then the
+ * method can be invoked as normal. This call will only succeed when the application has sufficient security privileges. If this call fails then a warning will
+ * be logged and the method may fail.
+ * </p>
*/
public class MethodUtils {
@@ -62,21 +65,22 @@ public class MethodUtils {
/**
* The sole constructor.
*
- * @param cls the class to reflect, must not be null
- * @param methodName the method name to obtain
+ * @param cls the class to reflect, must not be null
+ * @param methodName the method name to obtain
* @param paramTypes the array of classes representing the parameter types
- * @param exact whether the match has to be exact.
+ * @param exact whether the match has to be exact.
*/
- public MethodDescriptor(final Class<?> cls, final String methodName, final Class<?>[] paramTypes,
- final boolean exact) {
+ public MethodDescriptor(final Class<?> cls, final String methodName, final Class<?>[] paramTypes, final boolean exact) {
this.cls = Objects.requireNonNull(cls, "cls");
this.methodName = Objects.requireNonNull(methodName, "methodName");
this.paramTypes = paramTypes != null ? paramTypes : BeanUtils.EMPTY_CLASS_ARRAY;
- this.exact= exact;
+ this.exact = exact;
this.hashCode = methodName.length();
}
+
/**
* Checks for equality.
+ *
* @param obj object to be tested for equality
* @return true, if the object describes the same Method.
*/
@@ -85,18 +89,15 @@ public class MethodUtils {
if (!(obj instanceof MethodDescriptor)) {
return false;
}
- final MethodDescriptor md = (MethodDescriptor)obj;
+ final MethodDescriptor md = (MethodDescriptor) obj;
- return exact == md.exact &&
- methodName.equals(md.methodName) &&
- cls.equals(md.cls) &&
- Arrays.equals(paramTypes, md.paramTypes);
+ return exact == md.exact && methodName.equals(md.methodName) && cls.equals(md.cls) && Arrays.equals(paramTypes, md.paramTypes);
}
+
/**
- * Returns the string length of method name. I.e. if the
- * hash codes are different, the objects are different. If the
- * hash codes are the same, need to use the equals method to
- * determine equality.
+ * Returns the string length of method name. I.e. if the hash codes are different, the objects are different. If the hash codes are the same, need to
+ * use the equals method to determine equality.
+ *
* @return the string length of method name.
*/
@Override
@@ -110,53 +111,39 @@ public class MethodUtils {
/**
* Only log warning about accessibility work around once.
* <p>
- * Note that this is broken when this class is deployed via a shared
- * classloader in a container, as the warning message will be emitted
- * only once, not once per webapp. However making the warning appear
- * once per webapp means having a map keyed by context classloader
- * which introduces nasty memory-leak problems. As this warning is
- * really optional we can ignore this problem; only one of the webapps
- * will get the warning in its logs but that should be good enough.
+ * Note that this is broken when this class is deployed via a shared classloader in a container, as the warning message will be emitted only once, not once
+ * per webapp. However making the warning appear once per webapp means having a map keyed by context classloader which introduces nasty memory-leak
+ * problems. As this warning is really optional we can ignore this problem; only one of the webapps will get the warning in its logs but that should be good
+ * enough.
*/
private static boolean loggedAccessibleWarning;
/**
* Indicates whether methods should be cached for improved performance.
* <p>
- * Note that when this class is deployed via a shared classloader in
- * a container, this will affect all webapps. However making this
- * configurable per webapp would mean having a map keyed by context classloader
- * which may introduce memory-leak problems.
+ * Note that when this class is deployed via a shared classloader in a container, this will affect all webapps. However making this configurable per webapp
+ * would mean having a map keyed by context classloader which may introduce memory-leak problems.
*/
private static boolean CACHE_METHODS = true;
/**
* Stores a cache of MethodDescriptor -> Method in a WeakHashMap.
* <p>
- * The keys into this map only ever exist as temporary variables within
- * methods of this class, and are never exposed to users of this class.
- * This means that the WeakHashMap is used only as a mechanism for
- * limiting the size of the cache, that is, a way to tell the garbage collector
- * that the contents of the cache can be completely garbage-collected
- * whenever it needs the memory. Whether this is a good approach to
- * this problem is doubtful; something like the commons-collections
- * LRUMap may be more appropriate (though of course selecting an
- * appropriate size is an issue).
+ * The keys into this map only ever exist as temporary variables within methods of this class, and are never exposed to users of this class. This means that
+ * the WeakHashMap is used only as a mechanism for limiting the size of the cache, that is, a way to tell the garbage collector that the contents of the
+ * cache can be completely garbage-collected whenever it needs the memory. Whether this is a good approach to this problem is doubtful; something like the
+ * commons-collections LRUMap may be more appropriate (though of course selecting an appropriate size is an issue).
* <p>
- * This static variable is safe even when this code is deployed via a
- * shared classloader because it is keyed via a MethodDescriptor object
- * which has a Class as one of its members and that member is used in
- * the MethodDescriptor.equals method. So two components that load the same
- * class via different class loaders will generate non-equal MethodDescriptor
- * objects and hence end up with different entries in the map.
+ * This static variable is safe even when this code is deployed via a shared classloader because it is keyed via a MethodDescriptor object which has a Class
+ * as one of its members and that member is used in the MethodDescriptor.equals method. So two components that load the same class via different class
+ * loaders will generate non-equal MethodDescriptor objects and hence end up with different entries in the map.
*/
- private static final Map<MethodDescriptor, Reference<Method>> cache = Collections
- .synchronizedMap(new WeakHashMap<>());
+ private static final Map<MethodDescriptor, Reference<Method>> cache = Collections.synchronizedMap(new WeakHashMap<>());
/**
* Add a method to the cache.
*
- * @param md The method descriptor
+ * @param md The method descriptor
* @param method The method to cache
*/
private static void cacheMethod(final MethodDescriptor md, final Method method) {
@@ -167,6 +154,7 @@ public class MethodUtils {
/**
* Clear the method cache.
+ *
* @return the number of cached methods cleared
* @since 1.8.0
*/
@@ -177,11 +165,12 @@ public class MethodUtils {
}
/**
- * <p>Return an accessible method (that is, one that can be invoked via
- * reflection) that implements the specified Method. If no such method
- * can be found, return {@code null}.</p>
+ * <p>
+ * Return an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. If no such method can be found,
+ * return {@code null}.
+ * </p>
*
- * @param clazz The class of the object
+ * @param clazz The class of the object
* @param method The method that we wish to call
* @return The accessible method
* @since 1.8.0
@@ -202,8 +191,7 @@ public class MethodUtils {
clazz = method.getDeclaringClass();
} else {
if (!method.getDeclaringClass().isAssignableFrom(clazz)) {
- throw new IllegalArgumentException(clazz.getName() +
- " is not assignable from " + method.getDeclaringClass().getName());
+ throw new IllegalArgumentException(clazz.getName() + " is not assignable from " + method.getDeclaringClass().getName());
}
sameClass = clazz.equals(method.getDeclaringClass());
}
@@ -216,61 +204,48 @@ public class MethodUtils {
return method;
}
- final String methodName = method.getName();
+ final String methodName = method.getName();
final Class<?>[] parameterTypes = method.getParameterTypes();
// Check the implemented interfaces and subinterfaces
- method =
- getAccessibleMethodFromInterfaceNest(clazz,
- methodName,
- parameterTypes);
+ method = getAccessibleMethodFromInterfaceNest(clazz, methodName, parameterTypes);
// Check the superclass chain
if (method == null) {
- method = getAccessibleMethodFromSuperclass(clazz,
- methodName,
- parameterTypes);
+ method = getAccessibleMethodFromSuperclass(clazz, methodName, parameterTypes);
}
return method;
}
/**
- * <p>Return an accessible method (that is, one that can be invoked via
- * reflection) with given name and a single parameter. If no such method
- * can be found, return {@code null}.
- * Basically, a convenience wrapper that constructs a {@code Class}
- * array for you.</p>
+ * <p>
+ * Return an accessible method (that is, one that can be invoked via reflection) with given name and a single parameter. If no such method can be found,
+ * return {@code null}. Basically, a convenience wrapper that constructs a {@code Class} array for you.
+ * </p>
*
- * @param clazz get method from this class
- * @param methodName get method with this name
+ * @param clazz get method from this class
+ * @param methodName get method with this name
* @param parameterType taking this type of parameter
* @return The accessible method
*/
- public static Method getAccessibleMethod(
- final Class<?> clazz,
- final String methodName,
- final Class<?> parameterType) {
- final Class<?>[] parameterTypes = {parameterType};
+ public static Method getAccessibleMethod(final Class<?> clazz, final String methodName, final Class<?> parameterType) {
+ final Class<?>[] parameterTypes = { parameterType };
return getAccessibleMethod(clazz, methodName, parameterTypes);
}
/**
- * <p>Return an accessible method (that is, one that can be invoked via
- * reflection) with given name and parameters. If no such method
- * can be found, return {@code null}.
- * This is just a convenient wrapper for
- * {@link #getAccessibleMethod(Method method)}.</p>
+ * <p>
+ * Return an accessible method (that is, one that can be invoked via reflection) with given name and parameters. If no such method can be found, return
+ * {@code null}. This is just a convenient wrapper for {@link #getAccessibleMethod(Method method)}.
+ * </p>
*
- * @param clazz get method from this class
- * @param methodName get method with this name
+ * @param clazz get method from this class
+ * @param methodName get method with this name
* @param parameterTypes with these parameters types
* @return The accessible method
*/
- public static Method getAccessibleMethod(
- final Class<?> clazz,
- final String methodName,
- final Class<?>[] parameterTypes) {
+ public static Method getAccessibleMethod(final Class<?> clazz, final String methodName, final Class<?>[] parameterTypes) {
try {
final MethodDescriptor md = new MethodDescriptor(clazz, methodName, parameterTypes, true);
// Check the cache first
@@ -279,8 +254,7 @@ public class MethodUtils {
return method;
}
- method = getAccessibleMethod
- (clazz, clazz.getMethod(methodName, parameterTypes));
+ method = getAccessibleMethod(clazz, clazz.getMethod(methodName, parameterTypes));
cacheMethod(md, method);
return method;
} catch (final NoSuchMethodException e) {
@@ -289,9 +263,10 @@ public class MethodUtils {
}
/**
- * <p>Return an accessible method (that is, one that can be invoked via
- * reflection) that implements the specified Method. If no such method
- * can be found, return {@code null}.</p>
+ * <p>
+ * Return an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. If no such method can be found,
+ * return {@code null}.
+ * </p>
*
* @param method The method that we wish to call
* @return The accessible method
@@ -306,21 +281,21 @@ public class MethodUtils {
}
/**
- * <p>Return an accessible method (that is, one that can be invoked via
- * reflection) that implements the specified method, by scanning through
- * all implemented interfaces and subinterfaces. If no such method
- * can be found, return {@code null}.</p>
+ * <p>
+ * Return an accessible method (that is, one that can be invoked via reflection) that implements the specified method, by scanning through all implemented
+ * interfaces and subinterfaces. If no such method can be found, return {@code null}.
+ * </p>
*
- * <p> There isn't any good reason why this method must be private.
- * It is because there doesn't seem any reason why other classes should
- * call this rather than the higher level methods.</p>
+ * <p>
+ * There isn't any good reason why this method must be private. It is because there doesn't seem any reason why other classes should call this rather than
+ * the higher level methods.
+ * </p>
*
- * @param clazz Parent class for the interfaces to be checked
- * @param methodName Method name of the method we wish to call
+ * @param clazz Parent class for the interfaces to be checked
+ * @param methodName Method name of the method we wish to call
* @param parameterTypes The parameter type signatures
*/
- private static Method getAccessibleMethodFromInterfaceNest
- (Class<?> clazz, final String methodName, final Class<?>[] parameterTypes) {
+ private static Method getAccessibleMethodFromInterfaceNest(Class<?> clazz, final String methodName, final Class<?>[] parameterTypes) {
Method method = null;
// Search up the superclass chain
@@ -337,11 +312,10 @@ public class MethodUtils {
// Does the method exist on this interface?
try {
- method = anInterface.getDeclaredMethod(methodName,
- parameterTypes);
+ method = anInterface.getDeclaredMethod(methodName, parameterTypes);
} catch (final NoSuchMethodException e) {
- /* Swallow, if no method is found after the loop then this
- * method returns null.
+ /*
+ * Swallow, if no method is found after the loop then this method returns null.
*/
}
if (method != null) {
@@ -349,10 +323,7 @@ public class MethodUtils {
}
// Recursively check our parent interfaces
- method =
- getAccessibleMethodFromInterfaceNest(anInterface,
- methodName,
- parameterTypes);
+ method = getAccessibleMethodFromInterfaceNest(anInterface, methodName, parameterTypes);
if (method != null) {
return method;
}
@@ -366,16 +337,16 @@ public class MethodUtils {
}
/**
- * <p>Return an accessible method (that is, one that can be invoked via
- * reflection) by scanning through the superclasses. If no such method
- * can be found, return {@code null}.</p>
+ * <p>
+ * Return an accessible method (that is, one that can be invoked via reflection) by scanning through the superclasses. If no such method can be found,
+ * return {@code null}.
+ * </p>
*
- * @param clazz Class to be checked
- * @param methodName Method name of the method we wish to call
+ * @param clazz Class to be checked
+ * @param methodName Method name of the method we wish to call
* @param parameterTypes The parameter type signatures
*/
- private static Method getAccessibleMethodFromSuperclass
- (final Class<?> clazz, final String methodName, final Class<?>[] parameterTypes) {
+ private static Method getAccessibleMethodFromSuperclass(final Class<?> clazz, final String methodName, final Class<?>[] parameterTypes) {
Class<?> parentClazz = clazz.getSuperclass();
while (parentClazz != null) {
if (Modifier.isPublic(parentClazz.getModifiers())) {
@@ -407,32 +378,28 @@ public class MethodUtils {
}
/**
- * <p>Find an accessible method that matches the given name and has compatible parameters.
- * Compatible parameters mean that every method parameter is assignable from
- * the given parameters.
- * In other words, it finds a method with the given name
- * that will take the parameters given.</p>
+ * <p>
+ * Find an accessible method that matches the given name and has compatible parameters. Compatible parameters mean that every method parameter is assignable
+ * from the given parameters. In other words, it finds a method with the given name that will take the parameters given.
+ * </p>
*
- * <p>This method is slightly indeterministic since it loops
- * through methods names and return the first matching method.</p>
+ * <p>
+ * This method is slightly indeterministic since it loops through methods names and return the first matching method.
+ * </p>
*
- * <p>This method is used by
- * {@link
- * #invokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)}.
+ * <p>
+ * This method is used by {@link #invokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)}.
*
- * <p>This method can match primitive parameter by passing in wrapper classes.
- * For example, a {@code Boolean</code> will match a primitive <code>boolean}
+ * <p>
+ * This method can match primitive parameter by passing in wrapper classes. For example, a {@code Boolean</code> will match a primitive <code>boolean}
* parameter.
*
- * @param clazz find method in this class
- * @param methodName find method with this name
+ * @param clazz find method in this class
+ * @param methodName find method with this name
* @param parameterTypes find method with compatible parameters
* @return The accessible method
*/
- public static Method getMatchingAccessibleMethod(
- final Class<?> clazz,
- final String methodName,
- final Class<?>[] parameterTypes) {
+ public static Method getMatchingAccessibleMethod(final Class<?> clazz, final String methodName, final Class<?>[] parameterTypes) {
// trace logging
if (LOG.isTraceEnabled()) {
LOG.trace("Matching name=" + methodName + " on " + clazz);
@@ -459,7 +426,8 @@ public class MethodUtils {
cacheMethod(md, method);
return method;
- } catch (final NoSuchMethodException e) { /* SWALLOW */ }
+ } catch (final NoSuchMethodException e) {
+ /* SWALLOW */ }
// search through all methods
final int paramSize = parameterTypes.length;
@@ -480,15 +448,14 @@ public class MethodUtils {
final int methodParamSize = methodsParams.length;
if (methodParamSize == paramSize) {
boolean match = true;
- for (int n = 0 ; n < methodParamSize; n++) {
+ for (int n = 0; n < methodParamSize; n++) {
if (LOG.isTraceEnabled()) {
LOG.trace("Param=" + parameterTypes[n].getName());
LOG.trace("Method=" + methodsParams[n].getName());
}
if (!isAssignmentCompatible(methodsParams[n], parameterTypes[n])) {
if (LOG.isTraceEnabled()) {
- LOG.trace(methodsParams[n] + " is not assignable from "
- + parameterTypes[n]);
+ LOG.trace(methodsParams[n] + " is not assignable from " + parameterTypes[n]);
}
match = false;
break;
@@ -500,14 +467,13 @@ public class MethodUtils {
final Method method = getAccessibleMethod(clazz, method2);
if (method != null) {
if (LOG.isTraceEnabled()) {
- LOG.trace(method + " accessible version of "
- + method2);
+ LOG.trace(method + " accessible version of " + method2);
}
setMethodAccessible(method); // Default access superclass workaround
myCost = getTotalTransformationCost(parameterTypes, method.getParameterTypes());
- if ( myCost < bestMatchCost ) {
- bestMatch = method;
- bestMatchCost = myCost;
+ if (myCost < bestMatchCost) {
+ bestMatch = method;
+ bestMatchCost = myCost;
}
}
@@ -527,10 +493,10 @@ public class MethodUtils {
}
/**
- * Gets the number of steps required needed to turn the source class into the
- * destination class. This represents the number of steps in the object hierarchy
+ * Gets the number of steps required needed to turn the source class into the destination class. This represents the number of steps in the object hierarchy
* graph.
- * @param srcClass The source class
+ *
+ * @param srcClass The source class
* @param destClass The destination class
* @return The cost of transforming an object
*/
@@ -557,8 +523,7 @@ public class MethodUtils {
}
/*
- * If the destination class is null, we've traveled all the way up to
- * an Object match. We'll penalize this by adding 1.5 to the cost.
+ * If the destination class is null, we've traveled all the way up to an Object match. We'll penalize this by adding 1.5 to the cost.
*/
if (srcClass == null) {
cost += 1.5f;
@@ -568,11 +533,11 @@ public class MethodUtils {
}
/**
- * Gets the class for the primitive type corresponding to the primitive wrapper class given.
- * For example, an instance of {@code Boolean.class</code> returns a <code>boolean.class}.
+ * Gets the class for the primitive type corresponding to the primitive wrapper class given. For example, an instance of
+ * {@code Boolean.class</code> returns a <code>boolean.class}.
+ *
* @param wrapperType the
- * @return the primitive type class corresponding to the given wrapper class,
- * null if no match is found
+ * @return the primitive type class corresponding to the given wrapper class, null if no match is found
*/
public static Class<?> getPrimitiveType(final Class<?> wrapperType) {
// does anyone know a better strategy than comparing names?
@@ -607,11 +572,10 @@ public class MethodUtils {
}
/**
- * Gets the wrapper object class for the given primitive type class.
- * For example, passing {@code boolean.class</code> returns <code>Boolean.class}
+ * Gets the wrapper object class for the given primitive type class. For example, passing {@code boolean.class</code> returns <code>Boolean.class}
+ *
* @param primitiveType the primitive type class for which a match is to be found
- * @return the wrapper type associated with the given primitive
- * or null if no match is found
+ * @return the wrapper type associated with the given primitive or null if no match is found
*/
public static Class<?> getPrimitiveWrapper(final Class<?> primitiveType) {
// does anyone know a better strategy than comparing names?
@@ -643,9 +607,9 @@ public class MethodUtils {
}
/**
- * Returns the sum of the object transformation cost for each class in the source
- * argument list.
- * @param srcArgs The source arguments
+ * Returns the sum of the object transformation cost for each class in the source argument list.
+ *
+ * @param srcArgs The source arguments
* @param destArgs The destination arguments
* @return The total transformation cost
*/
@@ -662,64 +626,50 @@ public class MethodUtils {
}
/**
- * <p>Invoke a method whose parameter type matches exactly the object
- * type.</p>
+ * <p>
+ * Invoke a method whose parameter type matches exactly the object type.
+ * </p>
*
- * <p> This is a convenient wrapper for
- * {@link #invokeExactMethod(Object object,String methodName,Object [] args)}.
+ * <p>
+ * This is a convenient wrapper for {@link #invokeExactMethod(Object object,String methodName,Object [] args)}.
* </p>
*
- * @param object invoke method on this object
+ * @param object invoke method on this object
* @param methodName get method with this name
- * @param arg use this argument. May be null (this will result in calling the
- * parameterless method with name {@code methodName}).
+ * @param arg use this argument. May be null (this will result in calling the parameterless method with name {@code methodName}).
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
*/
- public static Object invokeExactMethod(
- final Object object,
- final String methodName,
- final Object arg)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeExactMethod(final Object object, final String methodName, final Object arg)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
final Object[] args = toArray(arg);
return invokeExactMethod(object, methodName, args);
}
/**
- * <p>Invoke a method whose parameter types match exactly the object
- * types.</p>
+ * <p>
+ * Invoke a method whose parameter types match exactly the object types.
+ * </p>
*
- * <p> This uses reflection to invoke the method obtained from a call to
- * {@code getAccessibleMethod()}.</p>
+ * <p>
+ * This uses reflection to invoke the method obtained from a call to {@code getAccessibleMethod()}.
+ * </p>
*
- * @param object invoke method on this object
+ * @param object invoke method on this object
* @param methodName get method with this name
- * @param args use these arguments - treat null as empty array (passing null will
- * result in calling the parameterless method with name {@code methodName}).
+ * @param args use these arguments - treat null as empty array (passing null will result in calling the parameterless method with name
+ * {@code methodName}).
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
*/
- public static Object invokeExactMethod(
- final Object object,
- final String methodName,
- Object[] args)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeExactMethod(final Object object, final String methodName, Object[] args)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
if (args == null) {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
}
@@ -732,34 +682,27 @@ public class MethodUtils {
}
/**
- * <p>Invoke a method whose parameter types match exactly the parameter
- * types given.</p>
+ * <p>
+ * Invoke a method whose parameter types match exactly the parameter types given.
+ * </p>
*
- * <p>This uses reflection to invoke the method obtained from a call to
- * {@code getAccessibleMethod()}.</p>
+ * <p>
+ * This uses reflection to invoke the method obtained from a call to {@code getAccessibleMethod()}.
+ * </p>
*
- * @param object invoke method on this object
- * @param methodName get method with this name
- * @param args use these arguments - treat null as empty array (passing null will
- * result in calling the parameterless method with name {@code methodName}).
+ * @param object invoke method on this object
+ * @param methodName get method with this name
+ * @param args use these arguments - treat null as empty array (passing null will result in calling the parameterless method with name
+ * {@code methodName}).
* @param parameterTypes match these parameters - treat null as empty array
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
*/
- public static Object invokeExactMethod(
- final Object object,
- final String methodName,
- Object[] args,
- Class<?>[] parameterTypes)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeExactMethod(final Object object, final String methodName, Object[] args, Class<?>[] parameterTypes)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
if (args == null) {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
}
@@ -768,78 +711,60 @@ public class MethodUtils {
parameterTypes = BeanUtils.EMPTY_CLASS_ARRAY;
}
- final Method method = getAccessibleMethod(
- object.getClass(),
- methodName,
- parameterTypes);
+ final Method method = getAccessibleMethod(object.getClass(), methodName, parameterTypes);
if (method == null) {
- throw new NoSuchMethodException("No such accessible method: " +
- methodName + "() on object: " + object.getClass().getName());
+ throw new NoSuchMethodException("No such accessible method: " + methodName + "() on object: " + object.getClass().getName());
}
return method.invoke(object, args);
}
/**
- * <p>Invoke a static method whose parameter type matches exactly the object
- * type.</p>
+ * <p>
+ * Invoke a static method whose parameter type matches exactly the object type.
+ * </p>
*
- * <p> This is a convenient wrapper for
- * {@link #invokeExactStaticMethod(Class objectClass,String methodName,Object [] args)}.
+ * <p>
+ * This is a convenient wrapper for {@link #invokeExactStaticMethod(Class objectClass,String methodName,Object [] args)}.
* </p>
*
* @param objectClass invoke static method on this class
- * @param methodName get method with this name
- * @param arg use this argument. May be null (this will result in calling the
- * parameterless method with name {@code methodName}).
+ * @param methodName get method with this name
+ * @param arg use this argument. May be null (this will result in calling the parameterless method with name {@code methodName}).
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
* @since 1.8.0
*/
- public static Object invokeExactStaticMethod(
- final Class<?> objectClass,
- final String methodName,
- final Object arg)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeExactStaticMethod(final Class<?> objectClass, final String methodName, final Object arg)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
final Object[] args = toArray(arg);
- return invokeExactStaticMethod (objectClass, methodName, args);
+ return invokeExactStaticMethod(objectClass, methodName, args);
}
/**
- * <p>Invoke a static method whose parameter types match exactly the object
- * types.</p>
+ * <p>
+ * Invoke a static method whose parameter types match exactly the object types.
+ * </p>
*
- * <p> This uses reflection to invoke the method obtained from a call to
- * {@link #getAccessibleMethod(Class, String, Class[])}.</p>
+ * <p>
+ * This uses reflection to invoke the method obtained from a call to {@link #getAccessibleMethod(Class, String, Class[])}.
+ * </p>
*
* @param objectClass invoke static method on this class
- * @param methodName get method with this name
- * @param args use these arguments - treat null as empty array (passing null will
- * result in calling the parameterless method with name {@code methodName}).
+ * @param methodName get method with this name
+ * @param args use these arguments - treat null as empty array (passing null will result in calling the parameterless method with name
+ * {@code methodName}).
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
* @since 1.8.0
*/
- public static Object invokeExactStaticMethod(
- final Class<?> objectClass,
- final String methodName,
- Object[] args)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeExactStaticMethod(final Class<?> objectClass, final String methodName, Object[] args)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
if (args == null) {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
}
@@ -852,35 +777,28 @@ public class MethodUtils {
}
/**
- * <p>Invoke a static method whose parameter types match exactly the parameter
- * types given.</p>
+ * <p>
+ * Invoke a static method whose parameter types match exactly the parameter types given.
+ * </p>
*
- * <p>This uses reflection to invoke the method obtained from a call to
- * {@link #getAccessibleMethod(Class, String, Class[])}.</p>
+ * <p>
+ * This uses reflection to invoke the method obtained from a call to {@link #getAccessibleMethod(Class, String, Class[])}.
+ * </p>
*
- * @param objectClass invoke static method on this class
- * @param methodName get method with this name
- * @param args use these arguments - treat null as empty array (passing null will
- * result in calling the parameterless method with name {@code methodName}).
+ * @param objectClass invoke static method on this class
+ * @param methodName get method with this name
+ * @param args use these arguments - treat null as empty array (passing null will result in calling the parameterless method with name
+ * {@code methodName}).
* @param parameterTypes match these parameters - treat null as empty array
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
* @since 1.8.0
*/
- public static Object invokeExactStaticMethod(
- final Class<?> objectClass,
- final String methodName,
- Object[] args,
- Class<?>[] parameterTypes)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeExactStaticMethod(final Class<?> objectClass, final String methodName, Object[] args, Class<?>[] parameterTypes)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
if (args == null) {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
}
@@ -889,93 +807,78 @@ public class MethodUtils {
parameterTypes = BeanUtils.EMPTY_CLASS_ARRAY;
}
- final Method method = getAccessibleMethod(
- objectClass,
- methodName,
- parameterTypes);
+ final Method method = getAccessibleMethod(objectClass, methodName, parameterTypes);
if (method == null) {
- throw new NoSuchMethodException("No such accessible method: " +
- methodName + "() on class: " + objectClass.getName());
+ throw new NoSuchMethodException("No such accessible method: " + methodName + "() on class: " + objectClass.getName());
}
return method.invoke(null, args);
}
/**
- * <p>Invoke a named method whose parameter type matches the object type.</p>
+ * <p>
+ * Invoke a named method whose parameter type matches the object type.
+ * </p>
*
- * <p>The behavior of this method is less deterministic
- * than {@code invokeExactMethod()}.
- * It loops through all methods with names that match
- * and then executes the first it finds with compatible parameters.</p>
+ * <p>
+ * The behavior of this method is less deterministic than {@code invokeExactMethod()}. It loops through all methods with names that match and then executes
+ * the first it finds with compatible parameters.
+ * </p>
*
- * <p>This method supports calls to methods taking primitive parameters
- * via passing in wrapping classes. So, for example, a {@code Boolean} class
- * would match a {@code boolean} primitive.</p>
+ * <p>
+ * This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a {@code Boolean} class would match a
+ * {@code boolean} primitive.
+ * </p>
*
- * <p> This is a convenient wrapper for
- * {@link #invokeMethod(Object object,String methodName,Object [] args)}.
+ * <p>
+ * This is a convenient wrapper for {@link #invokeMethod(Object object,String methodName,Object [] args)}.
* </p>
*
- * @param object invoke method on this object
+ * @param object invoke method on this object
* @param methodName get method with this name
- * @param arg use this argument. May be null (this will result in calling the
- * parameterless method with name {@code methodName}).
+ * @param arg use this argument. May be null (this will result in calling the parameterless method with name {@code methodName}).
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
*/
- public static Object invokeMethod(
- final Object object,
- final String methodName,
- final Object arg)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeMethod(final Object object, final String methodName, final Object arg)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
final Object[] args = toArray(arg);
return invokeMethod(object, methodName, args);
}
/**
- * <p>Invoke a named method whose parameter type matches the object type.</p>
+ * <p>
+ * Invoke a named method whose parameter type matches the object type.
+ * </p>
*
- * <p>The behavior of this method is less deterministic
- * than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}.
- * It loops through all methods with names that match
- * and then executes the first it finds with compatible parameters.</p>
+ * <p>
+ * The behavior of this method is less deterministic than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}. It loops through all
+ * methods with names that match and then executes the first it finds with compatible parameters.
+ * </p>
*
- * <p>This method supports calls to methods taking primitive parameters
- * via passing in wrapping classes. So, for example, a {@code Boolean} class
- * would match a {@code boolean} primitive.</p>
+ * <p>
+ * This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a {@code Boolean} class would match a
+ * {@code boolean} primitive.
+ * </p>
*
- * <p> This is a convenient wrapper for
- * {@link #invokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)}.
+ * <p>
+ * This is a convenient wrapper for {@link #invokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)}.
* </p>
*
- * @param object invoke method on this object
+ * @param object invoke method on this object
* @param methodName get method with this name
- * @param args use these arguments - treat null as empty array (passing null will
- * result in calling the parameterless method with name {@code methodName}).
+ * @param args use these arguments - treat null as empty array (passing null will result in calling the parameterless method with name
+ * {@code methodName}).
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
*/
- public static Object invokeMethod(
- final Object object,
- final String methodName,
- Object[] args)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeMethod(final Object object, final String methodName, Object[] args)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
if (args == null) {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
}
@@ -988,41 +891,35 @@ public class MethodUtils {
}
/**
- * <p>Invoke a named method whose parameter type matches the object type.</p>
+ * <p>
+ * Invoke a named method whose parameter type matches the object type.
+ * </p>
*
- * <p>The behavior of this method is less deterministic
- * than {@link
- * #invokeExactMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)}.
- * It loops through all methods with names that match
- * and then executes the first it finds with compatible parameters.</p>
+ * <p>
+ * The behavior of this method is less deterministic than
+ * {@link #invokeExactMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)}. It loops through all methods with names that match
+ * and then executes the first it finds with compatible parameters.
+ * </p>
*
- * <p>This method supports calls to methods taking primitive parameters
- * via passing in wrapping classes. So, for example, a {@code Boolean} class
- * would match a {@code boolean} primitive.</p>
+ * <p>
+ * This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a {@code Boolean} class would match a
+ * {@code boolean} primitive.
+ * </p>
*
*
- * @param object invoke method on this object
- * @param methodName get method with this name
- * @param args use these arguments - treat null as empty array (passing null will
- * result in calling the parameterless method with name {@code methodName}).
+ * @param object invoke method on this object
+ * @param methodName get method with this name
+ * @param args use these arguments - treat null as empty array (passing null will result in calling the parameterless method with name
+ * {@code methodName}).
* @param parameterTypes match these parameters - treat null as empty array
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
*/
- public static Object invokeMethod(
- final Object object,
- final String methodName,
- Object[] args,
- Class<?>[] parameterTypes)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeMethod(final Object object, final String methodName, Object[] args, Class<?>[] parameterTypes)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
if (parameterTypes == null) {
parameterTypes = BeanUtils.EMPTY_CLASS_ARRAY;
}
@@ -1030,95 +927,80 @@ public class MethodUtils {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
}
- final Method method = getMatchingAccessibleMethod(
- object.getClass(),
- methodName,
- parameterTypes);
+ final Method method = getMatchingAccessibleMethod(object.getClass(), methodName, parameterTypes);
if (method == null) {
- throw new NoSuchMethodException("No such accessible method: " +
- methodName + "() on object: " + object.getClass().getName());
+ throw new NoSuchMethodException("No such accessible method: " + methodName + "() on object: " + object.getClass().getName());
}
return method.invoke(object, args);
}
/**
- * <p>Invoke a named static method whose parameter type matches the object type.</p>
+ * <p>
+ * Invoke a named static method whose parameter type matches the object type.
+ * </p>
*
- * <p>The behavior of this method is less deterministic
- * than {@link #invokeExactMethod(Object, String, Object[], Class[])}.
- * It loops through all methods with names that match
- * and then executes the first it finds with compatible parameters.</p>
+ * <p>
+ * The behavior of this method is less deterministic than {@link #invokeExactMethod(Object, String, Object[], Class[])}. It loops through all methods with
+ * names that match and then executes the first it finds with compatible parameters.
+ * </p>
*
- * <p>This method supports calls to methods taking primitive parameters
- * via passing in wrapping classes. So, for example, a {@code Boolean} class
- * would match a {@code boolean} primitive.</p>
+ * <p>
+ * This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a {@code Boolean} class would match a
+ * {@code boolean} primitive.
+ * </p>
*
- * <p> This is a convenient wrapper for
- * {@link #invokeStaticMethod(Class objectClass,String methodName,Object [] args)}.
+ * <p>
+ * This is a convenient wrapper for {@link #invokeStaticMethod(Class objectClass,String methodName,Object [] args)}.
* </p>
*
* @param objectClass invoke static method on this class
- * @param methodName get method with this name
- * @param arg use this argument. May be null (this will result in calling the
- * parameterless method with name {@code methodName}).
+ * @param methodName get method with this name
+ * @param arg use this argument. May be null (this will result in calling the parameterless method with name {@code methodName}).
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
* @since 1.8.0
*/
- public static Object invokeStaticMethod(
- final Class<?> objectClass,
- final String methodName,
- final Object arg)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeStaticMethod(final Class<?> objectClass, final String methodName, final Object arg)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
final Object[] args = toArray(arg);
- return invokeStaticMethod (objectClass, methodName, args);
+ return invokeStaticMethod(objectClass, methodName, args);
}
/**
- * <p>Invoke a named static method whose parameter type matches the object type.</p>
+ * <p>
+ * Invoke a named static method whose parameter type matches the object type.
+ * </p>
*
- * <p>The behavior of this method is less deterministic
- * than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}.
- * It loops through all methods with names that match
- * and then executes the first it finds with compatible parameters.</p>
+ * <p>
+ * The behavior of this method is less deterministic than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}. It loops through all
+ * methods with names that match and then executes the first it finds with compatible parameters.
+ * </p>
*
- * <p>This method supports calls to methods taking primitive parameters
- * via passing in wrapping classes. So, for example, a {@code Boolean} class
- * would match a {@code boolean} primitive.</p>
+ * <p>
+ * This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a {@code Boolean} class would match a
+ * {@code boolean} primitive.
+ * </p>
*
- * <p> This is a convenient wrapper for
- * {@link #invokeStaticMethod(Class objectClass, String methodName, Object[] args, Class[] parameterTypes)}.
+ * <p>
+ * This is a convenient wrapper for {@link #invokeStaticMethod(Class objectClass, String methodName, Object[] args, Class[] parameterTypes)}.
* </p>
*
* @param objectClass invoke static method on this class
- * @param methodName get method with this name
- * @param args use these arguments - treat null as empty array (passing null will
- * result in calling the parameterless method with name {@code methodName}).
+ * @param methodName get method with this name
+ * @param args use these arguments - treat null as empty array (passing null will result in calling the parameterless method with name
+ * {@code methodName}).
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
* @since 1.8.0
*/
- public static Object invokeStaticMethod(
- final Class<?> objectClass,
- final String methodName,
- Object[] args)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeStaticMethod(final Class<?> objectClass, final String methodName, Object[] args)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
if (args == null) {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
}
@@ -1127,46 +1009,40 @@ public class MethodUtils {
for (int i = 0; i < arguments; i++) {
parameterTypes[i] = args[i].getClass();
}
- return invokeStaticMethod (objectClass, methodName, args, parameterTypes);
+ return invokeStaticMethod(objectClass, methodName, args, parameterTypes);
}
/**
- * <p>Invoke a named static method whose parameter type matches the object type.</p>
+ * <p>
+ * Invoke a named static method whose parameter type matches the object type.
+ * </p>
*
- * <p>The behavior of this method is less deterministic
- * than {@link
- * #invokeExactStaticMethod(Class objectClass, String methodName, Object[] args, Class[] parameterTypes)}.
- * It loops through all methods with names that match
- * and then executes the first it finds with compatible parameters.</p>
+ * <p>
+ * The behavior of this method is less deterministic than
+ * {@link #invokeExactStaticMethod(Class objectClass, String methodName, Object[] args, Class[] parameterTypes)}. It loops through all methods with names
+ * that match and then executes the first it finds with compatible parameters.
+ * </p>
*
- * <p>This method supports calls to methods taking primitive parameters
- * via passing in wrapping classes. So, for example, a {@code Boolean} class
- * would match a {@code boolean} primitive.</p>
+ * <p>
+ * This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a {@code Boolean} class would match a
+ * {@code boolean} primitive.
+ * </p>
*
*
- * @param objectClass invoke static method on this class
- * @param methodName get method with this name
- * @param args use these arguments - treat null as empty array (passing null will
- * result in calling the parameterless method with name {@code methodName}).
+ * @param objectClass invoke static method on this class
+ * @param methodName get method with this name
+ * @param args use these arguments - treat null as empty array (passing null will result in calling the parameterless method with name
+ * {@code methodName}).
* @param parameterTypes match these parameters - treat null as empty array
* @return The value returned by the invoked method
*
- * @throws NoSuchMethodException if there is no such accessible method
- * @throws InvocationTargetException wraps an exception thrown by the
- * method invoked
- * @throws IllegalAccessException if the requested method is not accessible
- * via reflection
+ * @throws NoSuchMethodException if there is no such accessible method
+ * @throws InvocationTargetException wraps an exception thrown by the method invoked
+ * @throws IllegalAccessException if the requested method is not accessible via reflection
* @since 1.8.0
*/
- public static Object invokeStaticMethod(
- final Class<?> objectClass,
- final String methodName,
- Object[] args,
- Class<?>[] parameterTypes)
- throws
- NoSuchMethodException,
- IllegalAccessException,
- InvocationTargetException {
+ public static Object invokeStaticMethod(final Class<?> objectClass, final String methodName, Object[] args, Class<?>[] parameterTypes)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
if (parameterTypes == null) {
parameterTypes = BeanUtils.EMPTY_CLASS_ARRAY;
@@ -1175,22 +1051,20 @@ public class MethodUtils {
args = BeanUtils.EMPTY_OBJECT_ARRAY;
}
- final Method method = getMatchingAccessibleMethod(
- objectClass,
- methodName,
- parameterTypes);
+ final Method method = getMatchingAccessibleMethod(objectClass, methodName, parameterTypes);
if (method == null) {
- throw new NoSuchMethodException("No such accessible method: " +
- methodName + "() on class: " + objectClass.getName());
+ throw new NoSuchMethodException("No such accessible method: " + methodName + "() on class: " + objectClass.getName());
}
return method.invoke(null, args);
}
/**
- * <p>Determine whether a type can be used as a parameter in a method invocation.
- * This method handles primitive conversions correctly.</p>
+ * <p>
+ * Determine whether a type can be used as a parameter in a method invocation. This method handles primitive conversions correctly.
+ * </p>
*
- * <p>In order words, it will match a {@code Boolean</code> to a <code>boolean},
+ * <p>
+ * In order words, it will match a {@code Boolean</code> to a <code>boolean},
* a {@code Long</code> to a <code>long},
* a {@code Float</code> to a <code>float},
* a {@code Integer</code> to a <code>int},
@@ -1198,7 +1072,7 @@ public class MethodUtils {
* Now logic widening matches are allowed.
* For example, a {@code Long</code> will not match a <code>int}.
*
- * @param parameterType the type of parameter accepted by the method
+ * @param parameterType the type of parameter accepted by the method
* @param parameterization the type of parameter being tested
*
* @return true if the assignment is compatible.
@@ -1222,11 +1096,9 @@ public class MethodUtils {
}
/**
- * Sets whether methods should be cached for greater performance or not,
- * default is {@code true}.
+ * Sets whether methods should be cached for greater performance or not, default is {@code true}.
*
- * @param cacheMethods {@code true} if methods should be
- * cached for greater performance, otherwise {@code false}
+ * @param cacheMethods {@code true} if methods should be cached for greater performance, otherwise {@code false}
* @since 1.8.0
*/
public static synchronized void setCacheMethods(final boolean cacheMethods) {
@@ -1238,6 +1110,7 @@ public class MethodUtils {
/**
* Try to make the method accessible
+ *
* @param method The source arguments
*/
private static void setMethodAccessible(final Method method) {
@@ -1268,11 +1141,8 @@ public class MethodUtils {
boolean vulnerableJVM = false;
try {
final String specVersion = SystemProperties.getJavaSpecificationVersion();
- if (specVersion.charAt(0) == '1' &&
- (specVersion.charAt(2) == '0' ||
- specVersion.charAt(2) == '1' ||
- specVersion.charAt(2) == '2' ||
- specVersion.charAt(2) == '3')) {
+ if (specVersion.charAt(0) == '1'
+ && (specVersion.charAt(2) == '0' || specVersion.charAt(2) == '1' || specVersion.charAt(2) == '2' || specVersion.charAt(2) == '3')) {
vulnerableJVM = true;
}
@@ -1281,9 +1151,7 @@ public class MethodUtils {
vulnerableJVM = true;
}
if (vulnerableJVM) {
- LOG.warn(
- "Current Security Manager restricts use of workarounds for reflection bugs "
- + " in pre-1.4 JVMs.");
+ LOG.warn("Current Security Manager restricts use of workarounds for reflection bugs " + " in pre-1.4 JVMs.");
}
loggedAccessibleWarning = true;
}
diff --git a/src/main/java/org/apache/commons/beanutils2/MutableDynaClass.java b/src/main/java/org/apache/commons/beanutils2/MutableDynaClass.java
index d6e10d51..181e332c 100644
--- a/src/main/java/org/apache/commons/beanutils2/MutableDynaClass.java
+++ b/src/main/java/org/apache/commons/beanutils2/MutableDynaClass.java
@@ -18,83 +18,68 @@
package org.apache.commons.beanutils2;
/**
- * <p>A specialized extension to {@code DynaClass} that allows properties
- * to be added or removed dynamically.</p>
+ * <p>
+ * A specialized extension to {@code DynaClass} that allows properties to be added or removed dynamically.
+ * </p>
*
- * <p><strong>WARNING</strong> - No guarantees that this will be in the final
- * APIs ... it's here primarily to preserve some concepts that were in the
- * original proposal for further discussion.</p>
+ * <p>
+ * <strong>WARNING</strong> - No guarantees that this will be in the final APIs ... it's here primarily to preserve some concepts that were in the original
+ * proposal for further discussion.
+ * </p>
*/
public interface MutableDynaClass extends DynaClass {
/**
- * Add a new dynamic property with no restrictions on data type,
- * readability, or writeability.
+ * Add a new dynamic property with no restrictions on data type, readability, or writeability.
*
* @param name Name of the new dynamic property
*
* @throws IllegalArgumentException if name is null
- * @throws IllegalStateException if this DynaClass is currently
- * restricted, so no new properties can be added
+ * @throws IllegalStateException if this DynaClass is currently restricted, so no new properties can be added
*/
void add(String name);
/**
- * Add a new dynamic property with the specified data type, but with
- * no restrictions on readability or writeability.
+ * Add a new dynamic property with the specified data type, but with no restrictions on readability or writeability.
*
* @param name Name of the new dynamic property
- * @param type Data type of the new dynamic property (null for no
- * restrictions)
+ * @param type Data type of the new dynamic property (null for no restrictions)
*
* @throws IllegalArgumentException if name is null
- * @throws IllegalStateException if this DynaClass is currently
- * restricted, so no new properties can be added
+ * @throws IllegalStateException if this DynaClass is currently restricted, so no new properties can be added
*/
void add(String name, Class<?> type);
/**
- * Add a new dynamic property with the specified data type, readability,
- * and writeability.
+ * Add a new dynamic property with the specified data type, readability, and writeability.
*
- * @param name Name of the new dynamic property
- * @param type Data type of the new dynamic property (null for no
- * restrictions)
- * @param readable Set to {@code true} if this property value
- * should be readable
- * @param writable Set to {@code true} if this property value
- * should be writable
+ * @param name Name of the new dynamic property
+ * @param type Data type of the new dynamic property (null for no restrictions)
+ * @param readable Set to {@code true} if this property value should be readable
+ * @param writable Set to {@code true} if this property value should be writable
*
* @throws IllegalArgumentException if name is null
- * @throws IllegalStateException if this DynaClass is currently
- * restricted, so no new properties can be added
+ * @throws IllegalStateException if this DynaClass is currently restricted, so no new properties can be added
*/
- void add(String name, Class<?> type, boolean readable,
- boolean writable);
+ void add(String name, Class<?> type, boolean readable, boolean writable);
/**
- * Is this DynaClass currently restricted, if so, no changes to the
- * existing registration of property names, data types, readability, or
- * writeability are allowed.
+ * Is this DynaClass currently restricted, if so, no changes to the existing registration of property names, data types, readability, or writeability are
+ * allowed.
*
- * @return {@code true} if this Mutable {@link DynaClass} is restricted,
- * otherwise {@code false}
+ * @return {@code true} if this Mutable {@link DynaClass} is restricted, otherwise {@code false}
*/
boolean isRestricted();
/**
- * Remove the specified dynamic property, and any associated data type,
- * readability, and writeability, from this dynamic class.
- * <strong>NOTE</strong> - This does <strong>NOT</strong> cause any
- * corresponding property values to be removed from DynaBean instances
- * associated with this DynaClass.
+ * Remove the specified dynamic property, and any associated data type, readability, and writeability, from this dynamic class. <strong>NOTE</strong> - This
+ * does <strong>NOT</strong> cause any corresponding property values to be removed from DynaBean instances associated with this DynaClass.
*
* @param name Name of the dynamic property to remove
*
* @throws IllegalArgumentException if name is null
- * @throws IllegalStateException if this DynaClass is currently
- * restricted, so no properties can be removed
+ * @throws IllegalStateException if this DynaClass is currently restricted, so no properties can be removed
*/
void remove(String name);
diff --git a/src/main/java/org/apache/commons/beanutils2/NestedNullException.java b/src/main/java/org/apache/commons/beanutils2/NestedNullException.java
index 92a2c31c..c6bd5b86 100644
--- a/src/main/java/org/apache/commons/beanutils2/NestedNullException.java
+++ b/src/main/java/org/apache/commons/beanutils2/NestedNullException.java
@@ -18,8 +18,7 @@
package org.apache.commons.beanutils2;
/**
- * Thrown to indicate that the <em>Bean Access Language</em> cannot execute query
- * against given bean since a nested bean referenced is null.
+ * Thrown to indicate that the <em>Bean Access Language</em> cannot execute query against given bean since a nested bean referenced is null.
*
* @since 1.7
*/
diff --git a/src/main/java/org/apache/commons/beanutils2/PropertyUtils.java b/src/main/java/org/apache/commons/beanutils2/PropertyUtils.java
index f29562a0..cc474d41 100644
--- a/src/main/java/org/apache/commons/beanutils2/PropertyUtils.java
+++ b/src/main/java/org/apache/commons/beanutils2/PropertyUtils.java
@@ -23,11 +23,13 @@ import java.lang.reflect.Method;
import java.util.Map;
/**
- * <p>Utility methods for using Java Reflection APIs to facilitate generic
- * property getter and setter operations on Java objects.</p>
+ * <p>
+ * Utility methods for using Java Reflection APIs to facilitate generic property getter and setter operations on Java objects.
+ * </p>
*
- * <p>The implementations for these methods are provided by {@code PropertyUtilsBean}.
- * For more details see {@link PropertyUtilsBean}.</p>
+ * <p>
+ * The implementations for these methods are provided by {@code PropertyUtilsBean}. For more details see {@link PropertyUtilsBean}.
+ * </p>
*
* @see PropertyUtilsBean
* @see org.apache.commons.beanutils2.expression.Resolver
@@ -36,11 +38,9 @@ import java.util.Map;
public class PropertyUtils {
/**
- * Adds a {@code BeanIntrospector}. This object is invoked when the
- * property descriptors of a class need to be obtained.
+ * Adds a {@code BeanIntrospector}. This object is invoked when the property descriptors of a class need to be obtained.
*
- * @param introspector the {@code BeanIntrospector} to be added (must
- * not be <b>null</b>
+ * @param introspector the {@code BeanIntrospector} to be added (must not be <b>null</b>
* @throws IllegalArgumentException if the argument is <b>null</b>
* @since 1.9
*/
@@ -49,11 +49,12 @@ public class PropertyUtils {
}
/**
- * Clear any cached property descriptors information for all classes
- * loaded by any class loaders. This is useful in cases where class
- * loaders are thrown away to implement class reloading.
+ * Clear any cached property descriptors information for all classes loaded by any class loaders. This is useful in cases where class loaders are thrown
+ * away to implement class reloading.
*
- * <p>For more details see {@code PropertyUtilsBean}.</p>
+ * <p>
+ * For more details see {@code PropertyUtilsBean}.
+ * </p>
*
* @see PropertyUtilsBean#clearDescriptors
*/
@@ -62,170 +63,156 @@ public class PropertyUtils {
}
/**
- * <p>Copy property values from the "origin" bean to the "destination" bean
- * for all cases where the property names are the same (even though the
- * actual getter and setter methods might have been customized via
- * {@code BeanInfo} classes).</p>
+ * <p>
+ * Copy property values from the "origin" bean to the "destination" bean for all cases where the property names are the same (even though the actual getter
+ * and setter methods might have been customized via {@code BeanInfo} classes).
+ * </p>
*
- * <p>For more details see {@code PropertyUtilsBean}.</p>
+ * <p>
+ * For more details see {@code PropertyUtilsBean}.
+ * </p>
*
* @param dest Destination bean whose properties are modified
* @param orig Origin bean whose properties are retrieved
*
- * @throws IllegalAccessException if the caller does not have
- * access to the property accessor method
- * @throws IllegalArgumentException if the {@code dest} or
- * {@code orig} argument is null
- * @throws InvocationTargetException if the property accessor method
- * throws an exception
- * @throws NoSuchMethodException if an accessor method for this
- * property cannot be found
+ * @throws IllegalAccessException if the caller does not have access to the property accessor method
+ * @throws IllegalArgumentException if the {@code dest} or {@code orig} argument is null
+ * @throws InvocationTargetException if the property accessor method throws an exception
+ * @throws NoSuchMethodException if an accessor method for this property cannot be found
* @see PropertyUtilsBean#copyProperties
*/
- public static void copyProperties(final Object dest, final Object orig)
- throws IllegalAccessException, InvocationTargetException,
- NoSuchMethodException {
+ public static void copyProperties(final Object dest, final Object orig) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
PropertyUtilsBean.getInstance().copyProperties(dest, orig);
}
/**
- * <p>Return the entire set of properties for which the specified bean
- * provides a read method.</p>
+ * <p>
+ * Return the entire set of properties for which the specified bean provides a read method.
+ * </p>
*
- * <p>For more details see {@code PropertyUtilsBean}.</p>
+ * <p>
+ * For more details see {@code PropertyUtilsBean}.
+ * </p>
*
* @param bean Bean whose properties are to be extracted
* @return The set of properties for the bean
... 12252 lines suppressed ...