commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1582522 - /commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyUtils.java
Date Thu, 27 Mar 2014 22:36:55 GMT
Author: mbenson
Date: Thu Mar 27 22:36:54 2014
New Revision: 1582522

URL: http://svn.apache.org/r1582522
Log:
unmodifiable static maps

Modified:
    commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyUtils.java

Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyUtils.java?rev=1582522&r1=1582521&r2=1582522&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyUtils.java
(original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyUtils.java
Thu Mar 27 22:36:54 2014
@@ -18,6 +18,7 @@
 package org.apache.commons.proxy2;
 
 import java.lang.reflect.Method;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -37,8 +38,8 @@ public final class ProxyUtils
 
     public static final Object[] EMPTY_ARGUMENTS = new Object[0];
     public static final Class<?>[] EMPTY_ARGUMENT_TYPES = new Class[0];
-    private static final Map<Class<?>, Class<?>> WRAPPER_CLASS_MAP = new
HashMap<Class<?>, Class<?>>();
-    private static final Map<Class<?>, Object> NULL_VALUE_MAP = new HashMap<Class<?>,
Object>();
+    private static final Map<Class<?>, Class<?>> WRAPPER_CLASS_MAP;
+    private static final Map<Class<?>, Object> NULL_VALUE_MAP;
 
     //******************************************************************************************************************
     // Static Methods
@@ -46,26 +47,30 @@ public final class ProxyUtils
 
     static
     {
-        WRAPPER_CLASS_MAP.put(Integer.TYPE, Integer.class);
-        WRAPPER_CLASS_MAP.put(Character.TYPE, Character.class);
-        WRAPPER_CLASS_MAP.put(Boolean.TYPE, Boolean.class);
-        WRAPPER_CLASS_MAP.put(Short.TYPE, Short.class);
-        WRAPPER_CLASS_MAP.put(Long.TYPE, Long.class);
-        WRAPPER_CLASS_MAP.put(Float.TYPE, Float.class);
-        WRAPPER_CLASS_MAP.put(Double.TYPE, Double.class);
-        WRAPPER_CLASS_MAP.put(Byte.TYPE, Byte.class);
+        final Map<Class<?>, Class<?>> wrappers = new HashMap<Class<?>,
Class<?>>();
+        wrappers.put(Integer.TYPE, Integer.class);
+        wrappers.put(Character.TYPE, Character.class);
+        wrappers.put(Boolean.TYPE, Boolean.class);
+        wrappers.put(Short.TYPE, Short.class);
+        wrappers.put(Long.TYPE, Long.class);
+        wrappers.put(Float.TYPE, Float.class);
+        wrappers.put(Double.TYPE, Double.class);
+        wrappers.put(Byte.TYPE, Byte.class);
+        WRAPPER_CLASS_MAP = Collections.unmodifiableMap(wrappers);
     }
 
     static
     {
-        NULL_VALUE_MAP.put(Integer.TYPE, Integer.valueOf(0));
-        NULL_VALUE_MAP.put(Long.TYPE, Long.valueOf(0));
-        NULL_VALUE_MAP.put(Short.TYPE, Short.valueOf((short) 0));
-        NULL_VALUE_MAP.put(Byte.TYPE, Byte.valueOf((byte) 0));
-        NULL_VALUE_MAP.put(Float.TYPE, Float.valueOf(0.0f));
-        NULL_VALUE_MAP.put(Double.TYPE, Double.valueOf(0.0));
-        NULL_VALUE_MAP.put(Character.TYPE, Character.valueOf((char) 0));
-        NULL_VALUE_MAP.put(Boolean.TYPE, Boolean.FALSE);
+        final Map<Class<?>, Object> nullValues = new HashMap<Class<?>,
Object>();
+        nullValues.put(Integer.TYPE, Integer.valueOf(0));
+        nullValues.put(Long.TYPE, Long.valueOf(0));
+        nullValues.put(Short.TYPE, Short.valueOf((short) 0));
+        nullValues.put(Byte.TYPE, Byte.valueOf((byte) 0));
+        nullValues.put(Float.TYPE, Float.valueOf(0.0f));
+        nullValues.put(Double.TYPE, Double.valueOf(0.0));
+        nullValues.put(Character.TYPE, Character.valueOf((char) 0));
+        nullValues.put(Boolean.TYPE, Boolean.FALSE);
+        NULL_VALUE_MAP = Collections.unmodifiableMap(nullValues);
     }
 
     /**



Mime
View raw message