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:
parent
53646c1c98
commit
adfcc014bd
|
@ -266,7 +266,7 @@ public class SerializationUtils {
|
||||||
static class ClassLoaderAwareObjectInputStream extends ObjectInputStream {
|
static class ClassLoaderAwareObjectInputStream extends ObjectInputStream {
|
||||||
private static final Map<String, Class<?>> primitiveTypes =
|
private static final Map<String, Class<?>> primitiveTypes =
|
||||||
new HashMap<String, Class<?>>();
|
new HashMap<String, Class<?>>();
|
||||||
private ClassLoader classLoader;
|
private final ClassLoader classLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
|
|
@ -466,7 +466,7 @@ public class StringUtilsEqualsIndexOfTest {
|
||||||
// other object be an instance of CustomCharSequence, even though, as char sequences,
|
// other object be an instance of CustomCharSequence, even though, as char sequences,
|
||||||
// `seq` may equal the other object.
|
// `seq` may equal the other object.
|
||||||
private static class CustomCharSequence implements CharSequence {
|
private static class CustomCharSequence implements CharSequence {
|
||||||
private CharSequence seq;
|
private final CharSequence seq;
|
||||||
|
|
||||||
public CustomCharSequence(CharSequence seq) {
|
public CustomCharSequence(CharSequence seq) {
|
||||||
this.seq = seq;
|
this.seq = seq;
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class EqualsBuilderTest {
|
||||||
|
|
||||||
static class TestTTLeafObject extends TestTTSubObject {
|
static class TestTTLeafObject extends TestTTSubObject {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private int leafValue;
|
private final int leafValue;
|
||||||
public TestTTLeafObject(int a, int t, int tt, int leafValue) {
|
public TestTTLeafObject(int a, int t, int tt, int leafValue) {
|
||||||
super(a, t, tt);
|
super(a, t, tt);
|
||||||
this.leafValue = leafValue;
|
this.leafValue = leafValue;
|
||||||
|
@ -938,7 +938,7 @@ public class EqualsBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TestACanEqualB {
|
public static class TestACanEqualB {
|
||||||
private int a;
|
private final int a;
|
||||||
|
|
||||||
public TestACanEqualB(int a) {
|
public TestACanEqualB(int a) {
|
||||||
this.a = a;
|
this.a = a;
|
||||||
|
@ -969,7 +969,7 @@ public class EqualsBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TestBCanEqualA {
|
public static class TestBCanEqualA {
|
||||||
private int b;
|
private final int b;
|
||||||
|
|
||||||
public TestBCanEqualA(int b) {
|
public TestBCanEqualA(int b) {
|
||||||
this.b = b;
|
this.b = b;
|
||||||
|
@ -1065,11 +1065,11 @@ public class EqualsBuilderTest {
|
||||||
|
|
||||||
static class TestObjectWithMultipleFields {
|
static class TestObjectWithMultipleFields {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private TestObject one;
|
private final TestObject one;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private TestObject two;
|
private final TestObject two;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private TestObject three;
|
private final TestObject three;
|
||||||
|
|
||||||
public TestObjectWithMultipleFields(int one, int two, int three) {
|
public TestObjectWithMultipleFields(int one, int two, int three) {
|
||||||
this.one = new TestObject(one);
|
this.one = new TestObject(one);
|
||||||
|
@ -1111,7 +1111,7 @@ public class EqualsBuilderTest {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private TestObjectReference reference;
|
private TestObjectReference reference;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private TestObject one;
|
private final TestObject one;
|
||||||
|
|
||||||
public TestObjectReference(int one) {
|
public TestObjectReference(int one) {
|
||||||
this.one = new TestObject(one);
|
this.one = new TestObject(one);
|
||||||
|
|
|
@ -33,10 +33,10 @@ public class ReflectionToStringBuilderExcludeTest {
|
||||||
|
|
||||||
class TestFixture {
|
class TestFixture {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private String secretField = SECRET_VALUE;
|
private final String secretField = SECRET_VALUE;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private String showField = NOT_SECRET_VALUE;
|
private final String showField = NOT_SECRET_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String NOT_SECRET_FIELD = "showField";
|
private static final String NOT_SECRET_FIELD = "showField";
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class ReflectionToStringBuilderMutateInspectConcurrencyTest {
|
||||||
class TestFixture {
|
class TestFixture {
|
||||||
final private LinkedList<Integer> listField = new LinkedList<Integer>();
|
final private LinkedList<Integer> listField = new LinkedList<Integer>();
|
||||||
final private Random random = new Random();
|
final private Random random = new Random();
|
||||||
private int N = 100;
|
private final int N = 100;
|
||||||
|
|
||||||
public TestFixture() {
|
public TestFixture() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
|
|
@ -359,14 +359,14 @@ public class ToStringBuilderTest {
|
||||||
|
|
||||||
static class ReflectionTestFixtureA {
|
static class ReflectionTestFixtureA {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private char a='a';
|
private final char a='a';
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private transient char transientA='t';
|
private transient char transientA='t';
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ReflectionTestFixtureB extends ReflectionTestFixtureA {
|
static class ReflectionTestFixtureB extends ReflectionTestFixtureA {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private char b='b';
|
private final char b='b';
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private transient char transientB='t';
|
private transient char transientB='t';
|
||||||
}
|
}
|
||||||
|
@ -489,7 +489,7 @@ public class ToStringBuilderTest {
|
||||||
|
|
||||||
private static class SelfInstanceVarReflectionTestFixture {
|
private static class SelfInstanceVarReflectionTestFixture {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private SelfInstanceVarReflectionTestFixture typeIsSelf;
|
private final SelfInstanceVarReflectionTestFixture typeIsSelf;
|
||||||
|
|
||||||
public SelfInstanceVarReflectionTestFixture() {
|
public SelfInstanceVarReflectionTestFixture() {
|
||||||
this.typeIsSelf = this;
|
this.typeIsSelf = this;
|
||||||
|
@ -503,8 +503,8 @@ public class ToStringBuilderTest {
|
||||||
|
|
||||||
private static class SelfInstanceTwoVarsReflectionTestFixture {
|
private static class SelfInstanceTwoVarsReflectionTestFixture {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private SelfInstanceTwoVarsReflectionTestFixture typeIsSelf;
|
private final SelfInstanceTwoVarsReflectionTestFixture typeIsSelf;
|
||||||
private String otherType = "The Other Type";
|
private final String otherType = "The Other Type";
|
||||||
|
|
||||||
public SelfInstanceTwoVarsReflectionTestFixture() {
|
public SelfInstanceTwoVarsReflectionTestFixture() {
|
||||||
this.typeIsSelf = this;
|
this.typeIsSelf = this;
|
||||||
|
|
|
@ -201,7 +201,7 @@ public class EventUtilsTest
|
||||||
|
|
||||||
private static class EventCountingInvociationHandler implements InvocationHandler
|
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)
|
public <L> L createListener(Class<L> listenerType)
|
||||||
{
|
{
|
||||||
|
@ -234,7 +234,7 @@ public class EventUtilsTest
|
||||||
|
|
||||||
public static class MultipleEventSource
|
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)
|
public void addMultipleEventListener(MultipleEventListener listener)
|
||||||
{
|
{
|
||||||
|
@ -252,7 +252,7 @@ public class EventUtilsTest
|
||||||
|
|
||||||
public static class PropertyChangeSource
|
public static class PropertyChangeSource
|
||||||
{
|
{
|
||||||
private EventListenerSupport<PropertyChangeListener> listeners = EventListenerSupport.create(PropertyChangeListener.class);
|
private final EventListenerSupport<PropertyChangeListener> listeners = EventListenerSupport.create(PropertyChangeListener.class);
|
||||||
|
|
||||||
private String property;
|
private String property;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.commons.lang3.mutable.MutableObject;
|
||||||
*/
|
*/
|
||||||
public class ConstructorUtilsTest {
|
public class ConstructorUtilsTest {
|
||||||
public static class TestBean {
|
public static class TestBean {
|
||||||
private String toString;
|
private final String toString;
|
||||||
|
|
||||||
public TestBean() {
|
public TestBean() {
|
||||||
toString = "()";
|
toString = "()";
|
||||||
|
@ -72,7 +72,7 @@ public class ConstructorUtilsTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Class<?>, Class<?>[]> classCache;
|
private final Map<Class<?>, Class<?>[]> classCache;
|
||||||
|
|
||||||
public ConstructorUtilsTest() {
|
public ConstructorUtilsTest() {
|
||||||
classCache = new HashMap<Class<?>, Class<?>[]>();
|
classCache = new HashMap<Class<?>, Class<?>[]>();
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class FieldUtilsTest {
|
||||||
private PublicChild publicChild;
|
private PublicChild publicChild;
|
||||||
private PubliclyShadowedChild publiclyShadowedChild;
|
private PubliclyShadowedChild publiclyShadowedChild;
|
||||||
private PrivatelyShadowedChild privatelyShadowedChild;
|
private PrivatelyShadowedChild privatelyShadowedChild;
|
||||||
private Class<?> parentClass = PublicChild.class.getSuperclass();
|
private final Class<?> parentClass = PublicChild.class.getSuperclass();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class MethodUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestBean testBean;
|
private TestBean testBean;
|
||||||
private Map<Class<?>, Class<?>[]> classCache = new HashMap<Class<?>, Class<?>[]>();
|
private final Map<Class<?>, Class<?>[]> classCache = new HashMap<Class<?>, Class<?>[]>();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
|
|
@ -24,5 +24,5 @@ class Parent implements Foo {
|
||||||
protected boolean b = false;
|
protected boolean b = false;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private double d = 0.0;
|
private final double d = 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ package org.apache.commons.lang3.reflect.testbed;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unused", "hiding" }) // deliberate re-use of variable names
|
@SuppressWarnings({ "unused", "hiding" }) // deliberate re-use of variable names
|
||||||
public class PrivatelyShadowedChild extends Parent {
|
public class PrivatelyShadowedChild extends Parent {
|
||||||
private String s = "ss";
|
private final String s = "ss";
|
||||||
private boolean b = true;
|
private final boolean b = true;
|
||||||
private int i = 1;
|
private final int i = 1;
|
||||||
private double d = 1.0;
|
private final double d = 1.0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue