You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2013/01/07 18:15:24 UTC
svn commit: r1429905 [10/26] - in /commons/proper/collections/trunk/src:
main/java/org/apache/commons/collections/
main/java/org/apache/commons/collections/bag/
main/java/org/apache/commons/collections/bidimap/
main/java/org/apache/commons/collections/...
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractHashedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractHashedMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractHashedMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractHashedMap.java Mon Jan 7 17:15:14 2013
@@ -107,7 +107,7 @@ public class AbstractHashedMap<K, V> ext
* @param threshold the threshold, must be sensible
*/
@SuppressWarnings("unchecked")
- protected AbstractHashedMap(int initialCapacity, float loadFactor, int threshold) {
+ protected AbstractHashedMap(final int initialCapacity, final float loadFactor, final int threshold) {
super();
this.loadFactor = loadFactor;
this.data = new HashEntry[initialCapacity];
@@ -122,7 +122,7 @@ public class AbstractHashedMap<K, V> ext
* @param initialCapacity the initial capacity
* @throws IllegalArgumentException if the initial capacity is negative
*/
- protected AbstractHashedMap(int initialCapacity) {
+ protected AbstractHashedMap(final int initialCapacity) {
this(initialCapacity, DEFAULT_LOAD_FACTOR);
}
@@ -136,7 +136,7 @@ public class AbstractHashedMap<K, V> ext
* @throws IllegalArgumentException if the load factor is less than or equal to zero
*/
@SuppressWarnings("unchecked")
- protected AbstractHashedMap(int initialCapacity, float loadFactor) {
+ protected AbstractHashedMap(int initialCapacity, final float loadFactor) {
super();
if (initialCapacity < 0) {
throw new IllegalArgumentException("Initial capacity must be a non negative number");
@@ -157,7 +157,7 @@ public class AbstractHashedMap<K, V> ext
* @param map the map to copy
* @throws NullPointerException if the map is null
*/
- protected AbstractHashedMap(Map<K, V> map) {
+ protected AbstractHashedMap(final Map<K, V> map) {
this(Math.max(2 * map.size(), DEFAULT_CAPACITY), DEFAULT_LOAD_FACTOR);
_putAll(map);
}
@@ -178,7 +178,7 @@ public class AbstractHashedMap<K, V> ext
@Override
public V get(Object key) {
key = convertKey(key);
- int hashCode = hash(key);
+ final int hashCode = hash(key);
HashEntry<K, V> entry = data[hashIndex(hashCode, data.length)]; // no local for hash index
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(key, entry.key)) {
@@ -219,7 +219,7 @@ public class AbstractHashedMap<K, V> ext
@Override
public boolean containsKey(Object key) {
key = convertKey(key);
- int hashCode = hash(key);
+ final int hashCode = hash(key);
HashEntry<K, V> entry = data[hashIndex(hashCode, data.length)]; // no local for hash index
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(key, entry.key)) {
@@ -237,9 +237,9 @@ public class AbstractHashedMap<K, V> ext
* @return true if the map contains the value
*/
@Override
- public boolean containsValue(Object value) {
+ public boolean containsValue(final Object value) {
if (value == null) {
- for (HashEntry<K, V> element : data) {
+ for (final HashEntry<K, V> element : data) {
HashEntry<K, V> entry = element;
while (entry != null) {
if (entry.getValue() == null) {
@@ -249,7 +249,7 @@ public class AbstractHashedMap<K, V> ext
}
}
} else {
- for (HashEntry<K, V> element : data) {
+ for (final HashEntry<K, V> element : data) {
HashEntry<K, V> entry = element;
while (entry != null) {
if (isEqualValue(value, entry.getValue())) {
@@ -271,14 +271,14 @@ public class AbstractHashedMap<K, V> ext
* @return the value previously mapped to this key, null if none
*/
@Override
- public V put(K key, V value) {
- Object convertedKey = convertKey(key);
- int hashCode = hash(convertedKey);
- int index = hashIndex(hashCode, data.length);
+ public V put(final K key, final V value) {
+ final Object convertedKey = convertKey(key);
+ final int hashCode = hash(convertedKey);
+ final int index = hashIndex(hashCode, data.length);
HashEntry<K, V> entry = data[index];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(convertedKey, entry.key)) {
- V oldValue = entry.getValue();
+ final V oldValue = entry.getValue();
updateEntry(entry, value);
return oldValue;
}
@@ -299,7 +299,7 @@ public class AbstractHashedMap<K, V> ext
* @throws NullPointerException if the map is null
*/
@Override
- public void putAll(Map<? extends K, ? extends V> map) {
+ public void putAll(final Map<? extends K, ? extends V> map) {
_putAll(map);
}
@@ -315,14 +315,14 @@ public class AbstractHashedMap<K, V> ext
* @param map the map to add
* @throws NullPointerException if the map is null
*/
- private void _putAll(Map<? extends K, ? extends V> map) {
- int mapSize = map.size();
+ private void _putAll(final Map<? extends K, ? extends V> map) {
+ final int mapSize = map.size();
if (mapSize == 0) {
return;
}
- int newSize = (int) ((size + mapSize) / loadFactor + 1);
+ final int newSize = (int) ((size + mapSize) / loadFactor + 1);
ensureCapacity(calculateNewCapacity(newSize));
- for (Map.Entry<? extends K, ? extends V> entry: map.entrySet()) {
+ for (final Map.Entry<? extends K, ? extends V> entry: map.entrySet()) {
put(entry.getKey(), entry.getValue());
}
}
@@ -336,13 +336,13 @@ public class AbstractHashedMap<K, V> ext
@Override
public V remove(Object key) {
key = convertKey(key);
- int hashCode = hash(key);
- int index = hashIndex(hashCode, data.length);
+ final int hashCode = hash(key);
+ final int index = hashIndex(hashCode, data.length);
HashEntry<K, V> entry = data[index];
HashEntry<K, V> previous = null;
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(key, entry.key)) {
- V oldValue = entry.getValue();
+ final V oldValue = entry.getValue();
removeMapping(entry, index, previous);
return oldValue;
}
@@ -359,7 +359,7 @@ public class AbstractHashedMap<K, V> ext
@Override
public void clear() {
modCount++;
- HashEntry<K, V>[] data = this.data;
+ final HashEntry<K, V>[] data = this.data;
for (int i = data.length - 1; i >= 0; i--) {
data[i] = null;
}
@@ -378,7 +378,7 @@ public class AbstractHashedMap<K, V> ext
* @param key the key convert
* @return the converted key
*/
- protected Object convertKey(Object key) {
+ protected Object convertKey(final Object key) {
return key == null ? NULL : key;
}
@@ -390,7 +390,7 @@ public class AbstractHashedMap<K, V> ext
* @param key the key to get a hash code for
* @return the hash code
*/
- protected int hash(Object key) {
+ protected int hash(final Object key) {
// same as JDK 1.4
int h = key.hashCode();
h += ~(h << 9);
@@ -409,7 +409,7 @@ public class AbstractHashedMap<K, V> ext
* @param key2 the second key extracted from the entry via <code>entry.key</code>
* @return true if equal
*/
- protected boolean isEqualKey(Object key1, Object key2) {
+ protected boolean isEqualKey(final Object key1, final Object key2) {
return key1 == key2 || key1.equals(key2);
}
@@ -422,7 +422,7 @@ public class AbstractHashedMap<K, V> ext
* @param value2 the second value extracted from the entry via <code>getValue()</code>
* @return true if equal
*/
- protected boolean isEqualValue(Object value1, Object value2) {
+ protected boolean isEqualValue(final Object value1, final Object value2) {
return value1 == value2 || value1.equals(value2);
}
@@ -435,7 +435,7 @@ public class AbstractHashedMap<K, V> ext
* @param dataSize the size of the data to pick a bucket from
* @return the bucket index
*/
- protected int hashIndex(int hashCode, int dataSize) {
+ protected int hashIndex(final int hashCode, final int dataSize) {
return hashCode & dataSize - 1;
}
@@ -452,7 +452,7 @@ public class AbstractHashedMap<K, V> ext
*/
protected HashEntry<K, V> getEntry(Object key) {
key = convertKey(key);
- int hashCode = hash(key);
+ final int hashCode = hash(key);
HashEntry<K, V> entry = data[hashIndex(hashCode, data.length)]; // no local for hash index
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(key, entry.key)) {
@@ -473,7 +473,7 @@ public class AbstractHashedMap<K, V> ext
* @param entry the entry to update
* @param newValue the new value to store
*/
- protected void updateEntry(HashEntry<K, V> entry, V newValue) {
+ protected void updateEntry(final HashEntry<K, V> entry, final V newValue) {
entry.setValue(newValue);
}
@@ -489,7 +489,7 @@ public class AbstractHashedMap<K, V> ext
* @param key the key to add
* @param value the value to add
*/
- protected void reuseEntry(HashEntry<K, V> entry, int hashIndex, int hashCode, K key, V value) {
+ protected void reuseEntry(final HashEntry<K, V> entry, final int hashIndex, final int hashCode, final K key, final V value) {
entry.next = data[hashIndex];
entry.hashCode = hashCode;
entry.key = key;
@@ -510,9 +510,9 @@ public class AbstractHashedMap<K, V> ext
* @param key the key to add
* @param value the value to add
*/
- protected void addMapping(int hashIndex, int hashCode, K key, V value) {
+ protected void addMapping(final int hashIndex, final int hashCode, final K key, final V value) {
modCount++;
- HashEntry<K, V> entry = createEntry(data[hashIndex], hashCode, key, value);
+ final HashEntry<K, V> entry = createEntry(data[hashIndex], hashCode, key, value);
addEntry(entry, hashIndex);
size++;
checkCapacity();
@@ -531,7 +531,7 @@ public class AbstractHashedMap<K, V> ext
* @param value the value to store
* @return the newly created entry
*/
- protected HashEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) {
+ protected HashEntry<K, V> createEntry(final HashEntry<K, V> next, final int hashCode, final K key, final V value) {
return new HashEntry<K, V>(next, hashCode, convertKey(key), value);
}
@@ -544,7 +544,7 @@ public class AbstractHashedMap<K, V> ext
* @param entry the entry to add
* @param hashIndex the index into the data array to store at
*/
- protected void addEntry(HashEntry<K, V> entry, int hashIndex) {
+ protected void addEntry(final HashEntry<K, V> entry, final int hashIndex) {
data[hashIndex] = entry;
}
@@ -560,7 +560,7 @@ public class AbstractHashedMap<K, V> ext
* @param hashIndex the index into the data structure
* @param previous the previous entry in the chain
*/
- protected void removeMapping(HashEntry<K, V> entry, int hashIndex, HashEntry<K, V> previous) {
+ protected void removeMapping(final HashEntry<K, V> entry, final int hashIndex, final HashEntry<K, V> previous) {
modCount++;
removeEntry(entry, hashIndex, previous);
size--;
@@ -578,7 +578,7 @@ public class AbstractHashedMap<K, V> ext
* @param hashIndex the index into the data structure
* @param previous the previous entry in the chain
*/
- protected void removeEntry(HashEntry<K, V> entry, int hashIndex, HashEntry<K, V> previous) {
+ protected void removeEntry(final HashEntry<K, V> entry, final int hashIndex, final HashEntry<K, V> previous) {
if (previous == null) {
data[hashIndex] = entry.next;
} else {
@@ -594,7 +594,7 @@ public class AbstractHashedMap<K, V> ext
*
* @param entry the entry to destroy
*/
- protected void destroyEntry(HashEntry<K, V> entry) {
+ protected void destroyEntry(final HashEntry<K, V> entry) {
entry.next = null;
entry.key = null;
entry.value = null;
@@ -608,7 +608,7 @@ public class AbstractHashedMap<K, V> ext
*/
protected void checkCapacity() {
if (size >= threshold) {
- int newCapacity = data.length * 2;
+ final int newCapacity = data.length * 2;
if (newCapacity <= MAXIMUM_CAPACITY) {
ensureCapacity(newCapacity);
}
@@ -621,8 +621,8 @@ public class AbstractHashedMap<K, V> ext
* @param newCapacity the new capacity of the array (a power of two, less or equal to max)
*/
@SuppressWarnings("unchecked")
- protected void ensureCapacity(int newCapacity) {
- int oldCapacity = data.length;
+ protected void ensureCapacity(final int newCapacity) {
+ final int oldCapacity = data.length;
if (newCapacity <= oldCapacity) {
return;
}
@@ -630,8 +630,8 @@ public class AbstractHashedMap<K, V> ext
threshold = calculateThreshold(newCapacity, loadFactor);
data = new HashEntry[newCapacity];
} else {
- HashEntry<K, V> oldEntries[] = data;
- HashEntry<K, V> newEntries[] = new HashEntry[newCapacity];
+ final HashEntry<K, V> oldEntries[] = data;
+ final HashEntry<K, V> newEntries[] = new HashEntry[newCapacity];
modCount++;
for (int i = oldCapacity - 1; i >= 0; i--) {
@@ -639,8 +639,8 @@ public class AbstractHashedMap<K, V> ext
if (entry != null) {
oldEntries[i] = null; // gc
do {
- HashEntry<K, V> next = entry.next;
- int index = hashIndex(entry.hashCode, newCapacity);
+ final HashEntry<K, V> next = entry.next;
+ final int index = hashIndex(entry.hashCode, newCapacity);
entry.next = newEntries[index];
newEntries[index] = entry;
entry = next;
@@ -659,7 +659,7 @@ public class AbstractHashedMap<K, V> ext
* @param proposedCapacity the proposed capacity
* @return the normalized new capacity
*/
- protected int calculateNewCapacity(int proposedCapacity) {
+ protected int calculateNewCapacity(final int proposedCapacity) {
int newCapacity = 1;
if (proposedCapacity > MAXIMUM_CAPACITY) {
newCapacity = MAXIMUM_CAPACITY;
@@ -682,7 +682,7 @@ public class AbstractHashedMap<K, V> ext
* @param factor the load factor
* @return the new resize threshold
*/
- protected int calculateThreshold(int newCapacity, float factor) {
+ protected int calculateThreshold(final int newCapacity, final float factor) {
return (int) (newCapacity * factor);
}
@@ -696,7 +696,7 @@ public class AbstractHashedMap<K, V> ext
* @throws NullPointerException if the entry is null
* @since 3.1
*/
- protected HashEntry<K, V> entryNext(HashEntry<K, V> entry) {
+ protected HashEntry<K, V> entryNext(final HashEntry<K, V> entry) {
return entry.next;
}
@@ -709,7 +709,7 @@ public class AbstractHashedMap<K, V> ext
* @throws NullPointerException if the entry is null
* @since 3.1
*/
- protected int entryHashCode(HashEntry<K, V> entry) {
+ protected int entryHashCode(final HashEntry<K, V> entry) {
return entry.hashCode;
}
@@ -722,7 +722,7 @@ public class AbstractHashedMap<K, V> ext
* @throws NullPointerException if the entry is null
* @since 3.1
*/
- protected K entryKey(HashEntry<K, V> entry) {
+ protected K entryKey(final HashEntry<K, V> entry) {
return entry.getKey();
}
@@ -735,7 +735,7 @@ public class AbstractHashedMap<K, V> ext
* @throws NullPointerException if the entry is null
* @since 3.1
*/
- protected V entryValue(HashEntry<K, V> entry) {
+ protected V entryValue(final HashEntry<K, V> entry) {
return entry.getValue();
}
@@ -763,7 +763,7 @@ public class AbstractHashedMap<K, V> ext
*/
protected static class HashMapIterator<K, V> extends HashIterator<K, V> implements MapIterator<K, V> {
- protected HashMapIterator(AbstractHashedMap<K, V> parent) {
+ protected HashMapIterator(final AbstractHashedMap<K, V> parent) {
super(parent);
}
@@ -772,7 +772,7 @@ public class AbstractHashedMap<K, V> ext
}
public K getKey() {
- HashEntry<K, V> current = currentEntry();
+ final HashEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID);
}
@@ -780,15 +780,15 @@ public class AbstractHashedMap<K, V> ext
}
public V getValue() {
- HashEntry<K, V> current = currentEntry();
+ final HashEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID);
}
return current.getValue();
}
- public V setValue(V value) {
- HashEntry<K, V> current = currentEntry();
+ public V setValue(final V value) {
+ final HashEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
}
@@ -832,7 +832,7 @@ public class AbstractHashedMap<K, V> ext
/** The parent map */
protected final AbstractHashedMap<K, V> parent;
- protected EntrySet(AbstractHashedMap<K, V> parent) {
+ protected EntrySet(final AbstractHashedMap<K, V> parent) {
super();
this.parent = parent;
}
@@ -848,24 +848,24 @@ public class AbstractHashedMap<K, V> ext
}
@Override
- public boolean contains(Object entry) {
+ public boolean contains(final Object entry) {
if (entry instanceof Map.Entry) {
- Map.Entry<?, ?> e = (Map.Entry<?, ?>) entry;
- Entry<K, V> match = parent.getEntry(e.getKey());
+ final Map.Entry<?, ?> e = (Map.Entry<?, ?>) entry;
+ final Entry<K, V> match = parent.getEntry(e.getKey());
return match != null && match.equals(e);
}
return false;
}
@Override
- public boolean remove(Object obj) {
+ public boolean remove(final Object obj) {
if (obj instanceof Map.Entry == false) {
return false;
}
if (contains(obj) == false) {
return false;
}
- Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
+ final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
parent.remove(entry.getKey());
return true;
}
@@ -881,7 +881,7 @@ public class AbstractHashedMap<K, V> ext
*/
protected static class EntrySetIterator<K, V> extends HashIterator<K, V> implements Iterator<Map.Entry<K, V>> {
- protected EntrySetIterator(AbstractHashedMap<K, V> parent) {
+ protected EntrySetIterator(final AbstractHashedMap<K, V> parent) {
super(parent);
}
@@ -926,7 +926,7 @@ public class AbstractHashedMap<K, V> ext
/** The parent map */
protected final AbstractHashedMap<K, ?> parent;
- protected KeySet(AbstractHashedMap<K, ?> parent) {
+ protected KeySet(final AbstractHashedMap<K, ?> parent) {
super();
this.parent = parent;
}
@@ -942,13 +942,13 @@ public class AbstractHashedMap<K, V> ext
}
@Override
- public boolean contains(Object key) {
+ public boolean contains(final Object key) {
return parent.containsKey(key);
}
@Override
- public boolean remove(Object key) {
- boolean result = parent.containsKey(key);
+ public boolean remove(final Object key) {
+ final boolean result = parent.containsKey(key);
parent.remove(key);
return result;
}
@@ -965,7 +965,7 @@ public class AbstractHashedMap<K, V> ext
protected static class KeySetIterator<K> extends HashIterator<K, Object> implements Iterator<K> {
@SuppressWarnings("unchecked")
- protected KeySetIterator(AbstractHashedMap<K, ?> parent) {
+ protected KeySetIterator(final AbstractHashedMap<K, ?> parent) {
super((AbstractHashedMap<K, Object>) parent);
}
@@ -1010,7 +1010,7 @@ public class AbstractHashedMap<K, V> ext
/** The parent map */
protected final AbstractHashedMap<?, V> parent;
- protected Values(AbstractHashedMap<?, V> parent) {
+ protected Values(final AbstractHashedMap<?, V> parent) {
super();
this.parent = parent;
}
@@ -1026,7 +1026,7 @@ public class AbstractHashedMap<K, V> ext
}
@Override
- public boolean contains(Object value) {
+ public boolean contains(final Object value) {
return parent.containsValue(value);
}
@@ -1042,7 +1042,7 @@ public class AbstractHashedMap<K, V> ext
protected static class ValuesIterator<V> extends HashIterator<Object, V> implements Iterator<V> {
@SuppressWarnings("unchecked")
- protected ValuesIterator(AbstractHashedMap<?, V> parent) {
+ protected ValuesIterator(final AbstractHashedMap<?, V> parent) {
super((AbstractHashedMap<Object, V>) parent);
}
@@ -1070,7 +1070,7 @@ public class AbstractHashedMap<K, V> ext
/** The value */
protected Object value;
- protected HashEntry(HashEntry<K, V> next, int hashCode, Object key, V value) {
+ protected HashEntry(final HashEntry<K, V> next, final int hashCode, final Object key, final V value) {
super();
this.next = next;
this.hashCode = hashCode;
@@ -1092,21 +1092,21 @@ public class AbstractHashedMap<K, V> ext
}
@SuppressWarnings("unchecked")
- public V setValue(V value) {
- Object old = this.value;
+ public V setValue(final V value) {
+ final Object old = this.value;
this.value = value;
return (V) old;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof Map.Entry == false) {
return false;
}
- Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
+ final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
return
(getKey() == null ? other.getKey() == null : getKey().equals(other.getKey())) &&
(getValue() == null ? other.getValue() == null : getValue().equals(other.getValue()));
@@ -1140,10 +1140,10 @@ public class AbstractHashedMap<K, V> ext
/** The modification count expected */
protected int expectedModCount;
- protected HashIterator(AbstractHashedMap<K, V> parent) {
+ protected HashIterator(final AbstractHashedMap<K, V> parent) {
super();
this.parent = parent;
- HashEntry<K, V>[] data = parent.data;
+ final HashEntry<K, V>[] data = parent.data;
int i = data.length;
HashEntry<K, V> next = null;
while (i > 0 && next == null) {
@@ -1162,11 +1162,11 @@ public class AbstractHashedMap<K, V> ext
if (parent.modCount != expectedModCount) {
throw new ConcurrentModificationException();
}
- HashEntry<K, V> newCurrent = next;
+ final HashEntry<K, V> newCurrent = next;
if (newCurrent == null) {
throw new NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY);
}
- HashEntry<K, V>[] data = parent.data;
+ final HashEntry<K, V>[] data = parent.data;
int i = hashIndex;
HashEntry<K, V> n = newCurrent.next;
while (n == null && i > 0) {
@@ -1223,11 +1223,11 @@ public class AbstractHashedMap<K, V> ext
*
* @param out the output stream
*/
- protected void doWriteObject(ObjectOutputStream out) throws IOException {
+ protected void doWriteObject(final ObjectOutputStream out) throws IOException {
out.writeFloat(loadFactor);
out.writeInt(data.length);
out.writeInt(size);
- for (MapIterator<K, V> it = mapIterator(); it.hasNext();) {
+ for (final MapIterator<K, V> it = mapIterator(); it.hasNext();) {
out.writeObject(it.next());
out.writeObject(it.getValue());
}
@@ -1252,16 +1252,16 @@ public class AbstractHashedMap<K, V> ext
* @param in the input stream
*/
@SuppressWarnings("unchecked")
- protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ protected void doReadObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
loadFactor = in.readFloat();
- int capacity = in.readInt();
- int size = in.readInt();
+ final int capacity = in.readInt();
+ final int size = in.readInt();
init();
threshold = calculateThreshold(capacity, loadFactor);
data = new HashEntry[capacity];
for (int i = 0; i < size; i++) {
- K key = (K) in.readObject();
- V value = (V) in.readObject();
+ final K key = (K) in.readObject();
+ final V value = (V) in.readObject();
put(key, value);
}
}
@@ -1279,7 +1279,7 @@ public class AbstractHashedMap<K, V> ext
@SuppressWarnings("unchecked")
protected AbstractHashedMap<K, V> clone() {
try {
- AbstractHashedMap<K, V> cloned = (AbstractHashedMap<K, V>) super.clone();
+ final AbstractHashedMap<K, V> cloned = (AbstractHashedMap<K, V>) super.clone();
cloned.data = new HashEntry[data.length];
cloned.entrySet = null;
cloned.keySet = null;
@@ -1289,7 +1289,7 @@ public class AbstractHashedMap<K, V> ext
cloned.init();
cloned.putAll(this);
return cloned;
- } catch (CloneNotSupportedException ex) {
+ } catch (final CloneNotSupportedException ex) {
return null; // should never happen
}
}
@@ -1301,22 +1301,22 @@ public class AbstractHashedMap<K, V> ext
* @return true if equal
*/
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof Map == false) {
return false;
}
- Map<?,?> map = (Map<?,?>) obj;
+ final Map<?,?> map = (Map<?,?>) obj;
if (map.size() != size()) {
return false;
}
- MapIterator<?,?> it = mapIterator();
+ final MapIterator<?,?> it = mapIterator();
try {
while (it.hasNext()) {
- Object key = it.next();
- Object value = it.getValue();
+ final Object key = it.next();
+ final Object value = it.getValue();
if (value == null) {
if (map.get(key) != null || map.containsKey(key) == false) {
return false;
@@ -1327,9 +1327,9 @@ public class AbstractHashedMap<K, V> ext
}
}
}
- } catch (ClassCastException ignored) {
+ } catch (final ClassCastException ignored) {
return false;
- } catch (NullPointerException ignored) {
+ } catch (final NullPointerException ignored) {
return false;
}
return true;
@@ -1343,7 +1343,7 @@ public class AbstractHashedMap<K, V> ext
@Override
public int hashCode() {
int total = 0;
- Iterator<Map.Entry<K, V>> it = createEntrySetIterator();
+ final Iterator<Map.Entry<K, V>> it = createEntrySetIterator();
while (it.hasNext()) {
total += it.next().hashCode();
}
@@ -1360,14 +1360,14 @@ public class AbstractHashedMap<K, V> ext
if (size() == 0) {
return "{}";
}
- StringBuilder buf = new StringBuilder(32 * size());
+ final StringBuilder buf = new StringBuilder(32 * size());
buf.append('{');
- MapIterator<K, V> it = mapIterator();
+ final MapIterator<K, V> it = mapIterator();
boolean hasNext = it.hasNext();
while (hasNext) {
- K key = it.next();
- V value = it.getValue();
+ final K key = it.next();
+ final V value = it.getValue();
buf.append(key == this ? "(this Map)" : key)
.append('=')
.append(value == this ? "(this Map)" : value);
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractInputCheckedMapDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractInputCheckedMapDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractInputCheckedMapDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractInputCheckedMapDecorator.java Mon Jan 7 17:15:14 2013
@@ -58,7 +58,7 @@ abstract class AbstractInputCheckedMapDe
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if map is null
*/
- protected AbstractInputCheckedMapDecorator(Map<K, V> map) {
+ protected AbstractInputCheckedMapDecorator(final Map<K, V> map) {
super(map);
}
@@ -112,7 +112,7 @@ abstract class AbstractInputCheckedMapDe
/** The parent map */
private final AbstractInputCheckedMapDecorator<K, V> parent;
- protected EntrySet(Set<Map.Entry<K, V>> set, AbstractInputCheckedMapDecorator<K, V> parent) {
+ protected EntrySet(final Set<Map.Entry<K, V>> set, final AbstractInputCheckedMapDecorator<K, V> parent) {
super(set);
this.parent = parent;
}
@@ -125,7 +125,7 @@ abstract class AbstractInputCheckedMapDe
@Override
@SuppressWarnings("unchecked")
public Object[] toArray() {
- Object[] array = collection.toArray();
+ final Object[] array = collection.toArray();
for (int i = 0; i < array.length; i++) {
array[i] = new MapEntry((Map.Entry<K, V>) array[i], parent);
}
@@ -134,7 +134,7 @@ abstract class AbstractInputCheckedMapDe
@Override
@SuppressWarnings("unchecked")
- public <T> T[] toArray(T[] array) {
+ public <T> T[] toArray(final T[] array) {
Object[] result = array;
if (array.length > 0) {
// we must create a new array to handle multi-threaded situations
@@ -168,14 +168,14 @@ abstract class AbstractInputCheckedMapDe
/** The parent map */
private final AbstractInputCheckedMapDecorator<K, V> parent;
- protected EntrySetIterator(Iterator<Map.Entry<K, V>> iterator, AbstractInputCheckedMapDecorator<K, V> parent) {
+ protected EntrySetIterator(final Iterator<Map.Entry<K, V>> iterator, final AbstractInputCheckedMapDecorator<K, V> parent) {
super(iterator);
this.parent = parent;
}
@Override
public Map.Entry<K, V> next() {
- Map.Entry<K, V> entry = iterator.next();
+ final Map.Entry<K, V> entry = iterator.next();
return new MapEntry(entry, parent);
}
}
@@ -188,7 +188,7 @@ abstract class AbstractInputCheckedMapDe
/** The parent map */
private final AbstractInputCheckedMapDecorator<K, V> parent;
- protected MapEntry(Map.Entry<K, V> entry, AbstractInputCheckedMapDecorator<K, V> parent) {
+ protected MapEntry(final Map.Entry<K, V> entry, final AbstractInputCheckedMapDecorator<K, V> parent) {
super(entry);
this.parent = parent;
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractLinkedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractLinkedMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractLinkedMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractLinkedMap.java Mon Jan 7 17:15:14 2013
@@ -78,7 +78,7 @@ public abstract class AbstractLinkedMap<
* @param loadFactor the load factor, must be > 0.0f and generally < 1.0f
* @param threshold the threshold, must be sensible
*/
- protected AbstractLinkedMap(int initialCapacity, float loadFactor, int threshold) {
+ protected AbstractLinkedMap(final int initialCapacity, final float loadFactor, final int threshold) {
super(initialCapacity, loadFactor, threshold);
}
@@ -88,7 +88,7 @@ public abstract class AbstractLinkedMap<
* @param initialCapacity the initial capacity
* @throws IllegalArgumentException if the initial capacity is negative
*/
- protected AbstractLinkedMap(int initialCapacity) {
+ protected AbstractLinkedMap(final int initialCapacity) {
super(initialCapacity);
}
@@ -101,7 +101,7 @@ public abstract class AbstractLinkedMap<
* @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
- protected AbstractLinkedMap(int initialCapacity, float loadFactor) {
+ protected AbstractLinkedMap(final int initialCapacity, final float loadFactor) {
super(initialCapacity, loadFactor);
}
@@ -111,7 +111,7 @@ public abstract class AbstractLinkedMap<
* @param map the map to copy
* @throws NullPointerException if the map is null
*/
- protected AbstractLinkedMap(Map<K, V> map) {
+ protected AbstractLinkedMap(final Map<K, V> map) {
super(map);
}
@@ -136,7 +136,7 @@ public abstract class AbstractLinkedMap<
* @return true if the map contains the value
*/
@Override
- public boolean containsValue(Object value) {
+ public boolean containsValue(final Object value) {
// override uses faster iterator
if (value == null) {
for (LinkEntry<K, V> entry = header.after; entry != header; entry = entry.after) {
@@ -196,13 +196,13 @@ public abstract class AbstractLinkedMap<
* @param key the key to get after
* @return the next key
*/
- public K nextKey(Object key) {
- LinkEntry<K, V> entry = getEntry(key);
+ public K nextKey(final Object key) {
+ final LinkEntry<K, V> entry = getEntry(key);
return entry == null || entry.after == header ? null : entry.after.getKey();
}
@Override
- protected LinkEntry<K, V> getEntry(Object key) {
+ protected LinkEntry<K, V> getEntry(final Object key) {
return (LinkEntry<K, V>) super.getEntry(key);
}
@@ -212,8 +212,8 @@ public abstract class AbstractLinkedMap<
* @param key the key to get before
* @return the previous key
*/
- public K previousKey(Object key) {
- LinkEntry<K, V> entry = getEntry(key);
+ public K previousKey(final Object key) {
+ final LinkEntry<K, V> entry = getEntry(key);
return entry == null || entry.before == header ? null : entry.before.getKey();
}
@@ -225,7 +225,7 @@ public abstract class AbstractLinkedMap<
* @return the key at the specified index
* @throws IndexOutOfBoundsException if the index is invalid
*/
- protected LinkEntry<K, V> getEntry(int index) {
+ protected LinkEntry<K, V> getEntry(final int index) {
if (index < 0) {
throw new IndexOutOfBoundsException("Index " + index + " is less than zero");
}
@@ -259,8 +259,8 @@ public abstract class AbstractLinkedMap<
* @param hashIndex the index into the data array to store at
*/
@Override
- protected void addEntry(HashEntry<K, V> entry, int hashIndex) {
- LinkEntry<K, V> link = (LinkEntry<K, V>) entry;
+ protected void addEntry(final HashEntry<K, V> entry, final int hashIndex) {
+ final LinkEntry<K, V> link = (LinkEntry<K, V>) entry;
link.after = header;
link.before = header.before;
header.before.after = link;
@@ -280,7 +280,7 @@ public abstract class AbstractLinkedMap<
* @return the newly created entry
*/
@Override
- protected LinkEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) {
+ protected LinkEntry<K, V> createEntry(final HashEntry<K, V> next, final int hashCode, final K key, final V value) {
return new LinkEntry<K, V>(next, hashCode, convertKey(key), value);
}
@@ -295,8 +295,8 @@ public abstract class AbstractLinkedMap<
* @param previous the previous entry in the chain
*/
@Override
- protected void removeEntry(HashEntry<K, V> entry, int hashIndex, HashEntry<K, V> previous) {
- LinkEntry<K, V> link = (LinkEntry<K, V>) entry;
+ protected void removeEntry(final HashEntry<K, V> entry, final int hashIndex, final HashEntry<K, V> previous) {
+ final LinkEntry<K, V> link = (LinkEntry<K, V>) entry;
link.before.after = link.after;
link.after.before = link.before;
link.after = null;
@@ -314,7 +314,7 @@ public abstract class AbstractLinkedMap<
* @throws NullPointerException if the entry is null
* @since 3.1
*/
- protected LinkEntry<K, V> entryBefore(LinkEntry<K, V> entry) {
+ protected LinkEntry<K, V> entryBefore(final LinkEntry<K, V> entry) {
return entry.before;
}
@@ -327,7 +327,7 @@ public abstract class AbstractLinkedMap<
* @throws NullPointerException if the entry is null
* @since 3.1
*/
- protected LinkEntry<K, V> entryAfter(LinkEntry<K, V> entry) {
+ protected LinkEntry<K, V> entryAfter(final LinkEntry<K, V> entry) {
return entry.after;
}
@@ -349,7 +349,7 @@ public abstract class AbstractLinkedMap<
protected static class LinkMapIterator<K, V> extends LinkIterator<K, V> implements
OrderedMapIterator<K, V>, ResettableIterator<K> {
- protected LinkMapIterator(AbstractLinkedMap<K, V> parent) {
+ protected LinkMapIterator(final AbstractLinkedMap<K, V> parent) {
super(parent);
}
@@ -362,7 +362,7 @@ public abstract class AbstractLinkedMap<
}
public K getKey() {
- LinkEntry<K, V> current = currentEntry();
+ final LinkEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID);
}
@@ -370,15 +370,15 @@ public abstract class AbstractLinkedMap<
}
public V getValue() {
- LinkEntry<K, V> current = currentEntry();
+ final LinkEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID);
}
return current.getValue();
}
- public V setValue(V value) {
- LinkEntry<K, V> current = currentEntry();
+ public V setValue(final V value) {
+ final LinkEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
}
@@ -407,7 +407,7 @@ public abstract class AbstractLinkedMap<
protected static class EntrySetIterator<K, V> extends LinkIterator<K, V> implements
OrderedIterator<Map.Entry<K, V>>, ResettableIterator<Map.Entry<K, V>> {
- protected EntrySetIterator(AbstractLinkedMap<K, V> parent) {
+ protected EntrySetIterator(final AbstractLinkedMap<K, V> parent) {
super(parent);
}
@@ -442,7 +442,7 @@ public abstract class AbstractLinkedMap<
OrderedIterator<K>, ResettableIterator<K> {
@SuppressWarnings("unchecked")
- protected KeySetIterator(AbstractLinkedMap<K, ?> parent) {
+ protected KeySetIterator(final AbstractLinkedMap<K, ?> parent) {
super((AbstractLinkedMap<K, Object>) parent);
}
@@ -477,7 +477,7 @@ public abstract class AbstractLinkedMap<
OrderedIterator<V>, ResettableIterator<V> {
@SuppressWarnings("unchecked")
- protected ValuesIterator(AbstractLinkedMap<?, V> parent) {
+ protected ValuesIterator(final AbstractLinkedMap<?, V> parent) {
super((AbstractLinkedMap<Object, V>) parent);
}
@@ -513,7 +513,7 @@ public abstract class AbstractLinkedMap<
* @param key the key
* @param value the value
*/
- protected LinkEntry(HashEntry<K, V> next, int hashCode, Object key, V value) {
+ protected LinkEntry(final HashEntry<K, V> next, final int hashCode, final Object key, final V value) {
super(next, hashCode, key, value);
}
}
@@ -532,7 +532,7 @@ public abstract class AbstractLinkedMap<
/** The modification count expected */
protected int expectedModCount;
- protected LinkIterator(AbstractLinkedMap<K, V> parent) {
+ protected LinkIterator(final AbstractLinkedMap<K, V> parent) {
super();
this.parent = parent;
this.next = parent.header.after;
@@ -563,7 +563,7 @@ public abstract class AbstractLinkedMap<
if (parent.modCount != expectedModCount) {
throw new ConcurrentModificationException();
}
- LinkEntry<K, V> previous = next.before;
+ final LinkEntry<K, V> previous = next.before;
if (previous == parent.header) {
throw new NoSuchElementException(AbstractHashedMap.NO_PREVIOUS_ENTRY);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractMapDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractMapDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractMapDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractMapDecorator.java Mon Jan 7 17:15:14 2013
@@ -57,7 +57,7 @@ public abstract class AbstractMapDecorat
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if the collection is null
*/
- protected AbstractMapDecorator(Map<K, V> map) {
+ protected AbstractMapDecorator(final Map<K, V> map) {
if (map == null) {
throw new IllegalArgumentException("Map must not be null");
}
@@ -78,11 +78,11 @@ public abstract class AbstractMapDecorat
decorated().clear();
}
- public boolean containsKey(Object key) {
+ public boolean containsKey(final Object key) {
return decorated().containsKey(key);
}
- public boolean containsValue(Object value) {
+ public boolean containsValue(final Object value) {
return decorated().containsValue(value);
}
@@ -90,7 +90,7 @@ public abstract class AbstractMapDecorat
return decorated().entrySet();
}
- public V get(Object key) {
+ public V get(final Object key) {
return decorated().get(key);
}
@@ -102,15 +102,15 @@ public abstract class AbstractMapDecorat
return decorated().keySet();
}
- public V put(K key, V value) {
+ public V put(final K key, final V value) {
return decorated().put(key, value);
}
- public void putAll(Map<? extends K, ? extends V> mapToCopy) {
+ public void putAll(final Map<? extends K, ? extends V> mapToCopy) {
decorated().putAll(mapToCopy);
}
- public V remove(Object key) {
+ public V remove(final Object key) {
return decorated().remove(key);
}
@@ -123,7 +123,7 @@ public abstract class AbstractMapDecorat
}
@Override
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if (object == this) {
return true;
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractOrderedMapDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractOrderedMapDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractOrderedMapDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractOrderedMapDecorator.java Mon Jan 7 17:15:14 2013
@@ -51,7 +51,7 @@ public abstract class AbstractOrderedMap
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if the collection is null
*/
- public AbstractOrderedMapDecorator(OrderedMap<K, V> map) {
+ public AbstractOrderedMapDecorator(final OrderedMap<K, V> map) {
super(map);
}
@@ -74,11 +74,11 @@ public abstract class AbstractOrderedMap
return decorated().lastKey();
}
- public K nextKey(K key) {
+ public K nextKey(final K key) {
return decorated().nextKey(key);
}
- public K previousKey(K key) {
+ public K previousKey(final K key) {
return decorated().previousKey(key);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java Mon Jan 7 17:15:14 2013
@@ -96,7 +96,7 @@ public abstract class AbstractReferenceM
* @return ReferenceType
* @throws IllegalArgumentException if the specified value is invalid.
*/
- public static ReferenceStrength resolve(int value) {
+ public static ReferenceStrength resolve(final int value) {
switch (value) {
case 0:
return HARD;
@@ -109,7 +109,7 @@ public abstract class AbstractReferenceM
}
}
- private ReferenceStrength(int value) {
+ private ReferenceStrength(final int value) {
this.value = value;
}
@@ -162,8 +162,8 @@ public abstract class AbstractReferenceM
* key is garbage collected
*/
protected AbstractReferenceMap(
- ReferenceStrength keyType, ReferenceStrength valueType, int capacity,
- float loadFactor, boolean purgeValues) {
+ final ReferenceStrength keyType, final ReferenceStrength valueType, final int capacity,
+ final float loadFactor, final boolean purgeValues) {
super(capacity, loadFactor);
this.keyType = keyType;
this.valueType = valueType;
@@ -208,9 +208,9 @@ public abstract class AbstractReferenceM
* @return true if the map contains the key
*/
@Override
- public boolean containsKey(Object key) {
+ public boolean containsKey(final Object key) {
purgeBeforeRead();
- Entry<K, V> entry = getEntry(key);
+ final Entry<K, V> entry = getEntry(key);
if (entry == null) {
return false;
}
@@ -224,7 +224,7 @@ public abstract class AbstractReferenceM
* @return true if the map contains the value
*/
@Override
- public boolean containsValue(Object value) {
+ public boolean containsValue(final Object value) {
purgeBeforeRead();
if (value == null) {
return false;
@@ -239,9 +239,9 @@ public abstract class AbstractReferenceM
* @return the mapped value, null if no match
*/
@Override
- public V get(Object key) {
+ public V get(final Object key) {
purgeBeforeRead();
- Entry<K, V> entry = getEntry(key);
+ final Entry<K, V> entry = getEntry(key);
if (entry == null) {
return null;
}
@@ -259,7 +259,7 @@ public abstract class AbstractReferenceM
* @throws NullPointerException if either the key or value is null
*/
@Override
- public V put(K key, V value) {
+ public V put(final K key, final V value) {
if (key == null) {
throw new NullPointerException("null keys not allowed");
}
@@ -278,7 +278,7 @@ public abstract class AbstractReferenceM
* @return the value mapped to the removed key, null if key not in map
*/
@Override
- public V remove(Object key) {
+ public V remove(final Object key) {
if (key == null) {
return null;
}
@@ -388,12 +388,12 @@ public abstract class AbstractReferenceM
*
* @param ref the reference to purge
*/
- protected void purge(Reference<?> ref) {
+ protected void purge(final Reference<?> ref) {
// The hashCode of the reference is the hashCode of the
// mapping key, even if the reference refers to the
// mapping value...
- int hash = ref.hashCode();
- int index = hashIndex(hash, data.length);
+ final int hash = ref.hashCode();
+ final int index = hashIndex(hash, data.length);
HashEntry<K, V> previous = null;
HashEntry<K, V> entry = data[index];
while (entry != null) {
@@ -420,7 +420,7 @@ public abstract class AbstractReferenceM
* @return the entry, null if no match
*/
@Override
- protected HashEntry<K, V> getEntry(Object key) {
+ protected HashEntry<K, V> getEntry(final Object key) {
if (key == null) {
return null;
}
@@ -435,7 +435,7 @@ public abstract class AbstractReferenceM
* @param value the value to get a hash code for, may be null
* @return the hash code, as per the MapEntry specification
*/
- protected int hashEntry(Object key, Object value) {
+ protected int hashEntry(final Object key, final Object value) {
return (key == null ? 0 : key.hashCode()) ^
(value == null ? 0 : value.hashCode());
}
@@ -452,7 +452,7 @@ public abstract class AbstractReferenceM
*/
@Override
@SuppressWarnings("unchecked")
- protected boolean isEqualKey(Object key1, Object key2) {
+ protected boolean isEqualKey(final Object key1, Object key2) {
key2 = keyType == ReferenceStrength.HARD ? key2 : ((Reference<K>) key2).get();
return key1 == key2 || key1.equals(key2);
}
@@ -467,7 +467,7 @@ public abstract class AbstractReferenceM
* @return the newly created entry
*/
@Override
- protected ReferenceEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) {
+ protected ReferenceEntry<K, V> createEntry(final HashEntry<K, V> next, final int hashCode, final K key, final V value) {
return new ReferenceEntry<K, V>(this, next, hashCode, key, value);
}
@@ -507,7 +507,7 @@ public abstract class AbstractReferenceM
*/
static class ReferenceEntrySet<K, V> extends EntrySet<K, V> {
- protected ReferenceEntrySet(AbstractHashedMap<K, V> parent) {
+ protected ReferenceEntrySet(final AbstractHashedMap<K, V> parent) {
super(parent);
}
@@ -517,10 +517,10 @@ public abstract class AbstractReferenceM
}
@Override
- public <T> T[] toArray(T[] arr) {
+ public <T> T[] toArray(final T[] arr) {
// special implementation to handle disappearing entries
- ArrayList<Map.Entry<K, V>> list = new ArrayList<Map.Entry<K, V>>();
- for (Map.Entry<K, V> entry : this) {
+ final ArrayList<Map.Entry<K, V>> list = new ArrayList<Map.Entry<K, V>>();
+ for (final Map.Entry<K, V> entry : this) {
list.add(new DefaultMapEntry<K, V>(entry));
}
return list.toArray(arr);
@@ -533,7 +533,7 @@ public abstract class AbstractReferenceM
*/
static class ReferenceKeySet<K> extends KeySet<K> {
- protected ReferenceKeySet(AbstractHashedMap<K, ?> parent) {
+ protected ReferenceKeySet(final AbstractHashedMap<K, ?> parent) {
super(parent);
}
@@ -543,10 +543,10 @@ public abstract class AbstractReferenceM
}
@Override
- public <T> T[] toArray(T[] arr) {
+ public <T> T[] toArray(final T[] arr) {
// special implementation to handle disappearing keys
- List<K> list = new ArrayList<K>(parent.size());
- for (K key : this) {
+ final List<K> list = new ArrayList<K>(parent.size());
+ for (final K key : this) {
list.add(key);
}
return list.toArray(arr);
@@ -559,7 +559,7 @@ public abstract class AbstractReferenceM
*/
static class ReferenceValues<V> extends Values<V> {
- protected ReferenceValues(AbstractHashedMap<?, V> parent) {
+ protected ReferenceValues(final AbstractHashedMap<?, V> parent) {
super(parent);
}
@@ -569,10 +569,10 @@ public abstract class AbstractReferenceM
}
@Override
- public <T> T[] toArray(T[] arr) {
+ public <T> T[] toArray(final T[] arr) {
// special implementation to handle disappearing values
- List<V> list = new ArrayList<V>(parent.size());
- for (V value : this) {
+ final List<V> list = new ArrayList<V>(parent.size());
+ for (final V value : this) {
list.add(value);
}
return list.toArray(arr);
@@ -601,7 +601,7 @@ public abstract class AbstractReferenceM
* @param key the key
* @param value the value
*/
- public ReferenceEntry(AbstractReferenceMap<K, V> parent, HashEntry<K, V> next, int hashCode, K key, V value) {
+ public ReferenceEntry(final AbstractReferenceMap<K, V> parent, final HashEntry<K, V> next, final int hashCode, final K key, final V value) {
super(next, hashCode, null, null);
this.parent = parent;
this.key = toReference(parent.keyType, key, hashCode);
@@ -640,8 +640,8 @@ public abstract class AbstractReferenceM
*/
@Override
@SuppressWarnings("unchecked")
- public V setValue(V obj) {
- V old = getValue();
+ public V setValue(final V obj) {
+ final V old = getValue();
if (parent.valueType != ReferenceStrength.HARD) {
((Reference<V>) value).clear();
}
@@ -659,7 +659,7 @@ public abstract class AbstractReferenceM
* @return true if equal, false if not
*/
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
@@ -667,9 +667,9 @@ public abstract class AbstractReferenceM
return false;
}
- Map.Entry<?, ?> entry = (Map.Entry<?, ?>)obj;
- Object entryKey = entry.getKey(); // convert to hard reference
- Object entryValue = entry.getValue(); // convert to hard reference
+ final Map.Entry<?, ?> entry = (Map.Entry<?, ?>)obj;
+ final Object entryKey = entry.getKey(); // convert to hard reference
+ final Object entryValue = entry.getValue(); // convert to hard reference
if (entryKey == null || entryValue == null) {
return false;
}
@@ -703,7 +703,7 @@ public abstract class AbstractReferenceM
* the referent represents a value and not a key
* @return the reference to the object
*/
- protected <T> Object toReference(ReferenceStrength type, T referent, int hash) {
+ protected <T> Object toReference(final ReferenceStrength type, final T referent, final int hash) {
if (type == ReferenceStrength.HARD) {
return referent;
}
@@ -721,7 +721,7 @@ public abstract class AbstractReferenceM
* @param ref the reference to purge
* @return true or false
*/
- boolean purge(Reference<?> ref) {
+ boolean purge(final Reference<?> ref) {
boolean r = parent.keyType != ReferenceStrength.HARD && key == ref;
r = r || parent.valueType != ReferenceStrength.HARD && value == ref;
if (r) {
@@ -768,7 +768,7 @@ public abstract class AbstractReferenceM
int expectedModCount;
- public ReferenceBaseIterator(AbstractReferenceMap<K, V> parent) {
+ public ReferenceBaseIterator(final AbstractReferenceMap<K, V> parent) {
super();
this.parent = parent;
index = parent.size() != 0 ? parent.data.length : 0;
@@ -850,7 +850,7 @@ public abstract class AbstractReferenceM
static class ReferenceEntrySetIterator<K, V>
extends ReferenceBaseIterator<K, V> implements Iterator<Map.Entry<K, V>> {
- public ReferenceEntrySetIterator(AbstractReferenceMap<K, V> parent) {
+ public ReferenceEntrySetIterator(final AbstractReferenceMap<K, V> parent) {
super(parent);
}
@@ -866,7 +866,7 @@ public abstract class AbstractReferenceM
static class ReferenceKeySetIterator<K> extends ReferenceBaseIterator<K, Object> implements Iterator<K> {
@SuppressWarnings("unchecked")
- ReferenceKeySetIterator(AbstractReferenceMap<K, ?> parent) {
+ ReferenceKeySetIterator(final AbstractReferenceMap<K, ?> parent) {
super((AbstractReferenceMap<K, Object>) parent);
}
@@ -881,7 +881,7 @@ public abstract class AbstractReferenceM
static class ReferenceValuesIterator<V> extends ReferenceBaseIterator<Object, V> implements Iterator<V> {
@SuppressWarnings("unchecked")
- ReferenceValuesIterator(AbstractReferenceMap<?, V> parent) {
+ ReferenceValuesIterator(final AbstractReferenceMap<?, V> parent) {
super((AbstractReferenceMap<Object, V>) parent);
}
@@ -895,7 +895,7 @@ public abstract class AbstractReferenceM
*/
static class ReferenceMapIterator<K, V> extends ReferenceBaseIterator<K, V> implements MapIterator<K, V> {
- protected ReferenceMapIterator(AbstractReferenceMap<K, V> parent) {
+ protected ReferenceMapIterator(final AbstractReferenceMap<K, V> parent) {
super(parent);
}
@@ -904,7 +904,7 @@ public abstract class AbstractReferenceM
}
public K getKey() {
- HashEntry<K, V> current = currentEntry();
+ final HashEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID);
}
@@ -912,15 +912,15 @@ public abstract class AbstractReferenceM
}
public V getValue() {
- HashEntry<K, V> current = currentEntry();
+ final HashEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID);
}
return current.getValue();
}
- public V setValue(V value) {
- HashEntry<K, V> current = currentEntry();
+ public V setValue(final V value) {
+ final HashEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
}
@@ -940,7 +940,7 @@ public abstract class AbstractReferenceM
/** the hashCode of the key (even if the reference points to a value) */
private final int hash;
- public SoftRef(int hash, T r, ReferenceQueue<? super T> q) {
+ public SoftRef(final int hash, final T r, final ReferenceQueue<? super T> q) {
super(r, q);
this.hash = hash;
}
@@ -958,7 +958,7 @@ public abstract class AbstractReferenceM
/** the hashCode of the key (even if the reference points to a value) */
private final int hash;
- public WeakRef(int hash, T r, ReferenceQueue<? super T> q) {
+ public WeakRef(final int hash, final T r, final ReferenceQueue<? super T> q) {
super(r, q);
this.hash = hash;
}
@@ -989,13 +989,13 @@ public abstract class AbstractReferenceM
* @param out the output stream
*/
@Override
- protected void doWriteObject(ObjectOutputStream out) throws IOException {
+ protected void doWriteObject(final ObjectOutputStream out) throws IOException {
out.writeInt(keyType.value);
out.writeInt(valueType.value);
out.writeBoolean(purgeValues);
out.writeFloat(loadFactor);
out.writeInt(data.length);
- for (MapIterator<K, V> it = mapIterator(); it.hasNext();) {
+ for (final MapIterator<K, V> it = mapIterator(); it.hasNext();) {
out.writeObject(it.next());
out.writeObject(it.getValue());
}
@@ -1022,20 +1022,20 @@ public abstract class AbstractReferenceM
*/
@Override
@SuppressWarnings("unchecked")
- protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ protected void doReadObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
this.keyType = ReferenceStrength.resolve(in.readInt());
this.valueType = ReferenceStrength.resolve(in.readInt());
this.purgeValues = in.readBoolean();
this.loadFactor = in.readFloat();
- int capacity = in.readInt();
+ final int capacity = in.readInt();
init();
data = new HashEntry[capacity];
while (true) {
- K key = (K) in.readObject();
+ final K key = (K) in.readObject();
if (key == null) {
break;
}
- V value = (V) in.readObject();
+ final V value = (V) in.readObject();
put(key, value);
}
threshold = calculateThreshold(data.length, loadFactor);
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractSortedMapDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractSortedMapDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractSortedMapDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractSortedMapDecorator.java Mon Jan 7 17:15:14 2013
@@ -61,7 +61,7 @@ public abstract class AbstractSortedMapD
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if the collection is null
*/
- public AbstractSortedMapDecorator(SortedMap<K, V> map) {
+ public AbstractSortedMapDecorator(final SortedMap<K, V> map) {
super(map);
}
@@ -88,25 +88,25 @@ public abstract class AbstractSortedMapD
return decorated().lastKey();
}
- public SortedMap<K, V> subMap(K fromKey, K toKey) {
+ public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
return decorated().subMap(fromKey, toKey);
}
- public SortedMap<K, V> headMap(K toKey) {
+ public SortedMap<K, V> headMap(final K toKey) {
return decorated().headMap(toKey);
}
- public SortedMap<K, V> tailMap(K fromKey) {
+ public SortedMap<K, V> tailMap(final K fromKey) {
return decorated().tailMap(fromKey);
}
- public K previousKey(K key) {
- SortedMap<K, V> headMap = headMap(key);
+ public K previousKey(final K key) {
+ final SortedMap<K, V> headMap = headMap(key);
return headMap.isEmpty() ? null : headMap.lastKey();
}
- public K nextKey(K key) {
- Iterator<K> it = tailMap(key).keySet().iterator();
+ public K nextKey(final K key) {
+ final Iterator<K> it = tailMap(key).keySet().iterator();
it.next();
return it.hasNext() ? it.next() : null;
}
@@ -131,7 +131,7 @@ public abstract class AbstractSortedMapD
/**
* Create a new AbstractSortedMapDecorator.SortedMapIterator.
*/
- protected SortedMapIterator(Set<Map.Entry<K, V>> entrySet) {
+ protected SortedMapIterator(final Set<Map.Entry<K, V>> entrySet) {
super(entrySet);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/CaseInsensitiveMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/CaseInsensitiveMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/CaseInsensitiveMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/CaseInsensitiveMap.java Mon Jan 7 17:15:14 2013
@@ -78,7 +78,7 @@ public class CaseInsensitiveMap<K, V> ex
* @param initialCapacity the initial capacity
* @throws IllegalArgumentException if the initial capacity is negative
*/
- public CaseInsensitiveMap(int initialCapacity) {
+ public CaseInsensitiveMap(final int initialCapacity) {
super(initialCapacity);
}
@@ -91,7 +91,7 @@ public class CaseInsensitiveMap<K, V> ex
* @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
- public CaseInsensitiveMap(int initialCapacity, float loadFactor) {
+ public CaseInsensitiveMap(final int initialCapacity, final float loadFactor) {
super(initialCapacity, loadFactor);
}
@@ -105,7 +105,7 @@ public class CaseInsensitiveMap<K, V> ex
* @param map the map to copy
* @throws NullPointerException if the map is null
*/
- public CaseInsensitiveMap(Map<K, V> map) {
+ public CaseInsensitiveMap(final Map<K, V> map) {
super(map);
}
@@ -120,9 +120,9 @@ public class CaseInsensitiveMap<K, V> ex
* @return the converted key
*/
@Override
- protected Object convertKey(Object key) {
+ protected Object convertKey(final Object key) {
if (key != null) {
- char[] chars = key.toString().toCharArray();
+ final char[] chars = key.toString().toCharArray();
for (int i = chars.length - 1; i >= 0; i--) {
chars[i] = Character.toLowerCase(Character.toUpperCase(chars[i]));
}
@@ -145,7 +145,7 @@ public class CaseInsensitiveMap<K, V> ex
/**
* Write the map out using a custom routine.
*/
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
doWriteObject(out);
}
@@ -153,7 +153,7 @@ public class CaseInsensitiveMap<K, V> ex
/**
* Read the map in using a custom routine.
*/
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
doReadObject(in);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/CompositeMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/CompositeMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/CompositeMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/CompositeMap.java Mon Jan 7 17:15:14 2013
@@ -69,7 +69,7 @@ public class CompositeMap<K, V> extends
* @throws IllegalArgumentException if there is a key collision
*/
@SuppressWarnings("unchecked")
- public CompositeMap(Map<K, V> one, Map<K, V> two) {
+ public CompositeMap(final Map<K, V> one, final Map<K, V> two) {
this(new Map[] { one, two }, null);
}
@@ -81,7 +81,7 @@ public class CompositeMap<K, V> extends
* @param mutator MapMutator to be used for mutation operations
*/
@SuppressWarnings("unchecked")
- public CompositeMap(Map<K, V> one, Map<K, V> two, MapMutator<K, V> mutator) {
+ public CompositeMap(final Map<K, V> one, final Map<K, V> two, final MapMutator<K, V> mutator) {
this(new Map[] { one, two }, mutator);
}
@@ -92,7 +92,7 @@ public class CompositeMap<K, V> extends
* @param composite the Maps to be composited
* @throws IllegalArgumentException if there is a key collision
*/
- public CompositeMap(Map<K, V>... composite) {
+ public CompositeMap(final Map<K, V>... composite) {
this(composite, null);
}
@@ -104,7 +104,7 @@ public class CompositeMap<K, V> extends
* @param mutator MapMutator to be used for mutation operations
*/
@SuppressWarnings("unchecked")
- public CompositeMap(Map<K, V>[] composite, MapMutator<K, V> mutator) {
+ public CompositeMap(final Map<K, V>[] composite, final MapMutator<K, V> mutator) {
this.mutator = mutator;
this.composite = new Map[0];
for (int i = composite.length - 1; i >= 0; --i) {
@@ -118,7 +118,7 @@ public class CompositeMap<K, V> extends
*
* @param mutator the MapMutator to be used for mutation delegation
*/
- public void setMutator(MapMutator<K, V> mutator) {
+ public void setMutator(final MapMutator<K, V> mutator) {
this.mutator = mutator;
}
@@ -130,9 +130,9 @@ public class CompositeMap<K, V> extends
* MapMutator set to handle it.
*/
@SuppressWarnings("unchecked")
- public synchronized void addComposited(Map<K, V> map) throws IllegalArgumentException {
+ public synchronized void addComposited(final Map<K, V> map) throws IllegalArgumentException {
for (int i = composite.length - 1; i >= 0; --i) {
- Collection<K> intersect = CollectionUtils.intersection(this.composite[i].keySet(), map.keySet());
+ final Collection<K> intersect = CollectionUtils.intersection(this.composite[i].keySet(), map.keySet());
if (intersect.size() != 0) {
if (this.mutator == null) {
throw new IllegalArgumentException("Key collision adding Map to CompositeMap");
@@ -140,7 +140,7 @@ public class CompositeMap<K, V> extends
this.mutator.resolveCollision(this, this.composite[i], map, intersect);
}
}
- Map<K, V>[] temp = new Map[this.composite.length + 1];
+ final Map<K, V>[] temp = new Map[this.composite.length + 1];
System.arraycopy(this.composite, 0, temp, 0, this.composite.length);
temp[temp.length - 1] = map;
this.composite = temp;
@@ -153,11 +153,11 @@ public class CompositeMap<K, V> extends
* @return The removed Map or <code>null</code> if map is not in the composite
*/
@SuppressWarnings("unchecked")
- public synchronized Map<K, V> removeComposited(Map<K, V> map) {
- int size = this.composite.length;
+ public synchronized Map<K, V> removeComposited(final Map<K, V> map) {
+ final int size = this.composite.length;
for (int i = 0; i < size; ++i) {
if (this.composite[i].equals(map)) {
- Map<K, V>[] temp = new Map[size - 1];
+ final Map<K, V>[] temp = new Map[size - 1];
System.arraycopy(this.composite, 0, temp, 0, i);
System.arraycopy(this.composite, i + 1, temp, i, size - i - 1);
this.composite = temp;
@@ -195,7 +195,7 @@ public class CompositeMap<K, V> extends
* @throws NullPointerException if the key is <tt>null</tt> and this map
* does not not permit <tt>null</tt> keys (optional).
*/
- public boolean containsKey(Object key) {
+ public boolean containsKey(final Object key) {
for (int i = this.composite.length - 1; i >= 0; --i) {
if (this.composite[i].containsKey(key)) {
return true;
@@ -220,7 +220,7 @@ public class CompositeMap<K, V> extends
* @throws NullPointerException if the value is <tt>null</tt> and this map
* does not not permit <tt>null</tt> values (optional).
*/
- public boolean containsValue(Object value) {
+ public boolean containsValue(final Object value) {
for (int i = this.composite.length - 1; i >= 0; --i) {
if (this.composite[i].containsValue(value)) {
return true;
@@ -247,7 +247,7 @@ public class CompositeMap<K, V> extends
* @return a set view of the mappings contained in this map.
*/
public Set<Map.Entry<K, V>> entrySet() {
- CompositeSet<Map.Entry<K, V>> entries = new CompositeSet<Map.Entry<K,V>>();
+ final CompositeSet<Map.Entry<K, V>> entries = new CompositeSet<Map.Entry<K,V>>();
for (int i = composite.length - 1; i >= 0; --i) {
entries.addComposited(composite[i].entrySet());
}
@@ -278,7 +278,7 @@ public class CompositeMap<K, V> extends
*
* @see #containsKey(Object)
*/
- public V get(Object key) {
+ public V get(final Object key) {
for (int i = this.composite.length - 1; i >= 0; --i) {
if (this.composite[i].containsKey(key)) {
return this.composite[i].get(key);
@@ -317,7 +317,7 @@ public class CompositeMap<K, V> extends
* @return a set view of the keys contained in this map.
*/
public Set<K> keySet() {
- CompositeSet<K> keys = new CompositeSet<K>();
+ final CompositeSet<K> keys = new CompositeSet<K>();
for (int i = this.composite.length - 1; i >= 0; --i) {
keys.addComposited(this.composite[i].keySet());
}
@@ -349,7 +349,7 @@ public class CompositeMap<K, V> extends
* keys or values, and the specified key or value is
* <tt>null</tt>.
*/
- public V put(K key, V value) {
+ public V put(final K key, final V value) {
if (this.mutator == null) {
throw new UnsupportedOperationException("No mutator specified");
}
@@ -378,7 +378,7 @@ public class CompositeMap<K, V> extends
* this map does not permit <tt>null</tt> keys or values, and the
* specified map contains <tt>null</tt> keys or values.
*/
- public void putAll(Map<? extends K, ? extends V> map) {
+ public void putAll(final Map<? extends K, ? extends V> map) {
if (this.mutator == null) {
throw new UnsupportedOperationException("No mutator specified");
}
@@ -410,7 +410,7 @@ public class CompositeMap<K, V> extends
* @throws UnsupportedOperationException if the <tt>remove</tt> method is
* not supported by the composited map containing the key
*/
- public V remove(Object key) {
+ public V remove(final Object key) {
for (int i = this.composite.length - 1; i >= 0; --i) {
if (this.composite[i].containsKey(key)) {
return this.composite[i].remove(key);
@@ -448,7 +448,7 @@ public class CompositeMap<K, V> extends
* @return a collection view of the values contained in this map.
*/
public Collection<V> values() {
- CompositeCollection<V> values = new CompositeCollection<V>();
+ final CompositeCollection<V> values = new CompositeCollection<V>();
for (int i = composite.length - 1; i >= 0; --i) {
values.addComposited(composite[i].values());
}
@@ -462,9 +462,9 @@ public class CompositeMap<K, V> extends
* @return true if the maps are equal
*/
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj instanceof Map) {
- Map<?, ?> map = (Map<?, ?>) obj;
+ final Map<?, ?> map = (Map<?, ?>) obj;
return this.entrySet().equals(map.entrySet());
}
return false;
@@ -477,7 +477,7 @@ public class CompositeMap<K, V> extends
@Override
public int hashCode() {
int code = 0;
- for (Map.Entry<K, V> entry : entrySet()) {
+ for (final Map.Entry<K, V> entry : entrySet()) {
code += entry.hashCode();
}
return code;
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/DefaultedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/DefaultedMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/DefaultedMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/DefaultedMap.java Mon Jan 7 17:15:14 2013
@@ -82,7 +82,7 @@ public class DefaultedMap<K, V> extends
* @return a new defaulting map
* @throws IllegalArgumentException if map is null
*/
- public static <K, V> DefaultedMap<K, V> defaultedMap(Map<K, V> map, V defaultValue) {
+ public static <K, V> DefaultedMap<K, V> defaultedMap(final Map<K, V> map, final V defaultValue) {
return new DefaultedMap<K, V>(map, ConstantTransformer.constantTransformer(defaultValue));
}
@@ -99,7 +99,7 @@ public class DefaultedMap<K, V> extends
* @return a new defaulting map
* @throws IllegalArgumentException if map or factory is null
*/
- public static <K, V> DefaultedMap<K, V> defaultedMap(Map<K, V> map, Factory<? extends V> factory) {
+ public static <K, V> DefaultedMap<K, V> defaultedMap(final Map<K, V> map, final Factory<? extends V> factory) {
if (factory == null) {
throw new IllegalArgumentException("Factory must not be null");
}
@@ -120,7 +120,7 @@ public class DefaultedMap<K, V> extends
* @return a new defaulting map
* @throws IllegalArgumentException if map or factory is null
*/
- public static <K, V> Map<K, V> defaultedMap(Map<K, V> map, Transformer<? super K, ? extends V> transformer) {
+ public static <K, V> Map<K, V> defaultedMap(final Map<K, V> map, final Transformer<? super K, ? extends V> transformer) {
if (transformer == null) {
throw new IllegalArgumentException("Transformer must not be null");
}
@@ -137,7 +137,7 @@ public class DefaultedMap<K, V> extends
*
* @param defaultValue the default value to return when the key is not found
*/
- public DefaultedMap(V defaultValue) {
+ public DefaultedMap(final V defaultValue) {
this(ConstantTransformer.constantTransformer(defaultValue));
}
@@ -146,7 +146,7 @@ public class DefaultedMap<K, V> extends
*
* @param defaultValueTransformer transformer to use to generate missing values.
*/
- public DefaultedMap(Transformer<? super K, ? extends V> defaultValueTransformer) {
+ public DefaultedMap(final Transformer<? super K, ? extends V> defaultValueTransformer) {
this(new HashMap<K, V>(), defaultValueTransformer);
}
@@ -157,7 +157,7 @@ public class DefaultedMap<K, V> extends
* @param defaultValueTransformer the value transformer to use
* @throws IllegalArgumentException if map or transformer is null
*/
- protected DefaultedMap(Map<K, V> map, Transformer<? super K, ? extends V> defaultValueTransformer) {
+ protected DefaultedMap(final Map<K, V> map, final Transformer<? super K, ? extends V> defaultValueTransformer) {
super(map);
if (defaultValueTransformer == null) {
throw new IllegalArgumentException("transformer must not be null");
@@ -172,7 +172,7 @@ public class DefaultedMap<K, V> extends
* @param out the output stream
* @throws IOException
*/
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(map);
}
@@ -185,7 +185,7 @@ public class DefaultedMap<K, V> extends
* @throws ClassNotFoundException
*/
@SuppressWarnings("unchecked")
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
map = (Map<K, V>) in.readObject();
}
@@ -193,7 +193,7 @@ public class DefaultedMap<K, V> extends
//-----------------------------------------------------------------------
@Override
@SuppressWarnings("unchecked")
- public V get(Object key) {
+ public V get(final Object key) {
// create value for key if key is not currently in the map
if (map.containsKey(key) == false) {
return value.transform((K) key);
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/EntrySetToMapIteratorAdapter.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/EntrySetToMapIteratorAdapter.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/EntrySetToMapIteratorAdapter.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/EntrySetToMapIteratorAdapter.java Mon Jan 7 17:15:14 2013
@@ -42,7 +42,7 @@ public class EntrySetToMapIteratorAdapte
/**
* Create a new EntrySetToMapIteratorAdapter.
*/
- public EntrySetToMapIteratorAdapter(Set<Map.Entry<K, V>> entrySet) {
+ public EntrySetToMapIteratorAdapter(final Set<Map.Entry<K, V>> entrySet) {
this.entrySet = entrySet;
reset();
}
@@ -64,7 +64,7 @@ public class EntrySetToMapIteratorAdapte
/**
* {@inheritDoc}
*/
- public V setValue(V value) {
+ public V setValue(final V value) {
return current().setValue(value);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/FixedSizeMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/FixedSizeMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/FixedSizeMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/FixedSizeMap.java Mon Jan 7 17:15:14 2013
@@ -68,7 +68,7 @@ public class FixedSizeMap<K, V>
* @return a new fixed size map
* @throws IllegalArgumentException if map is null
*/
- public static <K, V> FixedSizeMap<K, V> fixedSizeMap(Map<K, V> map) {
+ public static <K, V> FixedSizeMap<K, V> fixedSizeMap(final Map<K, V> map) {
return new FixedSizeMap<K, V>(map);
}
@@ -79,7 +79,7 @@ public class FixedSizeMap<K, V>
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if map is null
*/
- protected FixedSizeMap(Map<K, V> map) {
+ protected FixedSizeMap(final Map<K, V> map) {
super(map);
}
@@ -91,7 +91,7 @@ public class FixedSizeMap<K, V>
* @throws IOException
* @since 3.1
*/
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(map);
}
@@ -105,14 +105,14 @@ public class FixedSizeMap<K, V>
* @since 3.1
*/
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
map = (Map<K, V>) in.readObject(); // (1)
}
//-----------------------------------------------------------------------
@Override
- public V put(K key, V value) {
+ public V put(final K key, final V value) {
if (map.containsKey(key) == false) {
throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
}
@@ -120,8 +120,8 @@ public class FixedSizeMap<K, V>
}
@Override
- public void putAll(Map<? extends K, ? extends V> mapToCopy) {
- for (K key : mapToCopy.keySet()) {
+ public void putAll(final Map<? extends K, ? extends V> mapToCopy) {
+ for (final K key : mapToCopy.keySet()) {
if (!containsKey(key)) {
throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
}
@@ -135,26 +135,26 @@ public class FixedSizeMap<K, V>
}
@Override
- public V remove(Object key) {
+ public V remove(final Object key) {
throw new UnsupportedOperationException("Map is fixed size");
}
@Override
public Set<Map.Entry<K, V>> entrySet() {
- Set<Map.Entry<K, V>> set = map.entrySet();
+ final Set<Map.Entry<K, V>> set = map.entrySet();
// unmodifiable set will still allow modification via Map.Entry objects
return UnmodifiableSet.unmodifiableSet(set);
}
@Override
public Set<K> keySet() {
- Set<K> set = map.keySet();
+ final Set<K> set = map.keySet();
return UnmodifiableSet.unmodifiableSet(set);
}
@Override
public Collection<V> values() {
- Collection<V> coll = map.values();
+ final Collection<V> coll = map.values();
return UnmodifiableCollection.unmodifiableCollection(coll);
}