You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2013/04/30 15:09:57 UTC

svn commit: r1477612 - in /commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map: AbstractReferenceMap.java ReferenceIdentityMap.java

Author: sebb
Date: Tue Apr 30 13:09:57 2013
New Revision: 1477612

URL: http://svn.apache.org/r1477612
Log:
Privatise fields

Modified:
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/ReferenceIdentityMap.java

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java?rev=1477612&r1=1477611&r2=1477612&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java Tue Apr 30 13:09:57 2013
@@ -118,17 +118,17 @@ public abstract class AbstractReferenceM
     /**
      * The reference type for keys.
      */
-    protected ReferenceStrength keyType;
+    private ReferenceStrength keyType;
 
     /**
      * The reference type for values.
      */
-    protected ReferenceStrength valueType;
+    private ReferenceStrength valueType;
 
     /**
      * Should the value be automatically purged when the associated key has been collected?
      */
-    protected boolean purgeValues;
+    private boolean purgeValues;
 
     /**
      * ReferenceQueue used to eliminate stale mappings.
@@ -591,7 +591,7 @@ public abstract class AbstractReferenceM
      */
     protected static class ReferenceEntry<K, V> extends HashEntry<K, V> {
         /** The parent map */
-        protected final AbstractReferenceMap<K, V> parent;
+        private final AbstractReferenceMap<K, V> parent;
 
         /**
          * Creates a new entry object for the ReferenceMap.
@@ -1047,4 +1047,12 @@ public abstract class AbstractReferenceM
         // do not call super.doReadObject() as code there doesn't work for reference map
     }
 
+    /**
+     * Provided protected read-only access to the key type.
+     * @param type the type to check against.
+     * @return true if keyType has the specified type
+     */
+    protected boolean isKeyType(ReferenceStrength type) {
+        return this.keyType == type;
+    }
 }

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/ReferenceIdentityMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/ReferenceIdentityMap.java?rev=1477612&r1=1477611&r2=1477612&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/ReferenceIdentityMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/ReferenceIdentityMap.java Tue Apr 30 13:09:57 2013
@@ -202,7 +202,7 @@ public class ReferenceIdentityMap<K, V> 
      */
     @Override
     protected boolean isEqualKey(final Object key1, Object key2) {
-        key2 = keyType == ReferenceStrength.HARD ? key2 : ((Reference<?>) key2).get();
+        key2 = isKeyType(ReferenceStrength.HARD) ? key2 : ((Reference<?>) key2).get();
         return key1 == key2;
     }