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 2021/01/21 16:51:04 UTC
[commons-beanutils] 01/02: Use final.
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 6c152a18295565b83312bb20c6cc99f61c2bc074
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jan 21 11:50:39 2021 -0500
Use final.
---
src/main/java/org/apache/commons/beanutils2/BeanMap.java | 6 +++---
.../apache/commons/beanutils2/BeanPropertyValueChangeConsumer.java | 6 +++---
.../apache/commons/beanutils2/BeanPropertyValueEqualsPredicate.java | 6 +++---
.../apache/commons/beanutils2/BeanToPropertyValueTransformer.java | 4 ++--
src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java | 4 ++--
src/main/java/org/apache/commons/beanutils2/WrapDynaClass.java | 4 ++--
.../org/apache/commons/beanutils2/DynaBeanMapDecoratorTestCase.java | 6 +++---
.../java/org/apache/commons/beanutils2/bugs/Jira509TestCase.java | 2 +-
.../apache/commons/beanutils2/locale/LocaleBeanUtilsTestCase.java | 2 +-
9 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanMap.java b/src/main/java/org/apache/commons/beanutils2/BeanMap.java
index c456d40..be3c0bf 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanMap.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanMap.java
@@ -45,9 +45,9 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
private transient Object bean;
- private transient HashMap<String, Method> readMethods = new HashMap<>();
- private transient HashMap<String, Method> writeMethods = new HashMap<>();
- private transient HashMap<String, Class<? extends Object>> types = new HashMap<>();
+ private final transient HashMap<String, Method> readMethods = new HashMap<>();
+ private final transient HashMap<String, Method> writeMethods = new HashMap<>();
+ private final transient HashMap<String, Class<? extends Object>> types = new HashMap<>();
/**
* An empty array. Used to invoke accessors via reflection.
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumer.java b/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumer.java
index 9f0c2b4..6042926 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumer.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumer.java
@@ -87,13 +87,13 @@ public class BeanPropertyValueChangeConsumer<T, V> implements Consumer<T> {
/**
* The name of the property which will be updated when this {@code Closure} executes.
*/
- private String propertyName;
+ private final String propertyName;
/**
* The value that the property specified by {@code propertyName}
* will be updated to when this {@code Closure} executes.
*/
- private V propertyValue;
+ private final V propertyValue;
/**
* Determines whether {@code null} objects in the property path will generate an
@@ -105,7 +105,7 @@ public class BeanPropertyValueChangeConsumer<T, V> implements Consumer<T> {
* {@code IllegalArgumentException</code> throw by <code>PropertyUtils} will be logged and
* re-thrown.
*/
- private boolean ignoreNull;
+ private final boolean ignoreNull;
/**
* Constructor which takes the name of the property to be changed, the new value to set
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicate.java b/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicate.java
index 1dae193..b56e153 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicate.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicate.java
@@ -118,13 +118,13 @@ public class BeanPropertyValueEqualsPredicate<T, V> implements Predicate<T> {
/**
* The name of the property which will be evaluated when this {@code Predicate} is executed.
*/
- private String propertyName;
+ private final String propertyName;
/**
* The value that the property specified by {@code propertyName}
* will be compared to when this {@code Predicate} executes.
*/
- private V propertyValue;
+ private final V propertyValue;
/**
* <p>Should {@code null} objects in the property path be ignored?</p>
@@ -139,7 +139,7 @@ public class BeanPropertyValueEqualsPredicate<T, V> implements Predicate<T> {
* re-thrown.
* </p>
*/
- private boolean ignoreNull;
+ private final boolean ignoreNull;
/**
* Constructor which takes the name of the property, its expected value to be used in evaluation,
diff --git a/src/main/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformer.java b/src/main/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformer.java
index 7c81d7e..72853e8 100644
--- a/src/main/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformer.java
+++ b/src/main/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformer.java
@@ -77,7 +77,7 @@ public class BeanToPropertyValueTransformer<T, R> implements Function<T, R> {
private final Log log = LogFactory.getLog(this.getClass());
/** The name of the property that will be used in the transformation of the object. */
- private String propertyName;
+ private final String propertyName;
/**
* <p>Should null objects on the property path throw an {@code IllegalArgumentException}?</p>
@@ -92,7 +92,7 @@ public class BeanToPropertyValueTransformer<T, R> implements Function<T, R> {
* re-thrown.
* </p>
*/
- private boolean ignoreNull;
+ private final boolean ignoreNull;
/**
* Constructs a Transformer which does not ignore nulls.
diff --git a/src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java b/src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java
index 56a59ec..9b49dce 100644
--- a/src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java
+++ b/src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java
@@ -106,8 +106,8 @@ public class PropertyUtilsBean {
* The cache of PropertyDescriptor arrays for beans we have already
* introspected, keyed by the java.lang.Class of this object.
*/
- private WeakFastHashMap<Class<?>, BeanIntrospectionData> descriptorsCache;
- private WeakFastHashMap<Class<?>, Map> mappedDescriptorsCache;
+ private final WeakFastHashMap<Class<?>, BeanIntrospectionData> descriptorsCache;
+ private final WeakFastHashMap<Class<?>, Map> mappedDescriptorsCache;
/** Log instance */
private final Log log = LogFactory.getLog(PropertyUtilsBean.class);
diff --git a/src/main/java/org/apache/commons/beanutils2/WrapDynaClass.java b/src/main/java/org/apache/commons/beanutils2/WrapDynaClass.java
index dc7abf5..5863ee4 100644
--- a/src/main/java/org/apache/commons/beanutils2/WrapDynaClass.java
+++ b/src/main/java/org/apache/commons/beanutils2/WrapDynaClass.java
@@ -71,12 +71,12 @@ public class WrapDynaClass implements DynaClass {
/**
* Name of the JavaBean class represented by this WrapDynaClass.
*/
- private String beanClassName;
+ private final String beanClassName;
/**
* Reference to the JavaBean class represented by this WrapDynaClass.
*/
- private Reference<Class<?>> beanClassRef;
+ private final Reference<Class<?>> beanClassRef;
/** Stores the associated {@code PropertyUtilsBean} instance. */
private final PropertyUtilsBean propertyUtilsBean;
diff --git a/src/test/java/org/apache/commons/beanutils2/DynaBeanMapDecoratorTestCase.java b/src/test/java/org/apache/commons/beanutils2/DynaBeanMapDecoratorTestCase.java
index efd371f..a154b85 100644
--- a/src/test/java/org/apache/commons/beanutils2/DynaBeanMapDecoratorTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/DynaBeanMapDecoratorTestCase.java
@@ -45,9 +45,9 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
stringProp, nullProp, intProp, dateProp, mapProp};
private static final DynaClass dynaClass = new BasicDynaClass("testDynaClass", BasicDynaBean.class, properties);
- private static String stringVal = "somevalue";
- private static Integer intVal = new Integer(5);
- private static Date dateVal = new Date();
+ private static final String stringVal = "somevalue";
+ private static final Integer intVal = new Integer(5);
+ private static final Date dateVal = new Date();
private final Map<Object, Object> mapVal = new HashMap<>();
private final Object[] values = new Object[] {stringVal, null, intVal, dateVal, mapVal};
diff --git a/src/test/java/org/apache/commons/beanutils2/bugs/Jira509TestCase.java b/src/test/java/org/apache/commons/beanutils2/bugs/Jira509TestCase.java
index 439737f..03839fa 100644
--- a/src/test/java/org/apache/commons/beanutils2/bugs/Jira509TestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/bugs/Jira509TestCase.java
@@ -66,7 +66,7 @@ public class Jira509TestCase {
// Loop _may_ hang without fix.
for (int i = 1; i < 10_000_000; i++) {
executor.submit(new Runnable() {
- Class<?> clazz = classList.get(random(classList.size()));
+ final Class<?> clazz = classList.get(random(classList.size()));
@Override
public void run() {
diff --git a/src/test/java/org/apache/commons/beanutils2/locale/LocaleBeanUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/locale/LocaleBeanUtilsTestCase.java
index 1d914c3..681a69c 100644
--- a/src/test/java/org/apache/commons/beanutils2/locale/LocaleBeanUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/locale/LocaleBeanUtilsTestCase.java
@@ -30,7 +30,7 @@ import junit.framework.TestSuite;
*/
public class LocaleBeanUtilsTestCase extends TestCase {
- private static Log log = LogFactory.getLog(LocaleBeanUtilsTestCase.class);
+ private static final Log log = LogFactory.getLog(LocaleBeanUtilsTestCase.class);
/**
* Constructs a new instance of this test case.