Add final modifier to private fields.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1436767 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2013-01-22 07:05:41 +00:00
parent 53646c1c98
commit adfcc014bd
12 changed files with 29 additions and 29 deletions

View File

@ -266,7 +266,7 @@ public class SerializationUtils {
static class ClassLoaderAwareObjectInputStream extends ObjectInputStream {
private static final Map<String, Class<?>> primitiveTypes =
new HashMap<String, Class<?>>();
private ClassLoader classLoader;
private final ClassLoader classLoader;
/**
* Constructor.

View File

@ -466,7 +466,7 @@ public class StringUtilsEqualsIndexOfTest {
// other object be an instance of CustomCharSequence, even though, as char sequences,
// `seq` may equal the other object.
private static class CustomCharSequence implements CharSequence {
private CharSequence seq;
private final CharSequence seq;
public CustomCharSequence(CharSequence seq) {
this.seq = seq;

View File

@ -128,7 +128,7 @@ public class EqualsBuilderTest {
static class TestTTLeafObject extends TestTTSubObject {
@SuppressWarnings("unused")
private int leafValue;
private final int leafValue;
public TestTTLeafObject(int a, int t, int tt, int leafValue) {
super(a, t, tt);
this.leafValue = leafValue;
@ -938,7 +938,7 @@ public class EqualsBuilderTest {
}
public static class TestACanEqualB {
private int a;
private final int a;
public TestACanEqualB(int a) {
this.a = a;
@ -969,7 +969,7 @@ public class EqualsBuilderTest {
}
public static class TestBCanEqualA {
private int b;
private final int b;
public TestBCanEqualA(int b) {
this.b = b;
@ -1065,11 +1065,11 @@ public class EqualsBuilderTest {
static class TestObjectWithMultipleFields {
@SuppressWarnings("unused")
private TestObject one;
private final TestObject one;
@SuppressWarnings("unused")
private TestObject two;
private final TestObject two;
@SuppressWarnings("unused")
private TestObject three;
private final TestObject three;
public TestObjectWithMultipleFields(int one, int two, int three) {
this.one = new TestObject(one);
@ -1111,7 +1111,7 @@ public class EqualsBuilderTest {
@SuppressWarnings("unused")
private TestObjectReference reference;
@SuppressWarnings("unused")
private TestObject one;
private final TestObject one;
public TestObjectReference(int one) {
this.one = new TestObject(one);

View File

@ -33,10 +33,10 @@ public class ReflectionToStringBuilderExcludeTest {
class TestFixture {
@SuppressWarnings("unused")
private String secretField = SECRET_VALUE;
private final String secretField = SECRET_VALUE;
@SuppressWarnings("unused")
private String showField = NOT_SECRET_VALUE;
private final String showField = NOT_SECRET_VALUE;
}
private static final String NOT_SECRET_FIELD = "showField";

View File

@ -40,7 +40,7 @@ public class ReflectionToStringBuilderMutateInspectConcurrencyTest {
class TestFixture {
final private LinkedList<Integer> listField = new LinkedList<Integer>();
final private Random random = new Random();
private int N = 100;
private final int N = 100;
public TestFixture() {
synchronized (this) {

View File

@ -359,14 +359,14 @@ public class ToStringBuilderTest {
static class ReflectionTestFixtureA {
@SuppressWarnings("unused")
private char a='a';
private final char a='a';
@SuppressWarnings("unused")
private transient char transientA='t';
}
static class ReflectionTestFixtureB extends ReflectionTestFixtureA {
@SuppressWarnings("unused")
private char b='b';
private final char b='b';
@SuppressWarnings("unused")
private transient char transientB='t';
}
@ -489,7 +489,7 @@ public class ToStringBuilderTest {
private static class SelfInstanceVarReflectionTestFixture {
@SuppressWarnings("unused")
private SelfInstanceVarReflectionTestFixture typeIsSelf;
private final SelfInstanceVarReflectionTestFixture typeIsSelf;
public SelfInstanceVarReflectionTestFixture() {
this.typeIsSelf = this;
@ -503,8 +503,8 @@ public class ToStringBuilderTest {
private static class SelfInstanceTwoVarsReflectionTestFixture {
@SuppressWarnings("unused")
private SelfInstanceTwoVarsReflectionTestFixture typeIsSelf;
private String otherType = "The Other Type";
private final SelfInstanceTwoVarsReflectionTestFixture typeIsSelf;
private final String otherType = "The Other Type";
public SelfInstanceTwoVarsReflectionTestFixture() {
this.typeIsSelf = this;

View File

@ -201,7 +201,7 @@ public class EventUtilsTest
private static class EventCountingInvociationHandler implements InvocationHandler
{
private Map<String, Integer> eventCounts = new TreeMap<String, Integer>();
private final Map<String, Integer> eventCounts = new TreeMap<String, Integer>();
public <L> L createListener(Class<L> listenerType)
{
@ -234,7 +234,7 @@ public class EventUtilsTest
public static class MultipleEventSource
{
private EventListenerSupport<MultipleEventListener> listeners = EventListenerSupport.create(MultipleEventListener.class);
private final EventListenerSupport<MultipleEventListener> listeners = EventListenerSupport.create(MultipleEventListener.class);
public void addMultipleEventListener(MultipleEventListener listener)
{
@ -252,7 +252,7 @@ public class EventUtilsTest
public static class PropertyChangeSource
{
private EventListenerSupport<PropertyChangeListener> listeners = EventListenerSupport.create(PropertyChangeListener.class);
private final EventListenerSupport<PropertyChangeListener> listeners = EventListenerSupport.create(PropertyChangeListener.class);
private String property;

View File

@ -34,7 +34,7 @@ import org.apache.commons.lang3.mutable.MutableObject;
*/
public class ConstructorUtilsTest {
public static class TestBean {
private String toString;
private final String toString;
public TestBean() {
toString = "()";
@ -72,7 +72,7 @@ public class ConstructorUtilsTest {
}
}
private Map<Class<?>, Class<?>[]> classCache;
private final Map<Class<?>, Class<?>[]> classCache;
public ConstructorUtilsTest() {
classCache = new HashMap<Class<?>, Class<?>[]>();

View File

@ -54,7 +54,7 @@ public class FieldUtilsTest {
private PublicChild publicChild;
private PubliclyShadowedChild publiclyShadowedChild;
private PrivatelyShadowedChild privatelyShadowedChild;
private Class<?> parentClass = PublicChild.class.getSuperclass();
private final Class<?> parentClass = PublicChild.class.getSuperclass();
@Before
public void setUp() {

View File

@ -126,7 +126,7 @@ public class MethodUtilsTest {
}
private TestBean testBean;
private Map<Class<?>, Class<?>[]> classCache = new HashMap<Class<?>, Class<?>[]>();
private final Map<Class<?>, Class<?>[]> classCache = new HashMap<Class<?>, Class<?>[]>();
@Before
public void setUp() throws Exception {

View File

@ -24,5 +24,5 @@ class Parent implements Foo {
protected boolean b = false;
int i = 0;
@SuppressWarnings("unused")
private double d = 0.0;
private final double d = 0.0;
}

View File

@ -21,8 +21,8 @@ package org.apache.commons.lang3.reflect.testbed;
*/
@SuppressWarnings({ "unused", "hiding" }) // deliberate re-use of variable names
public class PrivatelyShadowedChild extends Parent {
private String s = "ss";
private boolean b = true;
private int i = 1;
private double d = 1.0;
private final String s = "ss";
private final boolean b = true;
private final int i = 1;
private final double d = 1.0;
}