Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanPropertyValueEqualsPredicate.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanPropertyValueEqualsPredicate.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanPropertyValueEqualsPredicate.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanPropertyValueEqualsPredicate.java Wed Oct 15 20:15:17 2014 @@ -147,7 +147,7 @@ public class BeanPropertyValueEqualsPred * @param propertyValue The value to use in object evaluation. * @throws IllegalArgumentException If the property name provided is null or empty. */ - public BeanPropertyValueEqualsPredicate(String propertyName, Object propertyValue) { + public BeanPropertyValueEqualsPredicate(final String propertyName, final Object propertyValue) { this(propertyName, propertyValue, false); } @@ -162,7 +162,7 @@ public class BeanPropertyValueEqualsPred * genenerate an <code>IllegalArgumentException</code> or not. * @throws IllegalArgumentException If the property name provided is null or empty. */ - public BeanPropertyValueEqualsPredicate(String propertyName, Object propertyValue, boolean ignoreNull) { + public BeanPropertyValueEqualsPredicate(final String propertyName, final Object propertyValue, final boolean ignoreNull) { super(); if ((propertyName != null) && (propertyName.length() > 0)) { @@ -192,42 +192,42 @@ public class BeanPropertyValueEqualsPred * provided. Or if an object in the property path provided is <code>null</code> and * <code>ignoreNull</code> is set to <code>false</code>. */ - public boolean evaluate(Object object) { + public boolean evaluate(final Object object) { boolean evaluation = false; try { evaluation = evaluateValue(propertyValue, PropertyUtils.getProperty(object, propertyName)); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { final String errorMsg = "Problem during evaluation. Null value encountered in property path..."; if (ignoreNull) { log.warn("WARNING: " + errorMsg + e); } else { - IllegalArgumentException iae = new IllegalArgumentException(errorMsg); + final IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } throw iae; } - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { final String errorMsg = "Unable to access the property provided."; - IllegalArgumentException iae = new IllegalArgumentException(errorMsg); + final IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } throw iae; - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { final String errorMsg = "Exception occurred in property's getter"; - IllegalArgumentException iae = new IllegalArgumentException(errorMsg); + final IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } throw iae; - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { final String errorMsg = "Property not found."; - IllegalArgumentException iae = new IllegalArgumentException(errorMsg); + final IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } @@ -245,7 +245,7 @@ public class BeanPropertyValueEqualsPred * @param actual The actual value. * @return True if they are equal; false otherwise. */ - protected boolean evaluateValue(Object expected, Object actual) { + protected boolean evaluateValue(final Object expected, final Object actual) { return (expected == actual) || ((expected != null) && expected.equals(actual)); }
Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanToPropertyValueTransformer.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanToPropertyValueTransformer.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanToPropertyValueTransformer.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanToPropertyValueTransformer.java Wed Oct 15 20:15:17 2014 @@ -101,7 +101,7 @@ public class BeanToPropertyValueTransfor * @throws IllegalArgumentException If the <code>propertyName</code> is <code>null</code> or * empty. */ - public BeanToPropertyValueTransformer(String propertyName) { + public BeanToPropertyValueTransformer(final String propertyName) { this(propertyName, false); } @@ -117,7 +117,7 @@ public class BeanToPropertyValueTransfor * @throws IllegalArgumentException If the <code>propertyName</code> is <code>null</code> or * empty. */ - public BeanToPropertyValueTransformer(String propertyName, boolean ignoreNull) { + public BeanToPropertyValueTransformer(final String propertyName, final boolean ignoreNull) { super(); if ((propertyName != null) && (propertyName.length() > 0)) { @@ -145,42 +145,42 @@ public class BeanToPropertyValueTransfor * provided. Or if an object in the property path provided is <code>null</code> and * <code>ignoreNull</code> is set to <code>false</code>. */ - public Object transform(Object object) { + public Object transform(final Object object) { Object propertyValue = null; try { propertyValue = PropertyUtils.getProperty(object, propertyName); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { final String errorMsg = "Problem during transformation. Null value encountered in property path..."; if (ignoreNull) { log.warn("WARNING: " + errorMsg + e); } else { - IllegalArgumentException iae = new IllegalArgumentException(errorMsg); + final IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } throw iae; } - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { final String errorMsg = "Unable to access the property provided."; - IllegalArgumentException iae = new IllegalArgumentException(errorMsg); + final IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } throw iae; - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { final String errorMsg = "Exception occurred in property's getter"; - IllegalArgumentException iae = new IllegalArgumentException(errorMsg); + final IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } throw iae; - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { final String errorMsg = "No property found for name [" + propertyName + "]"; - IllegalArgumentException iae = new IllegalArgumentException(errorMsg); + final IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtils.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtils.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtils.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtils.java Wed Oct 15 20:15:17 2014 @@ -75,7 +75,7 @@ public class BeanUtils { * this class. */ @Deprecated - public static void setDebug(int newDebug) { + public static void setDebug(final int newDebug) { debug = newDebug; } @@ -101,7 +101,7 @@ public class BeanUtils { * property cannot be found * @see BeanUtilsBean#cloneBean */ - public static Object cloneBean(Object bean) + public static Object cloneBean(final Object bean) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException { @@ -129,7 +129,7 @@ public class BeanUtils { * throws an exception * @see BeanUtilsBean#copyProperties */ - public static void copyProperties(Object dest, Object orig) + public static void copyProperties(final Object dest, final Object orig) throws IllegalAccessException, InvocationTargetException { BeanUtilsBean.getInstance().copyProperties(dest, orig); @@ -152,7 +152,7 @@ public class BeanUtils { * throws an exception * @see BeanUtilsBean#copyProperty */ - public static void copyProperty(Object bean, String name, Object value) + public static void copyProperty(final Object bean, final String name, final Object value) throws IllegalAccessException, InvocationTargetException { BeanUtilsBean.getInstance().copyProperty(bean, name, value); @@ -176,7 +176,7 @@ public class BeanUtils { * property cannot be found * @see BeanUtilsBean#describe */ - public static Map<String, String> describe(Object bean) + public static Map<String, String> describe(final Object bean) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -202,7 +202,7 @@ public class BeanUtils { * property cannot be found * @see BeanUtilsBean#getArrayProperty */ - public static String[] getArrayProperty(Object bean, String name) + public static String[] getArrayProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -229,7 +229,7 @@ public class BeanUtils { * property cannot be found * @see BeanUtilsBean#getIndexedProperty(Object, String) */ - public static String getIndexedProperty(Object bean, String name) + public static String getIndexedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -258,8 +258,8 @@ public class BeanUtils { * property cannot be found * @see BeanUtilsBean#getIndexedProperty(Object, String, int) */ - public static String getIndexedProperty(Object bean, - String name, int index) + public static String getIndexedProperty(final Object bean, + final String name, final int index) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -287,7 +287,7 @@ public class BeanUtils { * property cannot be found * @see BeanUtilsBean#getMappedProperty(Object, String) */ - public static String getMappedProperty(Object bean, String name) + public static String getMappedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -315,8 +315,8 @@ public class BeanUtils { * property cannot be found * @see BeanUtilsBean#getMappedProperty(Object, String, String) */ - public static String getMappedProperty(Object bean, - String name, String key) + public static String getMappedProperty(final Object bean, + final String name, final String key) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -345,7 +345,7 @@ public class BeanUtils { * property cannot be found * @see BeanUtilsBean#getNestedProperty */ - public static String getNestedProperty(Object bean, String name) + public static String getNestedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -373,7 +373,7 @@ public class BeanUtils { * property cannot be found * @see BeanUtilsBean#getProperty */ - public static String getProperty(Object bean, String name) + public static String getProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -400,7 +400,7 @@ public class BeanUtils { * property cannot be found * @see BeanUtilsBean#getSimpleProperty */ - public static String getSimpleProperty(Object bean, String name) + public static String getSimpleProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -425,7 +425,7 @@ public class BeanUtils { * throws an exception * @see BeanUtilsBean#populate */ - public static void populate(Object bean, Map<String, ? extends Object> properties) + public static void populate(final Object bean, final Map<String, ? extends Object> properties) throws IllegalAccessException, InvocationTargetException { BeanUtilsBean.getInstance().populate(bean, properties); @@ -448,7 +448,7 @@ public class BeanUtils { * throws an exception * @see BeanUtilsBean#setProperty */ - public static void setProperty(Object bean, String name, Object value) + public static void setProperty(final Object bean, final String name, final Object value) throws IllegalAccessException, InvocationTargetException { BeanUtilsBean.getInstance().setProperty(bean, name, value); @@ -462,7 +462,7 @@ public class BeanUtils { * @return true if the cause was initialized, otherwise false. * @since 1.8.0 */ - public static boolean initCause(Throwable throwable, Throwable cause) { + public static boolean initCause(final Throwable throwable, final Throwable cause) { return BeanUtilsBean.getInstance().initCause(throwable, cause); } @@ -483,7 +483,7 @@ public class BeanUtils { * @return Whether it is fast or not. * @since 1.8.0 */ - public static boolean getCacheFast(Map<?, ?> map) { + public static boolean getCacheFast(final Map<?, ?> map) { if (map instanceof WeakFastHashMap) { return ((WeakFastHashMap<?, ?>) map).getFast(); } else { @@ -497,7 +497,7 @@ public class BeanUtils { * @param fast Whether it should be fast or not. * @since 1.8.0 */ - public static void setCacheFast(Map<?, ?> map, boolean fast) { + public static void setCacheFast(final Map<?, ?> map, final boolean fast) { if (map instanceof WeakFastHashMap) { ((WeakFastHashMap<?, ?>)map).setFast(fast); } Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java Wed Oct 15 20:15:17 2014 @@ -83,7 +83,7 @@ public class BeanUtilsBean { * * @param newInstance The (pseudo-singleton) BeanUtils bean instance */ - public static void setInstance(BeanUtilsBean newInstance) { + public static void setInstance(final BeanUtilsBean newInstance) { BEANS_BY_CLASSLOADER.set(newInstance); } @@ -122,7 +122,7 @@ public class BeanUtilsBean { * * @since 1.8.0 */ - public BeanUtilsBean(ConvertUtilsBean convertUtilsBean) { + public BeanUtilsBean(final ConvertUtilsBean convertUtilsBean) { this(convertUtilsBean, new PropertyUtilsBean()); } @@ -135,8 +135,8 @@ public class BeanUtilsBean { * to access properties */ public BeanUtilsBean( - ConvertUtilsBean convertUtilsBean, - PropertyUtilsBean propertyUtilsBean) { + final ConvertUtilsBean convertUtilsBean, + final PropertyUtilsBean propertyUtilsBean) { this.convertUtilsBean = convertUtilsBean; this.propertyUtilsBean = propertyUtilsBean; @@ -166,7 +166,7 @@ public class BeanUtilsBean { * @exception NoSuchMethodException if an accessor method for this * property cannot be found */ - public Object cloneBean(Object bean) + public Object cloneBean(final Object bean) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException { @@ -227,7 +227,7 @@ public class BeanUtilsBean { * @exception InvocationTargetException if the property accessor method * throws an exception */ - public void copyProperties(Object dest, Object orig) + public void copyProperties(final Object dest, final Object orig) throws IllegalAccessException, InvocationTargetException { // Validate existence of the specified beans @@ -245,43 +245,44 @@ public class BeanUtilsBean { // Copy the properties, converting as necessary if (orig instanceof DynaBean) { - DynaProperty[] origDescriptors = + final DynaProperty[] origDescriptors = ((DynaBean) orig).getDynaClass().getDynaProperties(); for (int i = 0; i < origDescriptors.length; i++) { - String name = origDescriptors[i].getName(); + final String name = origDescriptors[i].getName(); // Need to check isReadable() for WrapDynaBean // (see Jira issue# BEANUTILS-61) if (getPropertyUtils().isReadable(orig, name) && getPropertyUtils().isWriteable(dest, name)) { - Object value = ((DynaBean) orig).get(name); + final Object value = ((DynaBean) orig).get(name); copyProperty(dest, name, value); } } } else if (orig instanceof Map) { @SuppressWarnings("unchecked") + final // Map properties are always of type <String, Object> Map<String, Object> propMap = (Map<String, Object>) orig; - for (Map.Entry<String, Object> entry : propMap.entrySet()) { - String name = entry.getKey(); + for (final Map.Entry<String, Object> entry : propMap.entrySet()) { + final String name = entry.getKey(); if (getPropertyUtils().isWriteable(dest, name)) { copyProperty(dest, name, entry.getValue()); } } } else /* if (orig is a standard JavaBean) */ { - PropertyDescriptor[] origDescriptors = + final PropertyDescriptor[] origDescriptors = getPropertyUtils().getPropertyDescriptors(orig); for (int i = 0; i < origDescriptors.length; i++) { - String name = origDescriptors[i].getName(); + final String name = origDescriptors[i].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)) { try { - Object value = + final Object value = getPropertyUtils().getSimpleProperty(orig, name); copyProperty(dest, name, value); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { // Should not happen } } @@ -322,12 +323,12 @@ public class BeanUtilsBean { * @exception InvocationTargetException if the property accessor method * throws an exception */ - public void copyProperty(Object bean, String name, Object value) + public void copyProperty(final Object bean, String name, Object value) throws IllegalAccessException, InvocationTargetException { // Trace logging (if enabled) if (log.isTraceEnabled()) { - StringBuilder sb = new StringBuilder(" copyProperty("); + final StringBuilder sb = new StringBuilder(" copyProperty("); sb.append(bean); sb.append(", "); sb.append(name); @@ -337,7 +338,7 @@ public class BeanUtilsBean { } else if (value instanceof String) { sb.append((String) value); } else if (value instanceof String[]) { - String[] values = (String[]) value; + final String[] values = (String[]) value; sb.append('['); for (int i = 0; i < values.length; i++) { if (i > 0) { @@ -355,12 +356,12 @@ public class BeanUtilsBean { // Resolve any nested expression to get the actual target bean Object target = bean; - Resolver resolver = getPropertyUtils().getResolver(); + final Resolver resolver = getPropertyUtils().getResolver(); while (resolver.hasNested(name)) { try { target = getPropertyUtils().getProperty(target, resolver.next(name)); name = resolver.remove(name); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { return; // Skip this property setter } } @@ -370,15 +371,15 @@ public class BeanUtilsBean { } // Declare local variables we will require - String propName = resolver.getProperty(name); // Simple name of target property + final String propName = resolver.getProperty(name); // Simple name of target property Class<?> type = null; // Java type of target property - int index = resolver.getIndex(name); // Indexed subscript value (if any) - String key = resolver.getKey(name); // Mapped key value (if any) + 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) { - DynaClass dynaClass = ((DynaBean) target).getDynaClass(); - DynaProperty dynaProperty = dynaClass.getDynaProperty(propName); + final DynaClass dynaClass = ((DynaBean) target).getDynaClass(); + final DynaProperty dynaProperty = dynaClass.getDynaProperty(propName); if (dynaProperty == null) { return; // Skip this property setter } @@ -391,7 +392,7 @@ public class BeanUtilsBean { if (descriptor == null) { return; // Skip this property setter } - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { return; // Skip this property setter } type = descriptor.getPropertyType(); @@ -415,7 +416,7 @@ public class BeanUtilsBean { try { getPropertyUtils().setIndexedProperty(target, propName, index, value); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { throw new InvocationTargetException (e, "Cannot set " + propName); } @@ -426,7 +427,7 @@ public class BeanUtilsBean { try { getPropertyUtils().setMappedProperty(target, propName, key, value); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { throw new InvocationTargetException (e, "Cannot set " + propName); } @@ -434,7 +435,7 @@ public class BeanUtilsBean { value = convertForCopy(value, type); try { getPropertyUtils().setSimpleProperty(target, propName, value); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { throw new InvocationTargetException (e, "Cannot set " + propName); } @@ -480,7 +481,7 @@ public class BeanUtilsBean { * @exception NoSuchMethodException if an accessor method for this * property cannot be found */ - public Map<String, String> describe(Object bean) + public Map<String, String> describe(final Object bean) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -493,20 +494,20 @@ public class BeanUtilsBean { log.debug("Describing bean: " + bean.getClass().getName()); } - Map<String, String> description = new HashMap<String, String>(); + final Map<String, String> description = new HashMap<String, String>(); if (bean instanceof DynaBean) { - DynaProperty[] descriptors = + final DynaProperty[] descriptors = ((DynaBean) bean).getDynaClass().getDynaProperties(); for (int i = 0; i < descriptors.length; i++) { - String name = descriptors[i].getName(); + final String name = descriptors[i].getName(); description.put(name, getProperty(bean, name)); } } else { - PropertyDescriptor[] descriptors = + final PropertyDescriptor[] descriptors = getPropertyUtils().getPropertyDescriptors(bean); - Class<?> clazz = bean.getClass(); + final Class<?> clazz = bean.getClass(); for (int i = 0; i < descriptors.length; i++) { - String name = descriptors[i].getName(); + final String name = descriptors[i].getName(); if (getPropertyUtils().getReadMethod(clazz, descriptors[i]) != null) { description.put(name, getProperty(bean, name)); } @@ -532,16 +533,16 @@ public class BeanUtilsBean { * @exception NoSuchMethodException if an accessor method for this * property cannot be found */ - public String[] getArrayProperty(Object bean, String name) + public String[] getArrayProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { - Object value = getPropertyUtils().getProperty(bean, name); + final Object value = getPropertyUtils().getProperty(bean, name); if (value == null) { return (null); } else if (value instanceof Collection) { - ArrayList<String> values = new ArrayList<String>(); - for (Object item : (Collection<?>) value) { + final ArrayList<String> values = new ArrayList<String>(); + for (final Object item : (Collection<?>) value) { if (item == null) { values.add(null); } else { @@ -551,10 +552,10 @@ public class BeanUtilsBean { } return (values.toArray(new String[values.size()])); } else if (value.getClass().isArray()) { - int n = Array.getLength(value); - String[] results = new String[n]; + final int n = Array.getLength(value); + final String[] results = new String[n]; for (int i = 0; i < n; i++) { - Object item = Array.get(value, i); + final Object item = Array.get(value, i); if (item == null) { results[i] = null; } else { @@ -564,7 +565,7 @@ public class BeanUtilsBean { } return (results); } else { - String[] results = new String[1]; + final String[] results = new String[1]; results[0] = getConvertUtils().convert(value); return (results); } @@ -591,11 +592,11 @@ public class BeanUtilsBean { * @exception NoSuchMethodException if an accessor method for this * property cannot be found */ - public String getIndexedProperty(Object bean, String name) + public String getIndexedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { - Object value = getPropertyUtils().getIndexedProperty(bean, name); + final Object value = getPropertyUtils().getIndexedProperty(bean, name); return (getConvertUtils().convert(value)); } @@ -618,12 +619,12 @@ public class BeanUtilsBean { * @exception NoSuchMethodException if an accessor method for this * property cannot be found */ - public String getIndexedProperty(Object bean, - String name, int index) + public String getIndexedProperty(final Object bean, + final String name, final int index) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { - Object value = getPropertyUtils().getIndexedProperty(bean, name, index); + final Object value = getPropertyUtils().getIndexedProperty(bean, name, index); return (getConvertUtils().convert(value)); } @@ -648,11 +649,11 @@ public class BeanUtilsBean { * @exception NoSuchMethodException if an accessor method for this * property cannot be found */ - public String getMappedProperty(Object bean, String name) + public String getMappedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { - Object value = getPropertyUtils().getMappedProperty(bean, name); + final Object value = getPropertyUtils().getMappedProperty(bean, name); return (getConvertUtils().convert(value)); } @@ -675,12 +676,12 @@ public class BeanUtilsBean { * @exception NoSuchMethodException if an accessor method for this * property cannot be found */ - public String getMappedProperty(Object bean, - String name, String key) + public String getMappedProperty(final Object bean, + final String name, final String key) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { - Object value = getPropertyUtils().getMappedProperty(bean, name, key); + final Object value = getPropertyUtils().getMappedProperty(bean, name, key); return (getConvertUtils().convert(value)); } @@ -703,11 +704,11 @@ public class BeanUtilsBean { * @exception NoSuchMethodException if an accessor method for this * property cannot be found */ - public String getNestedProperty(Object bean, String name) + public String getNestedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { - Object value = getPropertyUtils().getNestedProperty(bean, name); + final Object value = getPropertyUtils().getNestedProperty(bean, name); return (getConvertUtils().convert(value)); } @@ -729,7 +730,7 @@ public class BeanUtilsBean { * @exception NoSuchMethodException if an accessor method for this * property cannot be found */ - public String getProperty(Object bean, String name) + public String getProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -753,11 +754,11 @@ public class BeanUtilsBean { * @exception NoSuchMethodException if an accessor method for this * property cannot be found */ - public String getSimpleProperty(Object bean, String name) + public String getSimpleProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { - Object value = getPropertyUtils().getSimpleProperty(bean, name); + final Object value = getPropertyUtils().getSimpleProperty(bean, name); return (getConvertUtils().convert(value)); } @@ -798,7 +799,7 @@ public class BeanUtilsBean { * @exception InvocationTargetException if the property accessor method * throws an exception */ - public void populate(Object bean, Map<String, ? extends Object> properties) + public void populate(final Object bean, final Map<String, ? extends Object> properties) throws IllegalAccessException, InvocationTargetException { // Do nothing unless both arguments have been specified @@ -811,9 +812,9 @@ public class BeanUtilsBean { } // Loop through the property name/value pairs to be set - for(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 - String name = entry.getKey(); + final String name = entry.getKey(); if (name == null) { continue; } @@ -856,12 +857,12 @@ public class BeanUtilsBean { * @exception InvocationTargetException if the property accessor method * throws an exception */ - public void setProperty(Object bean, String name, Object value) + public void setProperty(final Object bean, String name, final Object value) throws IllegalAccessException, InvocationTargetException { // Trace logging (if enabled) if (log.isTraceEnabled()) { - StringBuilder sb = new StringBuilder(" setProperty("); + final StringBuilder sb = new StringBuilder(" setProperty("); sb.append(bean); sb.append(", "); sb.append(name); @@ -871,7 +872,7 @@ public class BeanUtilsBean { } else if (value instanceof String) { sb.append((String) value); } else if (value instanceof String[]) { - String[] values = (String[]) value; + final String[] values = (String[]) value; sb.append('['); for (int i = 0; i < values.length; i++) { if (i > 0) { @@ -889,7 +890,7 @@ public class BeanUtilsBean { // Resolve any nested expression to get the actual target bean Object target = bean; - Resolver resolver = getPropertyUtils().getResolver(); + final Resolver resolver = getPropertyUtils().getResolver(); while (resolver.hasNested(name)) { try { target = getPropertyUtils().getProperty(target, resolver.next(name)); @@ -897,7 +898,7 @@ public class BeanUtilsBean { return; } name = resolver.remove(name); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { return; // Skip this property setter } } @@ -907,15 +908,15 @@ public class BeanUtilsBean { } // Declare local variables we will require - String propName = resolver.getProperty(name); // Simple name of target property + final String propName = resolver.getProperty(name); // Simple name of target property Class<?> type = null; // Java type of target property - int index = resolver.getIndex(name); // Indexed subscript value (if any) - String key = resolver.getKey(name); // Mapped key value (if any) + 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) { - DynaClass dynaClass = ((DynaBean) target).getDynaClass(); - DynaProperty dynaProperty = dynaClass.getDynaProperty(propName); + final DynaClass dynaClass = ((DynaBean) target).getDynaClass(); + final DynaProperty dynaProperty = dynaClass.getDynaProperty(propName); if (dynaProperty == null) { return; // Skip this property setter } @@ -932,7 +933,7 @@ public class BeanUtilsBean { if (descriptor == null) { return; // Skip this property setter } - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { return; // Skip this property setter } if (descriptor instanceof MappedPropertyDescriptor) { @@ -978,7 +979,7 @@ public class BeanUtilsBean { Object newValue = null; if (type.isArray() && (index < 0)) { // Scalar value into array if (value == null) { - String[] values = new String[1]; + final String[] values = new String[1]; values[0] = null; newValue = getConvertUtils().convert(values, type); } else if (value instanceof String) { @@ -1012,7 +1013,7 @@ public class BeanUtilsBean { // Invoke the setter method try { getPropertyUtils().setProperty(target, name, newValue); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { throw new InvocationTargetException (e, "Cannot set " + propName); } @@ -1045,12 +1046,12 @@ public class BeanUtilsBean { * @return true if the cause was initialized, otherwise false. * @since 1.8.0 */ - public boolean initCause(Throwable throwable, Throwable cause) { + public boolean initCause(final Throwable throwable, final Throwable cause) { if (INIT_CAUSE_METHOD != null && cause != null) { try { INIT_CAUSE_METHOD.invoke(throwable, new Object[] { cause }); return true; - } catch (Throwable e) { + } catch (final Throwable e) { return false; // can't initialize cause } } @@ -1068,8 +1069,8 @@ public class BeanUtilsBean { * @exception ConversionException if thrown by an underlying Converter * @since 1.8.0 */ - protected Object convert(Object value, Class<?> type) { - Converter converter = getConvertUtils().lookup(type); + protected Object convert(final Object value, final Class<?> type) { + final Converter converter = getConvertUtils().lookup(type); if (converter != null) { log.trace(" USING CONVERTER " + converter); return converter.convert(type, value); @@ -1087,7 +1088,7 @@ public class BeanUtilsBean { * @param type the target type of the conversion * @return the converted value */ - private Object convertForCopy(Object value, Class<?> type) { + private Object convertForCopy(final Object value, final Class<?> type) { return (value != null) ? convert(value, type) : value; } @@ -1102,16 +1103,16 @@ public class BeanUtilsBean { */ private static Method getInitCauseMethod() { try { - Class<?>[] paramsClasses = new Class<?>[] { Throwable.class }; + final Class<?>[] paramsClasses = new Class<?>[] { Throwable.class }; return Throwable.class.getMethod("initCause", paramsClasses); - } catch (NoSuchMethodException e) { - Log log = LogFactory.getLog(BeanUtils.class); + } catch (final NoSuchMethodException e) { + final Log log = LogFactory.getLog(BeanUtils.class); if (log.isWarnEnabled()) { log.warn("Throwable does not have initCause() method in JDK 1.3"); } return null; - } catch (Throwable e) { - Log log = LogFactory.getLog(BeanUtils.class); + } catch (final Throwable e) { + final Log log = LogFactory.getLog(BeanUtils.class); if (log.isWarnEnabled()) { log.warn("Error getting the Throwable initCause() method", e); } @@ -1127,8 +1128,8 @@ public class BeanUtilsBean { * @param value the value object to be set for this property * @return the type of this property */ - private static Class<?> dynaPropertyType(DynaProperty dynaProperty, - Object value) { + private static Class<?> dynaPropertyType(final DynaProperty dynaProperty, + final Object value) { if (!dynaProperty.isMapped()) { return dynaProperty.getType(); } Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean2.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean2.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean2.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean2.java Wed Oct 15 20:15:17 2014 @@ -70,7 +70,7 @@ public class BeanUtilsBean2 extends Bean * @return The converted value */ @Override - protected Object convert(Object value, Class<?> type) { + protected Object convert(final Object value, final Class<?> type) { return getConvertUtils().convert(value, type); } } Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java Wed Oct 15 20:15:17 2014 @@ -67,14 +67,14 @@ public class ConstructorUtils { * * @see #invokeConstructor(java.lang.Class, java.lang.Object[], java.lang.Class[]) */ - public static <T> T invokeConstructor(Class<T> klass, Object arg) + public static <T> T invokeConstructor(final Class<T> klass, final Object arg) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { - Object[] args = toArray(arg); + final Object[] args = toArray(arg); return invokeConstructor(klass, args); } @@ -97,7 +97,7 @@ public class ConstructorUtils { * * @see #invokeConstructor(java.lang.Class, java.lang.Object[], java.lang.Class[]) */ - public static <T> T invokeConstructor(Class<T> klass, Object[] args) + public static <T> T invokeConstructor(final Class<T> klass, Object[] args) throws NoSuchMethodException, IllegalAccessException, @@ -107,8 +107,8 @@ public class ConstructorUtils { if (null == args) { args = EMPTY_OBJECT_ARRAY; } - int arguments = args.length; - Class<?> parameterTypes[] = new Class<?>[arguments]; + final int arguments = args.length; + final Class<?> parameterTypes[] = new Class<?>[arguments]; for (int i = 0; i < arguments; i++) { parameterTypes[i] = args[i].getClass(); } @@ -134,7 +134,7 @@ public class ConstructorUtils { * @see Constructor#newInstance */ public static <T> T invokeConstructor( - Class<T> klass, + final Class<T> klass, Object[] args, Class<?>[] parameterTypes) throws @@ -150,7 +150,7 @@ public class ConstructorUtils { args = EMPTY_OBJECT_ARRAY; } - Constructor<T> ctor = + final Constructor<T> ctor = getMatchingAccessibleConstructor(klass, parameterTypes); if (null == ctor) { throw new NoSuchMethodException( @@ -179,14 +179,14 @@ public class ConstructorUtils { * * @see #invokeExactConstructor(java.lang.Class, java.lang.Object[], java.lang.Class[]) */ - public static <T> T invokeExactConstructor(Class<T> klass, Object arg) + public static <T> T invokeExactConstructor(final Class<T> klass, final Object arg) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { - Object[] args = toArray(arg); + final Object[] args = toArray(arg); return invokeExactConstructor(klass, args); } @@ -209,7 +209,7 @@ public class ConstructorUtils { * * @see #invokeExactConstructor(java.lang.Class, java.lang.Object[], java.lang.Class[]) */ - public static <T> T invokeExactConstructor(Class<T> klass, Object[] args) + public static <T> T invokeExactConstructor(final Class<T> klass, Object[] args) throws NoSuchMethodException, IllegalAccessException, @@ -219,8 +219,8 @@ public class ConstructorUtils { if (null == args) { args = EMPTY_OBJECT_ARRAY; } - int arguments = args.length; - Class<?> parameterTypes[] = new Class[arguments]; + final int arguments = args.length; + final Class<?> parameterTypes[] = new Class[arguments]; for (int i = 0; i < arguments; i++) { parameterTypes[i] = args[i].getClass(); } @@ -247,7 +247,7 @@ public class ConstructorUtils { * @see Constructor#newInstance */ public static <T> T invokeExactConstructor( - Class<T> klass, + final Class<T> klass, Object[] args, Class<?>[] parameterTypes) throws @@ -264,7 +264,7 @@ public class ConstructorUtils { parameterTypes = EMPTY_CLASS_PARAMETERS; } - Constructor<T> ctor = getAccessibleConstructor(klass, parameterTypes); + final Constructor<T> ctor = getAccessibleConstructor(klass, parameterTypes); if (null == ctor) { throw new NoSuchMethodException( "No such accessible constructor on object: " + klass.getName()); @@ -282,10 +282,10 @@ public class ConstructorUtils { * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static <T> Constructor<T> getAccessibleConstructor( - Class<T> klass, - Class<?> parameterType) { + final Class<T> klass, + final Class<?> parameterType) { - Class<?>[] parameterTypes = { parameterType }; + final Class<?>[] parameterTypes = { parameterType }; return getAccessibleConstructor(klass, parameterTypes); } @@ -299,13 +299,13 @@ public class ConstructorUtils { * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static <T> Constructor<T> getAccessibleConstructor( - Class<T> klass, - Class<?>[] parameterTypes) { + final Class<T> klass, + final Class<?>[] parameterTypes) { try { return getAccessibleConstructor( klass.getConstructor(parameterTypes)); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { return (null); } } @@ -317,7 +317,7 @@ public class ConstructorUtils { * @return <code>null</code> if accessible constructor can not be found. * @see java.lang.SecurityManager */ - public static <T> Constructor<T> getAccessibleConstructor(Constructor<T> ctor) { + public static <T> Constructor<T> getAccessibleConstructor(final Constructor<T> ctor) { // Make sure we have a method to check if (ctor == null) { @@ -330,7 +330,7 @@ public class ConstructorUtils { } // If the declaring class is public, we are done - Class<T> clazz = ctor.getDeclaringClass(); + final Class<T> clazz = ctor.getDeclaringClass(); if (Modifier.isPublic(clazz.getModifiers())) { return (ctor); } @@ -339,7 +339,7 @@ public class ConstructorUtils { return null; } - private static Object[] toArray(Object arg) { + private static Object[] toArray(final Object arg) { Object[] args = null; if (arg != null) { args = new Object[] { arg }; @@ -365,12 +365,12 @@ public class ConstructorUtils { * @return a valid Constructor object. If there's no matching constructor, returns <code>null</code>. */ private static <T> Constructor<T> getMatchingAccessibleConstructor( - Class<T> clazz, - Class<?>[] parameterTypes) { + 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 { - Constructor<T> ctor = clazz.getConstructor(parameterTypes); + final Constructor<T> ctor = clazz.getConstructor(parameterTypes); try { // // XXX Default access superclass workaround @@ -389,21 +389,21 @@ public class ConstructorUtils { // Better workarounds would be greatfully accepted. // ctor.setAccessible(true); - } catch (SecurityException se) { + } catch (final SecurityException se) { /* SWALLOW, if workaround fails don't fret. */ } return ctor; - } catch (NoSuchMethodException e) { /* SWALLOW */ + } catch (final NoSuchMethodException e) { /* SWALLOW */ } // search through all methods - int paramSize = parameterTypes.length; - Constructor<?>[] ctors = clazz.getConstructors(); + final int paramSize = parameterTypes.length; + final Constructor<?>[] ctors = clazz.getConstructors(); for (int i = 0, size = ctors.length; i < size; i++) { // compare parameters - Class<?>[] ctorParams = ctors[i].getParameterTypes(); - int ctorParamSize = ctorParams.length; + final Class<?>[] ctorParams = ctors[i].getParameterTypes(); + final int ctorParamSize = ctorParams.length; if (ctorParamSize == paramSize) { boolean match = true; for (int n = 0; n < ctorParamSize; n++) { @@ -418,16 +418,17 @@ public class ConstructorUtils { if (match) { // get accessible version of method - Constructor<?> ctor = getAccessibleConstructor(ctors[i]); + final Constructor<?> ctor = getAccessibleConstructor(ctors[i]); if (ctor != null) { try { ctor.setAccessible(true); - } catch (SecurityException se) { + } catch (final SecurityException se) { /* Swallow SecurityException * TODO: Why? */ } @SuppressWarnings("unchecked") + final // Class.getConstructors() actually returns constructors // of type T, so it is safe to cast. Constructor<T> typedCtor = (Constructor<T>) ctor; Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ContextClassLoaderLocal.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ContextClassLoaderLocal.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ContextClassLoaderLocal.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ContextClassLoaderLocal.java Wed Oct 15 20:15:17 2014 @@ -145,7 +145,7 @@ public class ContextClassLoaderLocal<T> valueByClassLoader.isEmpty(); try { - ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); if (contextClassLoader != null) { T value = valueByClassLoader.get(contextClassLoader); @@ -158,7 +158,7 @@ public class ContextClassLoaderLocal<T> } - } catch (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) { @@ -174,7 +174,7 @@ public class ContextClassLoaderLocal<T> * * @param value the object to be associated with the entrant thread's context classloader */ - public synchronized void set(T value) { + public synchronized void set(final T value) { // synchronizing the whole method is a bit slower // but guarentees no subtle threading problems @@ -182,13 +182,13 @@ public class ContextClassLoaderLocal<T> valueByClassLoader.isEmpty(); try { - ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); if (contextClassLoader != null) { valueByClassLoader.put(contextClassLoader, value); return; } - } catch (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; @@ -201,17 +201,17 @@ public class ContextClassLoaderLocal<T> public synchronized void unset() { try { - ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); unset(contextClassLoader); - } catch (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 <i>unset</i> for */ - public synchronized void unset(ClassLoader classLoader) { + public synchronized void unset(final ClassLoader classLoader) { valueByClassLoader.remove(classLoader); } } \ No newline at end of file Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConversionException.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConversionException.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConversionException.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConversionException.java Wed Oct 15 20:15:17 2014 @@ -38,7 +38,7 @@ public class ConversionException extends * * @param message The message describing this exception */ - public ConversionException(String message) { + public ConversionException(final String message) { super(message); @@ -51,7 +51,7 @@ public class ConversionException extends * @param message The message describing this exception * @param cause The root cause of this exception */ - public ConversionException(String message, Throwable cause) { + public ConversionException(final String message, final Throwable cause) { super(message); this.cause = cause; @@ -64,7 +64,7 @@ public class ConversionException extends * * @param cause The root cause of this exception */ - public ConversionException(Throwable cause) { + public ConversionException(final Throwable cause) { super(cause.getMessage()); this.cause = cause; Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtils.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtils.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtils.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtils.java Wed Oct 15 20:15:17 2014 @@ -52,7 +52,7 @@ public class ConvertUtils { * Boolean.class instead */ @Deprecated - public static void setDefaultBoolean(boolean newDefaultBoolean) { + public static void setDefaultBoolean(final boolean newDefaultBoolean) { ConvertUtilsBean.getInstance().setDefaultBoolean(newDefaultBoolean); } @@ -75,7 +75,7 @@ public class ConvertUtils { * Byte.class instead */ @Deprecated - public static void setDefaultByte(byte newDefaultByte) { + public static void setDefaultByte(final byte newDefaultByte) { ConvertUtilsBean.getInstance().setDefaultByte(newDefaultByte); } @@ -98,7 +98,7 @@ public class ConvertUtils { * Character.class instead */ @Deprecated - public static void setDefaultCharacter(char newDefaultCharacter) { + public static void setDefaultCharacter(final char newDefaultCharacter) { ConvertUtilsBean.getInstance().setDefaultCharacter(newDefaultCharacter); } @@ -121,7 +121,7 @@ public class ConvertUtils { * Double.class instead */ @Deprecated - public static void setDefaultDouble(double newDefaultDouble) { + public static void setDefaultDouble(final double newDefaultDouble) { ConvertUtilsBean.getInstance().setDefaultDouble(newDefaultDouble); } @@ -144,7 +144,7 @@ public class ConvertUtils { * Float.class instead */ @Deprecated - public static void setDefaultFloat(float newDefaultFloat) { + public static void setDefaultFloat(final float newDefaultFloat) { ConvertUtilsBean.getInstance().setDefaultFloat(newDefaultFloat); } @@ -167,7 +167,7 @@ public class ConvertUtils { * Integer.class instead */ @Deprecated - public static void setDefaultInteger(int newDefaultInteger) { + public static void setDefaultInteger(final int newDefaultInteger) { ConvertUtilsBean.getInstance().setDefaultInteger(newDefaultInteger); } @@ -190,7 +190,7 @@ public class ConvertUtils { * Long.class instead */ @Deprecated - public static void setDefaultLong(long newDefaultLong) { + public static void setDefaultLong(final long newDefaultLong) { ConvertUtilsBean.getInstance().setDefaultLong(newDefaultLong); } @@ -213,7 +213,7 @@ public class ConvertUtils { * Short.class instead */ @Deprecated - public static void setDefaultShort(short newDefaultShort) { + public static void setDefaultShort(final short newDefaultShort) { ConvertUtilsBean.getInstance().setDefaultShort(newDefaultShort); } @@ -230,7 +230,7 @@ public class ConvertUtils { * * @see ConvertUtilsBean#convert(Object) */ - public static String convert(Object value) { + public static String convert(final Object value) { return ConvertUtilsBean.getInstance().convert(value); } @@ -247,7 +247,7 @@ public class ConvertUtils { * * @see ConvertUtilsBean#convert(String, Class) */ - public static Object convert(String value, Class<?> clazz) { + public static Object convert(final String value, final Class<?> clazz) { return ConvertUtilsBean.getInstance().convert(value, clazz); } @@ -264,7 +264,7 @@ public class ConvertUtils { * * @see ConvertUtilsBean#convert(String[], Class) */ - public static Object convert(String[] values, Class<?> clazz) { + public static Object convert(final String[] values, final Class<?> clazz) { return ConvertUtilsBean.getInstance().convert(values, clazz); } @@ -278,7 +278,7 @@ public class ConvertUtils { * * @exception ConversionException if thrown by an underlying Converter */ - public static Object convert(Object value, Class<?> targetType) { + public static Object convert(final Object value, final Class<?> targetType) { return ConvertUtilsBean.getInstance().convert(value, targetType); } @@ -304,7 +304,7 @@ public class ConvertUtils { * @param clazz Class for which to remove a registered Converter * @see ConvertUtilsBean#deregister(Class) */ - public static void deregister(Class<?> clazz) { + public static void deregister(final Class<?> clazz) { ConvertUtilsBean.getInstance().deregister(clazz); } @@ -320,7 +320,7 @@ public class ConvertUtils { * @return The registered {@link Converter} or <code>null</code> if not found * @see ConvertUtilsBean#lookup(Class) */ - public static Converter lookup(Class<?> clazz) { + public static Converter lookup(final Class<?> clazz) { return ConvertUtilsBean.getInstance().lookup(clazz); } @@ -333,7 +333,7 @@ public class ConvertUtils { * @param targetType Class of the value to be converted to * @return The registered {@link Converter} or <code>null</code> if not found */ - public static Converter lookup(Class<?> sourceType, Class<?> targetType) { + public static Converter lookup(final Class<?> sourceType, final Class<?> targetType) { return ConvertUtilsBean.getInstance().lookup(sourceType, targetType); } @@ -348,7 +348,7 @@ public class ConvertUtils { * Converter * @see ConvertUtilsBean#register(Converter, Class) */ - public static void register(Converter converter, Class<?> clazz) { + public static void register(final Converter converter, final Class<?> clazz) { ConvertUtilsBean.getInstance().register(converter, clazz); } @@ -366,7 +366,7 @@ public class ConvertUtils { // All type casts are safe because the TYPE members of the wrapper types // return their own class. @SuppressWarnings("unchecked") - public static <T> Class<T> primitiveToWrapper(Class<T> type) { + public static <T> Class<T> primitiveToWrapper(final Class<T> type) { if (type == null || !type.isPrimitive()) { return type; } Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtilsBean.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtilsBean.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtilsBean.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtilsBean.java Wed Oct 15 20:15:17 2014 @@ -190,7 +190,7 @@ public class ConvertUtilsBean { * Boolean.class instead */ @Deprecated - public void setDefaultBoolean(boolean newDefaultBoolean) { + public void setDefaultBoolean(final boolean newDefaultBoolean) { defaultBoolean = (newDefaultBoolean ? Boolean.TRUE : Boolean.FALSE); register(new BooleanConverter(defaultBoolean), Boolean.TYPE); register(new BooleanConverter(defaultBoolean), Boolean.class); @@ -223,7 +223,7 @@ public class ConvertUtilsBean { * Byte.class instead */ @Deprecated - public void setDefaultByte(byte newDefaultByte) { + public void setDefaultByte(final byte newDefaultByte) { defaultByte = new Byte(newDefaultByte); register(new ByteConverter(defaultByte), Byte.TYPE); register(new ByteConverter(defaultByte), Byte.class); @@ -256,7 +256,7 @@ public class ConvertUtilsBean { * Character.class instead */ @Deprecated - public void setDefaultCharacter(char newDefaultCharacter) { + public void setDefaultCharacter(final char newDefaultCharacter) { defaultCharacter = new Character(newDefaultCharacter); register(new CharacterConverter(defaultCharacter), Character.TYPE); @@ -291,7 +291,7 @@ public class ConvertUtilsBean { * Double.class instead */ @Deprecated - public void setDefaultDouble(double newDefaultDouble) { + public void setDefaultDouble(final double newDefaultDouble) { defaultDouble = new Double(newDefaultDouble); register(new DoubleConverter(defaultDouble), Double.TYPE); register(new DoubleConverter(defaultDouble), Double.class); @@ -324,7 +324,7 @@ public class ConvertUtilsBean { * Float.class instead */ @Deprecated - public void setDefaultFloat(float newDefaultFloat) { + public void setDefaultFloat(final float newDefaultFloat) { defaultFloat = new Float(newDefaultFloat); register(new FloatConverter(defaultFloat), Float.TYPE); register(new FloatConverter(defaultFloat), Float.class); @@ -357,7 +357,7 @@ public class ConvertUtilsBean { * Integer.class instead */ @Deprecated - public void setDefaultInteger(int newDefaultInteger) { + public void setDefaultInteger(final int newDefaultInteger) { defaultInteger = new Integer(newDefaultInteger); register(new IntegerConverter(defaultInteger), Integer.TYPE); register(new IntegerConverter(defaultInteger), Integer.class); @@ -390,7 +390,7 @@ public class ConvertUtilsBean { * Long.class instead */ @Deprecated - public void setDefaultLong(long newDefaultLong) { + public void setDefaultLong(final long newDefaultLong) { defaultLong = new Long(newDefaultLong); register(new LongConverter(defaultLong), Long.TYPE); register(new LongConverter(defaultLong), Long.class); @@ -423,7 +423,7 @@ public class ConvertUtilsBean { * Short.class instead */ @Deprecated - public void setDefaultShort(short newDefaultShort) { + public void setDefaultShort(final short newDefaultShort) { defaultShort = new Short(newDefaultShort); register(new ShortConverter(defaultShort), Short.TYPE); register(new ShortConverter(defaultShort), Short.class); @@ -454,11 +454,11 @@ public class ConvertUtilsBean { if (value == null) { return null; } else { - Converter converter = lookup(String.class); + final Converter converter = lookup(String.class); return (converter.convert(String.class, value)); } } else { - Converter converter = lookup(String.class); + final Converter converter = lookup(String.class); return (converter.convert(String.class, value)); } @@ -475,7 +475,7 @@ public class ConvertUtilsBean { * * @exception ConversionException if thrown by an underlying Converter */ - public Object convert(String value, Class<?> clazz) { + public Object convert(final String value, final Class<?> clazz) { if (log.isDebugEnabled()) { log.debug("Convert string '" + value + "' to class '" + @@ -506,7 +506,7 @@ public class ConvertUtilsBean { * * @exception ConversionException if thrown by an underlying Converter */ - public Object convert(String[] values, Class<?> clazz) { + public Object convert(final String[] values, final Class<?> clazz) { Class<?> type = clazz; if (clazz.isArray()) { @@ -523,7 +523,7 @@ public class ConvertUtilsBean { if (log.isTraceEnabled()) { log.trace(" Using converter " + converter); } - Object array = Array.newInstance(type, values.length); + final Object array = Array.newInstance(type, values.length); for (int i = 0; i < values.length; i++) { Array.set(array, i, converter.convert(type, values[i])); } @@ -543,9 +543,9 @@ public class ConvertUtilsBean { * * @exception ConversionException if thrown by an underlying Converter */ - public Object convert(Object value, Class<?> targetType) { + public Object convert(final Object value, final Class<?> targetType) { - Class<?> sourceType = value == null ? null : value.getClass(); + final Class<?> sourceType = value == null ? null : value.getClass(); if (log.isDebugEnabled()) { if (value == null) { @@ -620,7 +620,7 @@ public class ConvertUtilsBean { * Specifying a value less than zero causes a <code>null</code> value to be used for * the default. */ - public void register(boolean throwException, boolean defaultNull, int defaultArraySize) { + public void register(final boolean throwException, final boolean defaultNull, final int defaultArraySize) { registerPrimitives(throwException); registerStandard(throwException, defaultNull); registerOther(throwException); @@ -645,7 +645,7 @@ public class ConvertUtilsBean { * throw an exception when a conversion error occurs, otherwise <code> * <code>false</code> if a default value should be used. */ - private void registerPrimitives(boolean throwException) { + 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)); @@ -681,14 +681,14 @@ public class ConvertUtilsBean { * should use a default value of <code>null</code>, otherwise <code>false</code>. * N.B. This values is ignored if <code>throwException</code> is <code>true</code> */ - private void registerStandard(boolean throwException, boolean defaultNull) { + private void registerStandard(final boolean throwException, final boolean defaultNull) { - Number defaultNumber = defaultNull ? null : ZERO; - BigDecimal bigDecDeflt = defaultNull ? null : new BigDecimal("0.0"); - BigInteger bigIntDeflt = defaultNull ? null : new BigInteger("0"); - Boolean booleanDefault = defaultNull ? null : Boolean.FALSE; - Character charDefault = defaultNull ? null : SPACE; - 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)); @@ -722,7 +722,7 @@ public class ConvertUtilsBean { * throw an exception when a conversion error occurs, otherwise <code> * <code>false</code> if a default value should be used. */ - private void registerOther(boolean throwException) { + private void registerOther(final boolean throwException) { register(Class.class, throwException ? new ClassConverter() : new ClassConverter(null)); register(java.util.Date.class, throwException ? new DateConverter() : new DateConverter(null)); register(Calendar.class, throwException ? new CalendarConverter() : new CalendarConverter(null)); @@ -744,7 +744,7 @@ public class ConvertUtilsBean { * Specifying a value less than zero causes a <code>null<code> value to be used for * the default. */ - private void registerArrays(boolean throwException, int defaultArraySize) { + private void registerArrays(final boolean throwException, final int defaultArraySize) { // Primitives registerArrayConverter(Boolean.TYPE, new BooleanConverter(), throwException, defaultArraySize); @@ -791,9 +791,9 @@ public class ConvertUtilsBean { * value used in the event of a conversion error * @param defaultArraySize The size of the default array */ - private void registerArrayConverter(Class<?> componentType, Converter componentConverter, - boolean throwException, int defaultArraySize) { - Class<?> arrayType = Array.newInstance(componentType, 0).getClass(); + private void registerArrayConverter(final Class<?> componentType, final Converter componentConverter, + final boolean throwException, final int defaultArraySize) { + final Class<?> arrayType = Array.newInstance(componentType, 0).getClass(); Converter arrayConverter = null; if (throwException) { arrayConverter = new ArrayConverter(arrayType, componentConverter); @@ -804,7 +804,7 @@ public class ConvertUtilsBean { } /** strictly for convenience since it has same parameter order as Map.put */ - private void register(Class<?> clazz, Converter converter) { + private void register(final Class<?> clazz, final Converter converter) { register(new ConverterFacade(converter), clazz); } @@ -814,7 +814,7 @@ public class ConvertUtilsBean { * * @param clazz Class for which to remove a registered Converter */ - public void deregister(Class<?> clazz) { + public void deregister(final Class<?> clazz) { converters.remove(clazz); @@ -829,7 +829,7 @@ public class ConvertUtilsBean { * @param clazz Class for which to return a registered Converter * @return The registered {@link Converter} or <code>null</code> if not found */ - public Converter lookup(Class<?> clazz) { + public Converter lookup(final Class<?> clazz) { return (converters.get(clazz)); @@ -844,7 +844,7 @@ public class ConvertUtilsBean { * @param targetType Class of the value to be converted to * @return The registered {@link Converter} or <code>null</code> if not found */ - public Converter lookup(Class<?> sourceType, Class<?> targetType) { + public Converter lookup(final Class<?> sourceType, final Class<?> targetType) { if (targetType == null) { throw new IllegalArgumentException("Target type is missing"); @@ -890,7 +890,7 @@ public class ConvertUtilsBean { * @param clazz Destination class for conversions performed by this * Converter */ - public void register(Converter converter, Class<?> clazz) { + public void register(final Converter converter, final Class<?> clazz) { converters.put(clazz, converter); Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtilsBean2.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtilsBean2.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtilsBean2.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertUtilsBean2.java Wed Oct 15 20:15:17 2014 @@ -41,7 +41,7 @@ public class ConvertUtilsBean2 extends C * @see ConvertUtilsBean#convert(String[], Class) */ @Override - public String convert(Object value) { + public String convert(final Object value) { return (String)convert(value, String.class); } @@ -56,7 +56,7 @@ public class ConvertUtilsBean2 extends C * @see ConvertUtilsBean#convert(String[], Class) */ @Override - public Object convert(String value, Class<?> clazz) { + public Object convert(final String value, final Class<?> clazz) { return convert((Object)value, clazz); } @@ -71,7 +71,7 @@ public class ConvertUtilsBean2 extends C * @see ConvertUtilsBean#convert(String[], Class) */ @Override - public Object convert(String[] value, Class<?> clazz) { + public Object convert(final String[] value, final Class<?> clazz) { return convert((Object)value, clazz); } Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertingWrapDynaBean.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertingWrapDynaBean.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertingWrapDynaBean.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConvertingWrapDynaBean.java Wed Oct 15 20:15:17 2014 @@ -42,7 +42,7 @@ public class ConvertingWrapDynaBean exte * * @param instance JavaBean instance to be wrapped */ - public ConvertingWrapDynaBean(Object instance) { + public ConvertingWrapDynaBean(final Object instance) { super(instance); @@ -61,17 +61,17 @@ public class ConvertingWrapDynaBean exte * copying the property. */ @Override - public void set(String name, Object value) { + public void set(final String name, final Object value) { try { BeanUtils.copyProperty(instance, name, value); - } catch (InvocationTargetException ite) { - Throwable cause = ite.getTargetException(); + } catch (final InvocationTargetException ite) { + final Throwable cause = ite.getTargetException(); throw new IllegalArgumentException ("Error setting property '" + name + "' nested exception - " + cause); - } catch (Throwable t) { - IllegalArgumentException iae = new IllegalArgumentException + } catch (final Throwable t) { + final IllegalArgumentException iae = new IllegalArgumentException ("Error setting property '" + name + "', exception - " + t); BeanUtils.initCause(iae, t); Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/DefaultBeanIntrospector.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/DefaultBeanIntrospector.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/DefaultBeanIntrospector.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/DefaultBeanIntrospector.java Wed Oct 15 20:15:17 2014 @@ -73,11 +73,11 @@ public class DefaultBeanIntrospector imp * * @param icontext the introspection context */ - public void introspect(IntrospectionContext icontext) { + public void introspect(final IntrospectionContext icontext) { BeanInfo beanInfo = null; try { beanInfo = Introspector.getBeanInfo(icontext.getTargetClass()); - } catch (IntrospectionException e) { + } catch (final IntrospectionException e) { // no descriptors are added to the context log.error( "Error when inspecting class " + icontext.getTargetClass(), @@ -119,26 +119,26 @@ public class DefaultBeanIntrospector imp * @param beanClass the current class to be inspected * @param descriptors the array with property descriptors */ - private void handleIndexedPropertyDescriptors(Class<?> beanClass, - PropertyDescriptor[] descriptors) { - for (PropertyDescriptor pd : descriptors) { + private void handleIndexedPropertyDescriptors(final Class<?> beanClass, + final PropertyDescriptor[] descriptors) { + for (final PropertyDescriptor pd : descriptors) { if (pd instanceof IndexedPropertyDescriptor) { - IndexedPropertyDescriptor descriptor = (IndexedPropertyDescriptor) pd; - String propName = descriptor.getName().substring(0, 1) + final IndexedPropertyDescriptor descriptor = (IndexedPropertyDescriptor) pd; + final String propName = descriptor.getName().substring(0, 1) .toUpperCase() + descriptor.getName().substring(1); if (descriptor.getReadMethod() == null) { - String methodName = descriptor.getIndexedReadMethod() != null ? descriptor + final String methodName = descriptor.getIndexedReadMethod() != null ? descriptor .getIndexedReadMethod().getName() : "get" + propName; - Method readMethod = MethodUtils + final Method readMethod = MethodUtils .getMatchingAccessibleMethod(beanClass, methodName, EMPTY_CLASS_PARAMETERS); if (readMethod != null) { try { descriptor.setReadMethod(readMethod); - } catch (Exception e) { + } catch (final Exception e) { log.error( "Error setting indexed property read method", e); @@ -146,16 +146,16 @@ public class DefaultBeanIntrospector imp } } if (descriptor.getWriteMethod() == null) { - String methodName = descriptor.getIndexedWriteMethod() != null ? descriptor + final String methodName = descriptor.getIndexedWriteMethod() != null ? descriptor .getIndexedWriteMethod().getName() : "set" + propName; Method writeMethod = MethodUtils .getMatchingAccessibleMethod(beanClass, methodName, LIST_CLASS_PARAMETER); if (writeMethod == null) { - for (Method m : beanClass.getMethods()) { + for (final Method m : beanClass.getMethods()) { if (m.getName().equals(methodName)) { - Class<?>[] parameterTypes = m.getParameterTypes(); + final Class<?>[] parameterTypes = m.getParameterTypes(); if (parameterTypes.length == 1 && List.class .isAssignableFrom(parameterTypes[0])) { @@ -168,7 +168,7 @@ public class DefaultBeanIntrospector imp if (writeMethod != null) { try { descriptor.setWriteMethod(writeMethod); - } catch (Exception e) { + } catch (final Exception e) { log.error( "Error setting indexed property write method", e); Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/DefaultIntrospectionContext.java URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/DefaultIntrospectionContext.java?rev=1632171&r1=1632170&r2=1632171&view=diff ============================================================================== --- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/DefaultIntrospectionContext.java (original) +++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/DefaultIntrospectionContext.java Wed Oct 15 20:15:17 2014 @@ -52,7 +52,7 @@ class DefaultIntrospectionContext implem * * @param cls the current class */ - public DefaultIntrospectionContext(Class<?> cls) { + public DefaultIntrospectionContext(final Class<?> cls) { currentClass = cls; descriptors = new HashMap<String, PropertyDescriptor>(); } @@ -61,7 +61,7 @@ class DefaultIntrospectionContext implem return currentClass; } - public void addPropertyDescriptor(PropertyDescriptor desc) { + public void addPropertyDescriptor(final PropertyDescriptor desc) { if (desc == null) { throw new IllegalArgumentException( "Property descriptor must not be null!"); @@ -69,7 +69,7 @@ class DefaultIntrospectionContext implem descriptors.put(desc.getName(), desc); } - public void addPropertyDescriptors(PropertyDescriptor[] descs) { + public void addPropertyDescriptors(final PropertyDescriptor[] descs) { if (descs == null) { throw new IllegalArgumentException( "Array with descriptors must not be null!"); @@ -80,15 +80,15 @@ class DefaultIntrospectionContext implem } } - public boolean hasProperty(String name) { + public boolean hasProperty(final String name) { return descriptors.containsKey(name); } - public PropertyDescriptor getPropertyDescriptor(String name) { + public PropertyDescriptor getPropertyDescriptor(final String name) { return descriptors.get(name); } - public void removePropertyDescriptor(String name) { + public void removePropertyDescriptor(final String name) { descriptors.remove(name); }
