Privatise fields

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1477612 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2013-04-30 13:09:57 +00:00
parent 5ce18d6487
commit 35e45cc127
2 changed files with 13 additions and 5 deletions

View File

@ -118,17 +118,17 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
/**
* 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 AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
*/
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 AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
// 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;
}
}

View File

@ -202,7 +202,7 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
*/
@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;
}