Skip to content
Permalink
Browse files
Make private elements final where possible.
  • Loading branch information
garydgregory committed Jan 17, 2021
1 parent 48f3889 commit 54993ac065e8773fe71fedca63541d28196c5040
Showing 77 changed files with 197 additions and 197 deletions.
@@ -33,7 +33,7 @@
{
private String className;

private Map<OgnlContext, Class> defaultMapClassMap = new HashMap<OgnlContext, Class>();
private final Map<OgnlContext, Class> defaultMapClassMap = new HashMap<OgnlContext, Class>();

public ASTMap( int id )
{
@@ -35,7 +35,7 @@ public Enumeration<?> getElements( final Object target )
{
return new Enumeration<Object>()
{
private int count = Array.getLength( target );
private final int count = Array.getLength( target );

private int index = 0;

@@ -42,7 +42,7 @@

public static final DynamicSubscript all = new DynamicSubscript( ALL );

private int flag;
private final int flag;

private DynamicSubscript( int flag )
{
@@ -34,7 +34,7 @@ public static <E> Enumeration<E> newEnumeration( Iterator<E> iterator )
return new IteratorEnumeration<E>( iterator );
}

private Iterator<T> it;
private final Iterator<T> it;

private IteratorEnumeration( Iterator<T> it )
{
@@ -29,9 +29,9 @@
*/
public class JJTOgnlParserState
{
private List<Node> nodes;
private final List<Node> nodes;

private List<Integer> marks;
private final List<Integer> marks;

private int numNodesOnStack;

@@ -35,11 +35,11 @@ public Enumeration<?> getElements( final Object target )
{
return new Enumeration<Object>()
{
private int type = OgnlOps.getNumericType( target );
private final int type = OgnlOps.getNumericType( target );

private long next = 0;

private long finish = OgnlOps.longValue( target );
private final long finish = OgnlOps.longValue( target );

public boolean hasMoreElements()
{
@@ -84,11 +84,11 @@
public class ObjectIndexedPropertyDescriptor
extends PropertyDescriptor
{
private Method indexedReadMethod;
private final Method indexedReadMethod;

private Method indexedWriteMethod;
private final Method indexedWriteMethod;

private Class<?> propertyType;
private final Class<?> propertyType;

public ObjectIndexedPropertyDescriptor( String propertyName, Class<?> propertyType, Method indexedReadMethod,
Method indexedWriteMethod )
@@ -125,9 +125,9 @@
}
}

private Stack<Class<?>> typeStack = new Stack<Class<?>>();
private final Stack<Class<?>> typeStack = new Stack<Class<?>>();

private Stack<Class<?>> accessorStack = new Stack<Class<?>>();
private final Stack<Class<?>> accessorStack = new Stack<Class<?>>();

private int localReferenceCounter = 0;

@@ -55,7 +55,7 @@
*
* @serial
*/
private Throwable reason;
private final Throwable reason;

/** Constructs an OgnlException with no message or encapsulated exception. */
public OgnlException()
@@ -27,7 +27,7 @@
*/
class PrimitiveWrapperClasses {

private Map<Class<?>, Class<?>> map = new IdentityHashMap<Class<?>, Class<?>>();
private final Map<Class<?>, Class<?>> map = new IdentityHashMap<Class<?>, Class<?>>();

PrimitiveWrapperClasses() {
map.put( Boolean.TYPE, Boolean.class );
@@ -40,7 +40,7 @@
/* ...and now you see why. The table size is used as a mask for generating hashes */
private static final int TABLE_SIZE_MASK = TABLE_SIZE - 1;

private Entry<Class<?>, V>[] table = new Entry[TABLE_SIZE];
private final Entry<Class<?>, V>[] table = new Entry[TABLE_SIZE];

private ClassCacheInspector classInspector;

@@ -29,7 +29,7 @@
public class ConcurrentHashMapCache<K, V>
implements Cache<K, V>
{
private ConcurrentHashMap<K, V> cache = new ConcurrentHashMap<K, V>();
private final ConcurrentHashMap<K, V> cache = new ConcurrentHashMap<K, V>();

private CacheEntryFactory<K, V> cacheEntryFactory;

@@ -33,7 +33,7 @@
{
private final Map<K, V> cache = new HashMap<K, V>( 512 );

private CacheEntryFactory<K, V> cacheEntryFactory;
private final CacheEntryFactory<K, V> cacheEntryFactory;

public HashMapCache( CacheEntryFactory<K, V> cacheEntryFactory )
{
@@ -25,7 +25,7 @@

public class MethodAccessEntryValue
{
private boolean isAccessible;
private final boolean isAccessible;

private boolean notPublic;

@@ -34,8 +34,8 @@

public class ConcurrentHashMapCacheTest
{
private ConcurrentHashMapCacheTest.DummyEntryFactory entryFactory=new DummyEntryFactory( );
private Cache<CacheEntry, List<Method>> cache = new ConcurrentHashMapCache<CacheEntry, List<Method>>( entryFactory );
private final ConcurrentHashMapCacheTest.DummyEntryFactory entryFactory=new DummyEntryFactory( );
private final Cache<CacheEntry, List<Method>> cache = new ConcurrentHashMapCache<CacheEntry, List<Method>>( entryFactory );


@Test
@@ -57,9 +57,9 @@ private void getMethods( CacheEntry entry )

private class CacheEntry
{
private Class<?> clazz;
private final Class<?> clazz;

private String methodName;
private final String methodName;

private CacheEntry( Class<?> clazz, String methodName )
{
@@ -37,7 +37,7 @@
*/
public class GenericMethodParameterTypeCacheTest
{
private ConcurrentHashMapCache<GenericMethodParameterTypeCacheEntry, Class<?>[]> cache =
private final ConcurrentHashMapCache<GenericMethodParameterTypeCacheEntry, Class<?>[]> cache =
new ConcurrentHashMapCache<GenericMethodParameterTypeCacheEntry, Class<?>[]>( new GenericMethodParameterTypeFactory( ) );

@Test
@@ -36,7 +36,7 @@
*/
public class MethodAccessCacheTest
{
private Cache<Method, MethodAccessEntryValue> cache =
private final Cache<Method, MethodAccessEntryValue> cache =
new ConcurrentHashMapCache<Method, MethodAccessEntryValue>( new MethodAccessCacheEntryFactory( ) );

@Test
@@ -35,8 +35,8 @@
* Time: 12:13 AM
*/
public class MethodPermCacheTest {
private SecurityManager allowAllSecurityManager = new AllowAllSecurityManager();
private SecurityManager denyAllSecurityManager = new DenyAllSecurityManager();
private final SecurityManager allowAllSecurityManager = new AllowAllSecurityManager();
private final SecurityManager denyAllSecurityManager = new DenyAllSecurityManager();

private Cache<Method, Boolean> createCache(SecurityManager securityManager) {
return new ConcurrentHashMapCache<Method, Boolean>(new MethodPermCacheEntryFactory(securityManager) );
@@ -33,7 +33,7 @@
extends OgnlTestCase
{

private static Object[][] TESTS = {
private static final Object[][] TESTS = {
// Double-valued arithmetic expressions
{ "-1d", new Double( -1 ) },
{ "+1d", new Double( 1 ) },
@@ -35,9 +35,9 @@
extends OgnlTestCase
{

private static Root ROOT = new Root();
private static final Root ROOT = new Root();

private static Object[][] TESTS =
private static final Object[][] TESTS =
{
// Array creation
{ ROOT, "new String[] { \"one\", \"two\" }", new String[] { "one", "two" } },
@@ -34,13 +34,13 @@
extends OgnlTestCase
{

private static String[] STRING_ARRAY = new String[] { "hello", "world" };
private static final String[] STRING_ARRAY = new String[] { "hello", "world" };

private static int[] INT_ARRAY = new int[] { 10, 20 };
private static final int[] INT_ARRAY = new int[] { 10, 20 };

private static Root ROOT = new Root();
private static final Root ROOT = new Root();

private static Object[][] TESTS = {
private static final Object[][] TESTS = {
// Array elements test
{ STRING_ARRAY, "length", 2 },
{ STRING_ARRAY, "#root[1]", "world" },
@@ -34,9 +34,9 @@
extends OgnlTestCase
{

private static CorrectedObject CORRECTED = new CorrectedObject();
private static final CorrectedObject CORRECTED = new CorrectedObject();

private static Object[][] TESTS = {
private static final Object[][] TESTS = {
// Methods on Class
{ CORRECTED, "getClass().getName()", CORRECTED.getClass().getName() },
{ CORRECTED, "getClass().getInterfaces()", CORRECTED.getClass().getInterfaces() },
@@ -33,9 +33,9 @@
extends OgnlTestCase
{

private static Root ROOT = new Root();
private static final Root ROOT = new Root();

private static Object[][] TESTS = {
private static final Object[][] TESTS = {
// Collection direct properties
{ Arrays.asList( "hello", "world" ), "size", 2 },
{ Arrays.asList( "hello", "world" ), "isEmpty", Boolean.FALSE },
@@ -45,9 +45,9 @@
extends ObjectPropertyAccessor
{

private static NameFactory NAME_FACTORY = new NameFactory( "ognl.PropertyAccessor", "v" );
private static final NameFactory NAME_FACTORY = new NameFactory( "ognl.PropertyAccessor", "v" );

private static Getter NotFoundGetter = new Getter()
private static final Getter NOT_FOUND_GETTER = new Getter()
{

public Object get( OgnlContext context, Object target, String propertyName )
@@ -56,7 +56,7 @@ public Object get( OgnlContext context, Object target, String propertyName )
}
};

private static Getter DefaultGetter = new Getter()
private static final Getter DEFAULT_GETTER = new Getter()
{

public Object get( OgnlContext context, Object target, String propertyName )
@@ -72,13 +72,13 @@ public Object get( OgnlContext context, Object target, String propertyName )
}
};

private static Map pools = new HashMap();
private static final Map POOLS = new HashMap();

private static Map loaders = new HashMap();
private static final Map LOADERS = new HashMap();

private static java.util.IdentityHashMap PRIMITIVE_WRAPPER_CLASSES = new IdentityHashMap();
private static final java.util.IdentityHashMap PRIMITIVE_WRAPPER_CLASSES = new IdentityHashMap();

private java.util.IdentityHashMap seenGetMethods = new java.util.IdentityHashMap();
private final java.util.IdentityHashMap seenGetMethods = new java.util.IdentityHashMap();

static
{
@@ -117,8 +117,8 @@ public static Getter generateGetter( OgnlContext context, String code )

try
{
ClassPool pool = (ClassPool) pools.get( context.getClassResolver() );
EnhancedClassLoader loader = (EnhancedClassLoader) loaders.get( context.getClassResolver() );
ClassPool pool = (ClassPool) POOLS.get( context.getClassResolver() );
EnhancedClassLoader loader = (EnhancedClassLoader) LOADERS.get( context.getClassResolver() );
CtClass newClass;
CtClass ognlContextClass;
CtClass objectClass;
@@ -133,10 +133,10 @@ public static Getter generateGetter( OgnlContext context, String code )

pool = ClassPool.getDefault();
pool.insertClassPath( new LoaderClassPath( classLoader ) );
pools.put( context.getClassResolver(), pool );
POOLS.put( context.getClassResolver(), pool );

loader = new EnhancedClassLoader( classLoader );
loaders.put( context.getClassResolver(), loader );
LOADERS.put( context.getClassResolver(), loader );
}

newClass = pool.makeClass( className );
@@ -227,12 +227,12 @@ private Getter getGetter( OgnlContext context, Object target, String propertyNam
}
else
{
propertyMap.put( propertyName, result = DefaultGetter );
propertyMap.put( propertyName, result = DEFAULT_GETTER );
}
}
else
{
propertyMap.put( propertyName, result = NotFoundGetter );
propertyMap.put( propertyName, result = NOT_FOUND_GETTER );
}
}
catch ( Exception ex )
@@ -256,7 +256,7 @@ public Object getPossibleProperty( Map context, Object target, String name )
{
Getter getter = getGetter( ognlContext, target, name );

if ( getter != NotFoundGetter )
if ( getter != NOT_FOUND_GETTER )
{
result = getter.get( ognlContext, target, name );
}
@@ -35,7 +35,7 @@
extends OgnlTestCase
{

private static Object[][] TESTS = {
private static final Object[][] TESTS = {
{ "12345", new Integer( 12345 ) },
{ "0x100", new Integer( 256 ) },
{ "0xfE", new Integer( 254 ) },
@@ -36,7 +36,7 @@

public static int nonFinalStaticVariable = 15;

private static Object[][] TESTS = { { "true", Boolean.TRUE }, { "55", Boolean.TRUE },
private static final Object[][] TESTS = { { "true", Boolean.TRUE }, { "55", Boolean.TRUE },
{ "@java.awt.Color@black", Boolean.TRUE },
{ "@org.apache.commons.ognl.test.ConstantTreeTest@nonFinalStaticVariable", Boolean.FALSE },
{ "@org.apache.commons.ognl.test.ConstantTreeTest@nonFinalStaticVariable + 10", Boolean.FALSE },
@@ -32,9 +32,9 @@
extends OgnlTestCase
{

private static Object ROOT = new Simple();
private static final Object ROOT = new Simple();

private static Object[][] TESTS = {
private static final Object[][] TESTS = {
// Naming and referring to names
{ "#root", ROOT }, // Special root reference
{ "#this", ROOT }, // Special this reference
@@ -27,7 +27,7 @@
extends Object
implements NullHandler
{
private String defaultValue;
private final String defaultValue;

/*
* =================================================================== Constructors
@@ -35,11 +35,11 @@
extends OgnlTestCase
{

private static Root ROOT = new Root();
private static final Root ROOT = new Root();

private static IndexedSetObject INDEXED_SET = new IndexedSetObject();
private static final IndexedSetObject INDEXED_SET = new IndexedSetObject();

private static Object[][] TESTS =
private static final Object[][] TESTS =
{
{ ROOT, "list[index]", ROOT.getList().get( ROOT.getIndex() ) },
{ ROOT, "list[objectIndex]", ROOT.getList().get( ROOT.getObjectIndex().intValue() ) },

0 comments on commit 54993ac

Please sign in to comment.