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 [11/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/FixedSizeSortedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/FixedSizeSortedMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/FixedSizeSortedMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/FixedSizeSortedMap.java Mon Jan 7 17:15:14 2013
@@ -70,7 +70,7 @@ public class FixedSizeSortedMap<K, V>
* @return a new fixed size sorted map
* @throws IllegalArgumentException if map is null
*/
- public static <K, V> FixedSizeSortedMap<K, V> fixedSizeSortedMap(SortedMap<K, V> map) {
+ public static <K, V> FixedSizeSortedMap<K, V> fixedSizeSortedMap(final SortedMap<K, V> map) {
return new FixedSizeSortedMap<K, V>(map);
}
@@ -81,7 +81,7 @@ public class FixedSizeSortedMap<K, V>
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if map is null
*/
- protected FixedSizeSortedMap(SortedMap<K, V> map) {
+ protected FixedSizeSortedMap(final SortedMap<K, V> map) {
super(map);
}
@@ -98,7 +98,7 @@ public class FixedSizeSortedMap<K, V>
/**
* 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();
out.writeObject(map);
}
@@ -107,14 +107,14 @@ public class FixedSizeSortedMap<K, V>
* Read the map in using a custom routine.
*/
@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");
}
@@ -122,7 +122,7 @@ public class FixedSizeSortedMap<K, V>
}
@Override
- public void putAll(Map<? extends K, ? extends V> mapToCopy) {
+ public void putAll(final Map<? extends K, ? extends V> mapToCopy) {
if (CollectionUtils.isSubCollection(mapToCopy.keySet(), keySet())) {
throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
}
@@ -135,7 +135,7 @@ public class FixedSizeSortedMap<K, V>
}
@Override
- public V remove(Object key) {
+ public V remove(final Object key) {
throw new UnsupportedOperationException("Map is fixed size");
}
@@ -156,17 +156,17 @@ public class FixedSizeSortedMap<K, V>
//-----------------------------------------------------------------------
@Override
- public SortedMap<K, V> subMap(K fromKey, K toKey) {
+ public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
return new FixedSizeSortedMap<K, V>(getSortedMap().subMap(fromKey, toKey));
}
@Override
- public SortedMap<K, V> headMap(K toKey) {
+ public SortedMap<K, V> headMap(final K toKey) {
return new FixedSizeSortedMap<K, V>(getSortedMap().headMap(toKey));
}
@Override
- public SortedMap<K, V> tailMap(K fromKey) {
+ public SortedMap<K, V> tailMap(final K fromKey) {
return new FixedSizeSortedMap<K, V>(getSortedMap().tailMap(fromKey));
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/Flat3Map.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/Flat3Map.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/Flat3Map.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/Flat3Map.java Mon Jan 7 17:15:14 2013
@@ -111,7 +111,7 @@ public class Flat3Map<K, V> implements I
* @param map the map to copy
* @throws NullPointerException if the map is null
*/
- public Flat3Map(Map<? extends K, ? extends V> map) {
+ public Flat3Map(final Map<? extends K, ? extends V> map) {
super();
putAll(map);
}
@@ -123,7 +123,7 @@ public class Flat3Map<K, V> implements I
* @param key the key
* @return the mapped value, null if no match
*/
- public V get(Object key) {
+ public V get(final Object key) {
if (delegateMap != null) {
return delegateMap.get(key);
}
@@ -145,7 +145,7 @@ public class Flat3Map<K, V> implements I
}
} else {
if (size > 0) {
- int hashCode = key.hashCode();
+ final int hashCode = key.hashCode();
switch (size) {
// drop through
case 3:
@@ -194,7 +194,7 @@ public class Flat3Map<K, V> implements I
* @param key the key to search for
* @return true if the map contains the key
*/
- public boolean containsKey(Object key) {
+ public boolean containsKey(final Object key) {
if (delegateMap != null) {
return delegateMap.containsKey(key);
}
@@ -215,7 +215,7 @@ public class Flat3Map<K, V> implements I
}
} else {
if (size > 0) {
- int hashCode = key.hashCode();
+ final int hashCode = key.hashCode();
switch (size) { // drop through
case 3:
if (hash3 == hashCode && key.equals(key3)) {
@@ -241,7 +241,7 @@ public class Flat3Map<K, V> implements I
* @param value the value to search for
* @return true if the map contains the key
*/
- public boolean containsValue(Object value) {
+ public boolean containsValue(final Object value) {
if (delegateMap != null) {
return delegateMap.containsValue(value);
}
@@ -287,7 +287,7 @@ public class Flat3Map<K, V> implements I
* @param value the value to add
* @return the value previously mapped to this key, null if none
*/
- public V put(K key, V value) {
+ public V put(final K key, final V value) {
if (delegateMap != null) {
return delegateMap.put(key, value);
}
@@ -296,42 +296,42 @@ public class Flat3Map<K, V> implements I
switch (size) { // drop through
case 3:
if (key3 == null) {
- V old = value3;
+ final V old = value3;
value3 = value;
return old;
}
case 2:
if (key2 == null) {
- V old = value2;
+ final V old = value2;
value2 = value;
return old;
}
case 1:
if (key1 == null) {
- V old = value1;
+ final V old = value1;
value1 = value;
return old;
}
}
} else {
if (size > 0) {
- int hashCode = key.hashCode();
+ final int hashCode = key.hashCode();
switch (size) { // drop through
case 3:
if (hash3 == hashCode && key.equals(key3)) {
- V old = value3;
+ final V old = value3;
value3 = value;
return old;
}
case 2:
if (hash2 == hashCode && key.equals(key2)) {
- V old = value2;
+ final V old = value2;
value2 = value;
return old;
}
case 1:
if (hash1 == hashCode && key.equals(key1)) {
- V old = value1;
+ final V old = value1;
value1 = value;
return old;
}
@@ -371,8 +371,8 @@ public class Flat3Map<K, V> implements I
* @param map the map to add
* @throws NullPointerException if the map is null
*/
- public void putAll(Map<? extends K, ? extends V> map) {
- int size = map.size();
+ public void putAll(final Map<? extends K, ? extends V> map) {
+ final int size = map.size();
if (size == 0) {
return;
}
@@ -381,7 +381,7 @@ public class Flat3Map<K, V> implements I
return;
}
if (size < 4) {
- 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());
}
} else {
@@ -430,7 +430,7 @@ public class Flat3Map<K, V> implements I
* @param key the mapping to remove
* @return the value mapped to the removed key, null if key not in map
*/
- public V remove(Object key) {
+ public V remove(final Object key) {
if (delegateMap != null) {
return delegateMap.remove(key);
}
@@ -441,7 +441,7 @@ public class Flat3Map<K, V> implements I
switch (size) { // drop through
case 3:
if (key3 == null) {
- V old = value3;
+ final V old = value3;
hash3 = 0;
key3 = null;
value3 = null;
@@ -449,7 +449,7 @@ public class Flat3Map<K, V> implements I
return old;
}
if (key2 == null) {
- V old = value2;
+ final V old = value2;
hash2 = hash3;
key2 = key3;
value2 = value3;
@@ -460,7 +460,7 @@ public class Flat3Map<K, V> implements I
return old;
}
if (key1 == null) {
- V old = value1;
+ final V old = value1;
hash1 = hash3;
key1 = key3;
value1 = value3;
@@ -473,7 +473,7 @@ public class Flat3Map<K, V> implements I
return null;
case 2:
if (key2 == null) {
- V old = value2;
+ final V old = value2;
hash2 = 0;
key2 = null;
value2 = null;
@@ -481,7 +481,7 @@ public class Flat3Map<K, V> implements I
return old;
}
if (key1 == null) {
- V old = value1;
+ final V old = value1;
hash1 = hash2;
key1 = key2;
value1 = value2;
@@ -494,7 +494,7 @@ public class Flat3Map<K, V> implements I
return null;
case 1:
if (key1 == null) {
- V old = value1;
+ final V old = value1;
hash1 = 0;
key1 = null;
value1 = null;
@@ -504,11 +504,11 @@ public class Flat3Map<K, V> implements I
}
} else {
if (size > 0) {
- int hashCode = key.hashCode();
+ final int hashCode = key.hashCode();
switch (size) { // drop through
case 3:
if (hash3 == hashCode && key.equals(key3)) {
- V old = value3;
+ final V old = value3;
hash3 = 0;
key3 = null;
value3 = null;
@@ -516,7 +516,7 @@ public class Flat3Map<K, V> implements I
return old;
}
if (hash2 == hashCode && key.equals(key2)) {
- V old = value2;
+ final V old = value2;
hash2 = hash3;
key2 = key3;
value2 = value3;
@@ -527,7 +527,7 @@ public class Flat3Map<K, V> implements I
return old;
}
if (hash1 == hashCode && key.equals(key1)) {
- V old = value1;
+ final V old = value1;
hash1 = hash3;
key1 = key3;
value1 = value3;
@@ -540,7 +540,7 @@ public class Flat3Map<K, V> implements I
return null;
case 2:
if (hash2 == hashCode && key.equals(key2)) {
- V old = value2;
+ final V old = value2;
hash2 = 0;
key2 = null;
value2 = null;
@@ -548,7 +548,7 @@ public class Flat3Map<K, V> implements I
return old;
}
if (hash1 == hashCode && key.equals(key1)) {
- V old = value1;
+ final V old = value1;
hash1 = hash2;
key1 = key2;
value1 = value2;
@@ -561,7 +561,7 @@ public class Flat3Map<K, V> implements I
return null;
case 1:
if (hash1 == hashCode && key.equals(key1)) {
- V old = value1;
+ final V old = value1;
hash1 = 0;
key1 = null;
value1 = null;
@@ -620,7 +620,7 @@ public class Flat3Map<K, V> implements I
private int nextIndex = 0;
private boolean canRemove = false;
- FlatMapIterator(Flat3Map<K, V> parent) {
+ FlatMapIterator(final Flat3Map<K, V> parent) {
super();
this.parent = parent;
}
@@ -677,11 +677,11 @@ public class Flat3Map<K, V> implements I
throw new IllegalStateException("Invalid map index");
}
- public V setValue(V value) {
+ public V setValue(final V value) {
if (canRemove == false) {
throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
}
- V old = getValue();
+ final V old = getValue();
switch (nextIndex) {
case 3:
parent.value3 = value;
@@ -732,7 +732,7 @@ public class Flat3Map<K, V> implements I
static class EntrySet<K, V> extends AbstractSet<Map.Entry<K, V>> {
private final Flat3Map<K, V> parent;
- EntrySet(Flat3Map<K, V> parent) {
+ EntrySet(final Flat3Map<K, V> parent) {
super();
this.parent = parent;
}
@@ -748,13 +748,13 @@ public class Flat3Map<K, V> implements I
}
@Override
- public boolean remove(Object obj) {
+ public boolean remove(final Object obj) {
if (obj instanceof Map.Entry == false) {
return false;
}
- Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
- Object key = entry.getKey();
- boolean result = parent.containsKey(key);
+ final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
+ final Object key = entry.getKey();
+ final boolean result = parent.containsKey(key);
parent.remove(key);
return result;
}
@@ -779,7 +779,7 @@ public class Flat3Map<K, V> implements I
/**
* Create a new Flat3Map.EntryIterator.
*/
- public EntryIterator(Flat3Map<K, V> parent) {
+ public EntryIterator(final Flat3Map<K, V> parent) {
this.parent = parent;
}
@@ -835,11 +835,11 @@ public class Flat3Map<K, V> implements I
throw new IllegalStateException("Invalid map index");
}
- public V setValue(V value) {
+ public V setValue(final V value) {
if (canRemove == false) {
throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
}
- V old = getValue();
+ final V old = getValue();
switch (nextIndex) {
case 3:
parent.value3 = value;
@@ -860,7 +860,7 @@ public class Flat3Map<K, V> implements I
*/
static class EntrySetIterator<K, V> extends EntryIterator<K, V> implements Iterator<Map.Entry<K, V>> {
- EntrySetIterator(Flat3Map<K, V> parent) {
+ EntrySetIterator(final Flat3Map<K, V> parent) {
super(parent);
}
@@ -869,16 +869,16 @@ public class Flat3Map<K, V> implements I
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (canRemove == false) {
return false;
}
if (obj instanceof Map.Entry == false) {
return false;
}
- Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
- Object key = getKey();
- Object value = getValue();
+ final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
+ final Object key = getKey();
+ final Object value = getValue();
return (key == null ? other.getKey() == null : key.equals(other.getKey())) &&
(value == null ? other.getValue() == null : value.equals(other.getValue()));
}
@@ -888,8 +888,8 @@ public class Flat3Map<K, V> implements I
if (canRemove == false) {
return 0;
}
- Object key = getKey();
- Object value = getValue();
+ final Object key = getKey();
+ final Object value = getValue();
return (key == null ? 0 : key.hashCode()) ^
(value == null ? 0 : value.hashCode());
}
@@ -923,7 +923,7 @@ public class Flat3Map<K, V> implements I
static class KeySet<K> extends AbstractSet<K> {
private final Flat3Map<K, ?> parent;
- KeySet(Flat3Map<K, ?> parent) {
+ KeySet(final Flat3Map<K, ?> parent) {
super();
this.parent = parent;
}
@@ -939,13 +939,13 @@ public class Flat3Map<K, V> implements I
}
@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;
}
@@ -968,7 +968,7 @@ public class Flat3Map<K, V> implements I
static class KeySetIterator<K> extends EntryIterator<K, Object> implements Iterator<K>{
@SuppressWarnings("unchecked")
- KeySetIterator(Flat3Map<K, ?> parent) {
+ KeySetIterator(final Flat3Map<K, ?> parent) {
super((Flat3Map<K, Object>) parent);
}
@@ -998,7 +998,7 @@ public class Flat3Map<K, V> implements I
static class Values<V> extends AbstractCollection<V> {
private final Flat3Map<?, V> parent;
- Values(Flat3Map<?, V> parent) {
+ Values(final Flat3Map<?, V> parent) {
super();
this.parent = parent;
}
@@ -1014,7 +1014,7 @@ public class Flat3Map<K, V> implements I
}
@Override
- public boolean contains(Object value) {
+ public boolean contains(final Object value) {
return parent.containsValue(value);
}
@@ -1036,7 +1036,7 @@ public class Flat3Map<K, V> implements I
static class ValuesIterator<V> extends EntryIterator<Object, V> implements Iterator<V> {
@SuppressWarnings("unchecked")
- ValuesIterator(Flat3Map<?, V> parent) {
+ ValuesIterator(final Flat3Map<?, V> parent) {
super((Flat3Map<Object, V>) parent);
}
@@ -1050,10 +1050,10 @@ public class Flat3Map<K, V> implements I
/**
* 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();
out.writeInt(size());
- for (MapIterator<?, ?> it = mapIterator(); it.hasNext();) {
+ for (final MapIterator<?, ?> it = mapIterator(); it.hasNext();) {
out.writeObject(it.next()); // key
out.writeObject(it.getValue()); // value
}
@@ -1063,9 +1063,9 @@ public class Flat3Map<K, V> implements I
* Read the map in using a custom routine.
*/
@SuppressWarnings("unchecked")
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
- int count = in.readInt();
+ final int count = in.readInt();
if (count > 3) {
delegateMap = createDelegateMap();
}
@@ -1085,12 +1085,12 @@ public class Flat3Map<K, V> implements I
@SuppressWarnings("unchecked")
public Flat3Map<K, V> clone() {
try {
- Flat3Map<K, V> cloned = (Flat3Map<K, V>) super.clone();
+ final Flat3Map<K, V> cloned = (Flat3Map<K, V>) super.clone();
if (cloned.delegateMap != null) {
cloned.delegateMap = cloned.delegateMap.clone();
}
return cloned;
- } catch (CloneNotSupportedException ex) {
+ } catch (final CloneNotSupportedException ex) {
throw new InternalError();
}
}
@@ -1102,7 +1102,7 @@ public class Flat3Map<K, V> implements I
* @return true if equal
*/
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
@@ -1112,7 +1112,7 @@ public class Flat3Map<K, V> implements I
if (obj instanceof Map == false) {
return false;
}
- Map<?, ?> other = (Map<?, ?>) obj;
+ final Map<?, ?> other = (Map<?, ?>) obj;
if (size != other.size()) {
return false;
}
@@ -1183,7 +1183,7 @@ public class Flat3Map<K, V> implements I
if (size == 0) {
return "{}";
}
- StringBuilder buf = new StringBuilder(128);
+ final StringBuilder buf = new StringBuilder(128);
buf.append('{');
switch (size) { // drop through
case 3:
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/HashedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/HashedMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/HashedMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/HashedMap.java Mon Jan 7 17:15:14 2013
@@ -58,7 +58,7 @@ public class HashedMap<K, V>
* @param initialCapacity the initial capacity
* @throws IllegalArgumentException if the initial capacity is negative
*/
- public HashedMap(int initialCapacity) {
+ public HashedMap(final int initialCapacity) {
super(initialCapacity);
}
@@ -71,7 +71,7 @@ public class HashedMap<K, V>
* @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
- public HashedMap(int initialCapacity, float loadFactor) {
+ public HashedMap(final int initialCapacity, final float loadFactor) {
super(initialCapacity, loadFactor);
}
@@ -81,7 +81,7 @@ public class HashedMap<K, V>
* @param map the map to copy
* @throws NullPointerException if the map is null
*/
- public HashedMap(Map<K, V> map) {
+ public HashedMap(final Map<K, V> map) {
super(map);
}
@@ -99,7 +99,7 @@ public class HashedMap<K, V>
/**
* 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);
}
@@ -107,7 +107,7 @@ public class HashedMap<K, V>
/**
* 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/IdentityMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/IdentityMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/IdentityMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/IdentityMap.java Mon Jan 7 17:15:14 2013
@@ -59,7 +59,7 @@ public class IdentityMap<K, V>
* @param initialCapacity the initial capacity
* @throws IllegalArgumentException if the initial capacity is negative
*/
- public IdentityMap(int initialCapacity) {
+ public IdentityMap(final int initialCapacity) {
super(initialCapacity);
}
@@ -72,7 +72,7 @@ public class IdentityMap<K, V>
* @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
- public IdentityMap(int initialCapacity, float loadFactor) {
+ public IdentityMap(final int initialCapacity, final float loadFactor) {
super(initialCapacity, loadFactor);
}
@@ -82,7 +82,7 @@ public class IdentityMap<K, V>
* @param map the map to copy
* @throws NullPointerException if the map is null
*/
- public IdentityMap(Map<K, V> map) {
+ public IdentityMap(final Map<K, V> map) {
super(map);
}
@@ -95,7 +95,7 @@ public class IdentityMap<K, V>
* @return the hash code
*/
@Override
- protected int hash(Object key) {
+ protected int hash(final Object key) {
return System.identityHashCode(key);
}
@@ -108,7 +108,7 @@ public class IdentityMap<K, V>
* @return true if equal by identity
*/
@Override
- protected boolean isEqualKey(Object key1, Object key2) {
+ protected boolean isEqualKey(final Object key1, final Object key2) {
return key1 == key2;
}
@@ -121,7 +121,7 @@ public class IdentityMap<K, V>
* @return true if equal by identity
*/
@Override
- protected boolean isEqualValue(Object value1, Object value2) {
+ protected boolean isEqualValue(final Object value1, final Object value2) {
return value1 == value2;
}
@@ -136,7 +136,7 @@ public class IdentityMap<K, V>
* @return the newly created entry
*/
@Override
- protected IdentityEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) {
+ protected IdentityEntry<K, V> createEntry(final HashEntry<K, V> next, final int hashCode, final K key, final V value) {
return new IdentityEntry<K, V>(next, hashCode, key, value);
}
@@ -146,19 +146,19 @@ public class IdentityMap<K, V>
*/
protected static class IdentityEntry<K, V> extends HashEntry<K, V> {
- protected IdentityEntry(HashEntry<K, V> next, int hashCode, K key, V value) {
+ protected IdentityEntry(final HashEntry<K, V> next, final int hashCode, final K key, final V value) {
super(next, hashCode, key, value);
}
@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() == other.getKey() &&
getValue() == other.getValue();
@@ -185,7 +185,7 @@ public class IdentityMap<K, V>
/**
* 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);
}
@@ -193,7 +193,7 @@ public class IdentityMap<K, V>
/**
* 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/LRUMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LRUMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LRUMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LRUMap.java Mon Jan 7 17:15:14 2013
@@ -83,7 +83,7 @@ public class LRUMap<K, V>
* @param maxSize the maximum size of the map
* @throws IllegalArgumentException if the maximum size is less than one
*/
- public LRUMap(int maxSize) {
+ public LRUMap(final int maxSize) {
this(maxSize, DEFAULT_LOAD_FACTOR);
}
@@ -95,7 +95,7 @@ public class LRUMap<K, V>
* @throws IllegalArgumentException if the maximum size is less than one
* @since 3.1
*/
- public LRUMap(int maxSize, boolean scanUntilRemovable) {
+ public LRUMap(final int maxSize, final boolean scanUntilRemovable) {
this(maxSize, DEFAULT_LOAD_FACTOR, scanUntilRemovable);
}
@@ -108,7 +108,7 @@ public class LRUMap<K, V>
* @throws IllegalArgumentException if the maximum size is less than one
* @throws IllegalArgumentException if the load factor is less than zero
*/
- public LRUMap(int maxSize, float loadFactor) {
+ public LRUMap(final int maxSize, final float loadFactor) {
this(maxSize, loadFactor, false);
}
@@ -123,7 +123,7 @@ public class LRUMap<K, V>
* @throws IllegalArgumentException if the load factor is less than zero
* @since 3.1
*/
- public LRUMap(int maxSize, float loadFactor, boolean scanUntilRemovable) {
+ public LRUMap(final int maxSize, final float loadFactor, final boolean scanUntilRemovable) {
super(maxSize < 1 ? DEFAULT_CAPACITY : maxSize, loadFactor);
if (maxSize < 1) {
throw new IllegalArgumentException("LRUMap max size must be greater than 0");
@@ -141,7 +141,7 @@ public class LRUMap<K, V>
* @throws NullPointerException if the map is null
* @throws IllegalArgumentException if the map is empty
*/
- public LRUMap(Map<K, V> map) {
+ public LRUMap(final Map<K, V> map) {
this(map, false);
}
@@ -156,7 +156,7 @@ public class LRUMap<K, V>
* @throws IllegalArgumentException if the map is empty
* @since 3.1
*/
- public LRUMap(Map<K, V> map, boolean scanUntilRemovable) {
+ public LRUMap(final Map<K, V> map, final boolean scanUntilRemovable) {
this(map.size(), DEFAULT_LOAD_FACTOR, scanUntilRemovable);
putAll(map);
}
@@ -172,8 +172,8 @@ public class LRUMap<K, V>
* @return the mapped value, null if no match
*/
@Override
- public V get(Object key) {
- LinkEntry<K, V> entry = getEntry(key);
+ public V get(final Object key) {
+ final LinkEntry<K, V> entry = getEntry(key);
if (entry == null) {
return null;
}
@@ -189,7 +189,7 @@ public class LRUMap<K, V>
*
* @param entry the entry to update
*/
- protected void moveToMRU(LinkEntry<K, V> entry) {
+ protected void moveToMRU(final LinkEntry<K, V> entry) {
if (entry.after != header) {
modCount++;
// remove
@@ -221,7 +221,7 @@ public class LRUMap<K, V>
* @param newValue the new value to store
*/
@Override
- protected void updateEntry(HashEntry<K, V> entry, V newValue) {
+ protected void updateEntry(final HashEntry<K, V> entry, final V newValue) {
moveToMRU((LinkEntry<K, V>) entry); // handles modCount
entry.setValue(newValue);
}
@@ -242,7 +242,7 @@ public class LRUMap<K, V>
* @param value the value to add
*/
@Override
- 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) {
if (isFull()) {
LinkEntry<K, V> reuse = header.after;
boolean removeLRUEntry = false;
@@ -293,13 +293,13 @@ public class LRUMap<K, V>
* @param key the key to add
* @param value the value to add
*/
- protected void reuseMapping(LinkEntry<K, V> entry, int hashIndex, int hashCode, K key, V value) {
+ protected void reuseMapping(final LinkEntry<K, V> entry, final int hashIndex, final int hashCode, final K key, final V value) {
// find the entry before the entry specified in the hash table
// remember that the parameters (except the first) refer to the new entry,
// not the old one
try {
- int removeIndex = hashIndex(entry.hashCode, data.length);
- HashEntry<K, V>[] tmp = data; // may protect against some sync issues
+ final int removeIndex = hashIndex(entry.hashCode, data.length);
+ final HashEntry<K, V>[] tmp = data; // may protect against some sync issues
HashEntry<K, V> loop = tmp[removeIndex];
HashEntry<K, V> previous = null;
while (loop != entry && loop != null) {
@@ -319,7 +319,7 @@ public class LRUMap<K, V>
removeEntry(entry, removeIndex, previous);
reuseEntry(entry, hashIndex, hashCode, key, value);
addEntry(entry, hashIndex);
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
throw new IllegalStateException(
"NPE, entry=" + entry + " entryIsHeader=" + (entry==header) +
" key=" + key + " value=" + value + " size=" + size + " maxSize=" + maxSize +
@@ -362,7 +362,7 @@ public class LRUMap<K, V>
* @param entry the entry to be removed
* @return {@code true}
*/
- protected boolean removeLRU(LinkEntry<K, V> entry) {
+ protected boolean removeLRU(final LinkEntry<K, V> entry) {
return true;
}
@@ -410,7 +410,7 @@ public class LRUMap<K, V>
/**
* 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);
}
@@ -418,7 +418,7 @@ public class LRUMap<K, V>
/**
* 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);
}
@@ -427,7 +427,7 @@ public class LRUMap<K, V>
* Writes the data necessary for <code>put()</code> to work in deserialization.
*/
@Override
- protected void doWriteObject(ObjectOutputStream out) throws IOException {
+ protected void doWriteObject(final ObjectOutputStream out) throws IOException {
out.writeInt(maxSize);
super.doWriteObject(out);
}
@@ -436,7 +436,7 @@ public class LRUMap<K, V>
* Reads the data necessary for <code>put()</code> to work in the superclass.
*/
@Override
- protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ protected void doReadObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
maxSize = in.readInt();
super.doReadObject(in);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LazyMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LazyMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LazyMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LazyMap.java Mon Jan 7 17:15:14 2013
@@ -77,7 +77,7 @@ public class LazyMap<K, V> extends Abstr
* @return a new lazy map
* @throws IllegalArgumentException if map or factory is null
*/
- public static <K, V> LazyMap<K, V> lazyMap(Map<K, V> map, Factory< ? extends V> factory) {
+ public static <K, V> LazyMap<K, V> lazyMap(final Map<K, V> map, final Factory< ? extends V> factory) {
return new LazyMap<K,V>(map, factory);
}
@@ -91,7 +91,7 @@ public class LazyMap<K, V> extends Abstr
* @return a new lazy map
* @throws IllegalArgumentException if map or factory is null
*/
- public static <V, K> LazyMap<K, V> lazyMap(Map<K, V> map, Transformer<? super K, ? extends V> factory) {
+ public static <V, K> LazyMap<K, V> lazyMap(final Map<K, V> map, final Transformer<? super K, ? extends V> factory) {
return new LazyMap<K,V>(map, factory);
}
@@ -103,7 +103,7 @@ public class LazyMap<K, V> extends Abstr
* @param factory the factory to use, must not be null
* @throws IllegalArgumentException if map or factory is null
*/
- protected LazyMap(Map<K,V> map, Factory<? extends V> factory) {
+ protected LazyMap(final Map<K,V> map, final Factory<? extends V> factory) {
super(map);
if (factory == null) {
throw new IllegalArgumentException("Factory must not be null");
@@ -118,7 +118,7 @@ public class LazyMap<K, V> extends Abstr
* @param factory the factory to use, must not be null
* @throws IllegalArgumentException if map or factory is null
*/
- protected LazyMap(Map<K,V> map, Transformer<? super K, ? extends V> factory) {
+ protected LazyMap(final Map<K,V> map, final Transformer<? super K, ? extends V> factory) {
super(map);
if (factory == null) {
throw new IllegalArgumentException("Factory must not be null");
@@ -134,7 +134,7 @@ public class LazyMap<K, V> extends Abstr
* @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);
}
@@ -148,19 +148,20 @@ public class LazyMap<K, V> extends Abstr
* @since 3.1
*/
@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();
}
//-----------------------------------------------------------------------
@Override
- 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) {
@SuppressWarnings("unchecked")
+ final
K castKey = (K) key;
- V value = factory.transform(castKey);
+ final V value = factory.transform(castKey);
map.put(castKey, value);
return value;
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LazySortedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LazySortedMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LazySortedMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LazySortedMap.java Mon Jan 7 17:15:14 2013
@@ -73,7 +73,7 @@ public class LazySortedMap<K,V>
* @return a new lazy sorted map
* @throws IllegalArgumentException if map or factory is null
*/
- public static <K, V> LazySortedMap<K, V> lazySortedMap(SortedMap<K, V> map, Factory<? extends V> factory) {
+ public static <K, V> LazySortedMap<K, V> lazySortedMap(final SortedMap<K, V> map, final Factory<? extends V> factory) {
return new LazySortedMap<K,V>(map, factory);
}
@@ -87,8 +87,8 @@ public class LazySortedMap<K,V>
* @return a new lazy sorted map
* @throws IllegalArgumentException if map or factory is null
*/
- public static <K, V> LazySortedMap<K, V> lazySortedMap(SortedMap<K, V> map,
- Transformer<? super K, ? extends V> factory) {
+ public static <K, V> LazySortedMap<K, V> lazySortedMap(final SortedMap<K, V> map,
+ final Transformer<? super K, ? extends V> factory) {
return new LazySortedMap<K,V>(map, factory);
}
@@ -100,7 +100,7 @@ public class LazySortedMap<K,V>
* @param factory the factory to use, must not be null
* @throws IllegalArgumentException if map or factory is null
*/
- protected LazySortedMap(SortedMap<K,V> map, Factory<? extends V> factory) {
+ protected LazySortedMap(final SortedMap<K,V> map, final Factory<? extends V> factory) {
super(map, factory);
}
@@ -111,7 +111,7 @@ public class LazySortedMap<K,V>
* @param factory the factory to use, must not be null
* @throws IllegalArgumentException if map or factory is null
*/
- protected LazySortedMap(SortedMap<K,V> map, Transformer<? super K, ? extends V> factory) {
+ protected LazySortedMap(final SortedMap<K,V> map, final Transformer<? super K, ? extends V> factory) {
super(map, factory);
}
@@ -138,18 +138,18 @@ public class LazySortedMap<K,V>
return getSortedMap().comparator();
}
- public SortedMap<K,V> subMap(K fromKey, K toKey) {
- SortedMap<K,V> map = getSortedMap().subMap(fromKey, toKey);
+ public SortedMap<K,V> subMap(final K fromKey, final K toKey) {
+ final SortedMap<K,V> map = getSortedMap().subMap(fromKey, toKey);
return new LazySortedMap<K,V>(map, factory);
}
- public SortedMap<K,V> headMap(K toKey) {
- SortedMap<K,V> map = getSortedMap().headMap(toKey);
+ public SortedMap<K,V> headMap(final K toKey) {
+ final SortedMap<K,V> map = getSortedMap().headMap(toKey);
return new LazySortedMap<K,V>(map, factory);
}
- public SortedMap<K,V> tailMap(K fromKey) {
- SortedMap<K,V> map = getSortedMap().tailMap(fromKey);
+ public SortedMap<K,V> tailMap(final K fromKey) {
+ final SortedMap<K,V> map = getSortedMap().tailMap(fromKey);
return new LazySortedMap<K,V>(map, factory);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LinkedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LinkedMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LinkedMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LinkedMap.java Mon Jan 7 17:15:14 2013
@@ -78,7 +78,7 @@ public class LinkedMap<K, V> extends Abs
* @param initialCapacity the initial capacity
* @throws IllegalArgumentException if the initial capacity is negative
*/
- public LinkedMap(int initialCapacity) {
+ public LinkedMap(final int initialCapacity) {
super(initialCapacity);
}
@@ -91,7 +91,7 @@ public class LinkedMap<K, V> extends Abs
* @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
- public LinkedMap(int initialCapacity, float loadFactor) {
+ public LinkedMap(final int initialCapacity, final float loadFactor) {
super(initialCapacity, loadFactor);
}
@@ -101,7 +101,7 @@ public class LinkedMap<K, V> extends Abs
* @param map the map to copy
* @throws NullPointerException if the map is null
*/
- public LinkedMap(Map<K, V> map) {
+ public LinkedMap(final Map<K, V> map) {
super(map);
}
@@ -119,7 +119,7 @@ public class LinkedMap<K, V> extends Abs
/**
* 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);
}
@@ -127,7 +127,7 @@ public class LinkedMap<K, V> extends Abs
/**
* 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);
}
@@ -140,7 +140,7 @@ public class LinkedMap<K, V> extends Abs
* @return the key at the specified index
* @throws IndexOutOfBoundsException if the index is invalid
*/
- public K get(int index) {
+ public K get(final int index) {
return getEntry(index).getKey();
}
@@ -151,7 +151,7 @@ public class LinkedMap<K, V> extends Abs
* @return the value at the specified index
* @throws IndexOutOfBoundsException if the index is invalid
*/
- public V getValue(int index) {
+ public V getValue(final int index) {
return getEntry(index).getValue();
}
@@ -180,7 +180,7 @@ public class LinkedMap<K, V> extends Abs
* or <code>null</code> if none existed
* @throws IndexOutOfBoundsException if the index is invalid
*/
- public V remove(int index) {
+ public V remove(final int index) {
return remove(get(index));
}
@@ -210,7 +210,7 @@ public class LinkedMap<K, V> extends Abs
final LinkedMap<K, ?> parent;
- LinkedMapList(LinkedMap<K, ?> parent) {
+ LinkedMapList(final LinkedMap<K, ?> parent) {
this.parent = parent;
}
@@ -220,47 +220,47 @@ public class LinkedMap<K, V> extends Abs
}
@Override
- public K get(int index) {
+ public K get(final int index) {
return parent.get(index);
}
@Override
- public boolean contains(Object obj) {
+ public boolean contains(final Object obj) {
return parent.containsKey(obj);
}
@Override
- public int indexOf(Object obj) {
+ public int indexOf(final Object obj) {
return parent.indexOf(obj);
}
@Override
- public int lastIndexOf(Object obj) {
+ public int lastIndexOf(final Object obj) {
return parent.indexOf(obj);
}
@Override
- public boolean containsAll(Collection<?> coll) {
+ public boolean containsAll(final Collection<?> coll) {
return parent.keySet().containsAll(coll);
}
@Override
- public K remove(int index) {
+ public K remove(final int index) {
throw new UnsupportedOperationException();
}
@Override
- public boolean remove(Object obj) {
+ public boolean remove(final Object obj) {
throw new UnsupportedOperationException();
}
@Override
- public boolean removeAll(Collection<?> coll) {
+ public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
- public boolean retainAll(Collection<?> coll) {
+ public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@@ -275,7 +275,7 @@ public class LinkedMap<K, V> extends Abs
}
@Override
- public <T> T[] toArray(T[] array) {
+ public <T> T[] toArray(final T[] array) {
return parent.keySet().toArray(array);
}
@@ -290,12 +290,12 @@ public class LinkedMap<K, V> extends Abs
}
@Override
- public ListIterator<K> listIterator(int fromIndex) {
+ public ListIterator<K> listIterator(final int fromIndex) {
return UnmodifiableListIterator.umodifiableListIterator(super.listIterator(fromIndex));
}
@Override
- public List<K> subList(int fromIndexInclusive, int toIndexExclusive) {
+ public List<K> subList(final int fromIndexInclusive, final int toIndexExclusive) {
return UnmodifiableList.unmodifiableList(super.subList(fromIndexInclusive, toIndexExclusive));
}
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java Mon Jan 7 17:15:14 2013
@@ -95,7 +95,7 @@ public class ListOrderedMap<K, V>
* @return a new list ordered map
* @throws IllegalArgumentException if map is null
*/
- public static <K, V> ListOrderedMap<K, V> listOrderedMap(Map<K, V> map) {
+ public static <K, V> ListOrderedMap<K, V> listOrderedMap(final Map<K, V> map) {
return new ListOrderedMap<K, V>(map);
}
@@ -116,7 +116,7 @@ public class ListOrderedMap<K, V>
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if map is null
*/
- protected ListOrderedMap(Map<K, V> map) {
+ protected ListOrderedMap(final Map<K, V> map) {
super(map);
insertOrder.addAll(decorated().keySet());
}
@@ -129,7 +129,7 @@ public class ListOrderedMap<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);
}
@@ -143,7 +143,7 @@ public class ListOrderedMap<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)
}
@@ -188,8 +188,8 @@ public class ListOrderedMap<K, V>
* @param key the key to find previous for
* @return the next key, null if no match or at start
*/
- public K nextKey(Object key) {
- int index = insertOrder.indexOf(key);
+ public K nextKey(final Object key) {
+ final int index = insertOrder.indexOf(key);
if (index >= 0 && index < size() - 1) {
return insertOrder.get(index + 1);
}
@@ -203,8 +203,8 @@ public class ListOrderedMap<K, V>
* @param key the key to find previous for
* @return the previous key, null if no match or at start
*/
- public K previousKey(Object key) {
- int index = insertOrder.indexOf(key);
+ public K previousKey(final Object key) {
+ final int index = insertOrder.indexOf(key);
if (index > 0) {
return insertOrder.get(index - 1);
}
@@ -213,21 +213,21 @@ public class ListOrderedMap<K, V>
//-----------------------------------------------------------------------
@Override
- public V put(K key, V value) {
+ public V put(final K key, final V value) {
if (decorated().containsKey(key)) {
// re-adding doesn't change order
return decorated().put(key, value);
} else {
// first add, so add to both map and list
- V result = decorated().put(key, value);
+ final V result = decorated().put(key, value);
insertOrder.add(key);
return result;
}
}
@Override
- public void putAll(Map<? extends K, ? extends V> map) {
- for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
+ public void putAll(final Map<? extends K, ? extends V> map) {
+ for (final Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
put(entry.getKey(), entry.getValue());
}
}
@@ -239,9 +239,9 @@ public class ListOrderedMap<K, V>
* @param index the index in the Map to start at.
* @param map the Map containing the values to be added.
*/
- public void putAll(int index, Map<? extends K, ? extends V> map) {
- for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
- V old = put(index, entry.getKey(), entry.getValue());
+ public void putAll(int index, final Map<? extends K, ? extends V> map) {
+ for (final Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
+ final V old = put(index, entry.getKey(), entry.getValue());
if (old == null) {
// if no key was replaced, increment the index
index++;
@@ -253,7 +253,7 @@ public class ListOrderedMap<K, V>
}
@Override
- public V remove(Object key) {
+ public V remove(final Object key) {
V result = null;
if (decorated().containsKey(key)) {
result = decorated().remove(key);
@@ -349,12 +349,12 @@ public class ListOrderedMap<K, V>
if (isEmpty()) {
return "{}";
}
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append('{');
boolean first = true;
- for (Map.Entry<K, V> entry : entrySet()) {
- K key = entry.getKey();
- V value = entry.getValue();
+ for (final Map.Entry<K, V> entry : entrySet()) {
+ final K key = entry.getKey();
+ final V value = entry.getValue();
if (first) {
first = false;
} else {
@@ -376,7 +376,7 @@ public class ListOrderedMap<K, V>
* @return the key at the specified index
* @throws IndexOutOfBoundsException if the index is invalid
*/
- public K get(int index) {
+ public K get(final int index) {
return insertOrder.get(index);
}
@@ -387,7 +387,7 @@ public class ListOrderedMap<K, V>
* @return the key at the specified index
* @throws IndexOutOfBoundsException if the index is invalid
*/
- public V getValue(int index) {
+ public V getValue(final int index) {
return get(insertOrder.get(index));
}
@@ -397,7 +397,7 @@ public class ListOrderedMap<K, V>
* @param key the key to find the index of
* @return the index, or -1 if not found
*/
- public int indexOf(Object key) {
+ public int indexOf(final Object key) {
return insertOrder.indexOf(key);
}
@@ -410,8 +410,8 @@ public class ListOrderedMap<K, V>
* @throws IndexOutOfBoundsException if the index is invalid
* @since 3.2
*/
- public V setValue(int index, V value) {
- K key = insertOrder.get(index);
+ public V setValue(final int index, final V value) {
+ final K key = insertOrder.get(index);
return put(key, value);
}
@@ -434,11 +434,11 @@ public class ListOrderedMap<K, V>
* @throws IndexOutOfBoundsException if the index is out of range
* @since 3.2
*/
- public V put(int index, K key, V value) {
- Map<K, V> m = decorated();
+ public V put(int index, final K key, final V value) {
+ final Map<K, V> m = decorated();
if (m.containsKey(key)) {
- V result = m.remove(key);
- int pos = insertOrder.indexOf(key);
+ final V result = m.remove(key);
+ final int pos = insertOrder.indexOf(key);
insertOrder.remove(pos);
if (pos < index) {
index--;
@@ -460,7 +460,7 @@ public class ListOrderedMap<K, V>
* @return the removed value, or <code>null</code> if none existed
* @throws IndexOutOfBoundsException if the index is invalid
*/
- public V remove(int index) {
+ public V remove(final int index) {
return remove(get(index));
}
@@ -490,7 +490,7 @@ public class ListOrderedMap<K, V>
private final ListOrderedMap<Object, V> parent;
@SuppressWarnings("unchecked")
- ValuesView(ListOrderedMap<?, V> parent) {
+ ValuesView(final ListOrderedMap<?, V> parent) {
super();
this.parent = (ListOrderedMap<Object, V>) parent;
}
@@ -501,7 +501,7 @@ public class ListOrderedMap<K, V>
}
@Override
- public boolean contains(Object value) {
+ public boolean contains(final Object value) {
return this.parent.containsValue(value);
}
@@ -520,17 +520,17 @@ public class ListOrderedMap<K, V>
}
@Override
- public V get(int index) {
+ public V get(final int index) {
return this.parent.getValue(index);
}
@Override
- public V set(int index, V value) {
+ public V set(final int index, final V value) {
return this.parent.setValue(index, value);
}
@Override
- public V remove(int index) {
+ public V remove(final int index) {
return this.parent.remove(index);
}
}
@@ -540,7 +540,7 @@ public class ListOrderedMap<K, V>
private final ListOrderedMap<K, Object> parent;
@SuppressWarnings("unchecked")
- KeySetView(ListOrderedMap<K, ?> parent) {
+ KeySetView(final ListOrderedMap<K, ?> parent) {
super();
this.parent = (ListOrderedMap<K, Object>) parent;
}
@@ -551,7 +551,7 @@ public class ListOrderedMap<K, V>
}
@Override
- public boolean contains(Object value) {
+ public boolean contains(final Object value) {
return this.parent.containsKey(value);
}
@@ -576,7 +576,7 @@ public class ListOrderedMap<K, V>
private final List<K> insertOrder;
private Set<Map.Entry<K, V>> entrySet;
- public EntrySetView(ListOrderedMap<K, V> parent, List<K> insertOrder) {
+ public EntrySetView(final ListOrderedMap<K, V> parent, final List<K> insertOrder) {
super();
this.parent = parent;
this.insertOrder = insertOrder;
@@ -599,23 +599,23 @@ public class ListOrderedMap<K, V>
}
@Override
- public boolean contains(Object obj) {
+ public boolean contains(final Object obj) {
return getEntrySet().contains(obj);
}
@Override
- public boolean containsAll(Collection<?> coll) {
+ public boolean containsAll(final Collection<?> coll) {
return getEntrySet().containsAll(coll);
}
@Override
@SuppressWarnings("unchecked")
- public boolean remove(Object obj) {
+ public boolean remove(final Object obj) {
if (obj instanceof Map.Entry == false) {
return false;
}
if (getEntrySet().contains(obj)) {
- Object key = ((Map.Entry<K, V>) obj).getKey();
+ final Object key = ((Map.Entry<K, V>) obj).getKey();
parent.remove(key);
return true;
}
@@ -628,7 +628,7 @@ public class ListOrderedMap<K, V>
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
@@ -656,7 +656,7 @@ public class ListOrderedMap<K, V>
private final ListOrderedMap<K, V> parent;
private K last = null;
- ListOrderedIterator(ListOrderedMap<K, V> parent, List<K> insertOrder) {
+ ListOrderedIterator(final ListOrderedMap<K, V> parent, final List<K> insertOrder) {
super(insertOrder.iterator());
this.parent = parent;
}
@@ -677,7 +677,7 @@ public class ListOrderedMap<K, V>
static class ListOrderedMapEntry<K, V> extends AbstractMapEntry<K, V> {
private final ListOrderedMap<K, V> parent;
- ListOrderedMapEntry(ListOrderedMap<K, V> parent, K key) {
+ ListOrderedMapEntry(final ListOrderedMap<K, V> parent, final K key) {
super(key, null);
this.parent = parent;
}
@@ -688,7 +688,7 @@ public class ListOrderedMap<K, V>
}
@Override
- public V setValue(V value) {
+ public V setValue(final V value) {
return parent.decorated().put(key, value);
}
}
@@ -700,7 +700,7 @@ public class ListOrderedMap<K, V>
private K last = null;
private boolean readable = false;
- ListOrderedMapIterator(ListOrderedMap<K, V> parent) {
+ ListOrderedMapIterator(final ListOrderedMap<K, V> parent) {
super();
this.parent = parent;
this.iterator = parent.insertOrder.listIterator();
@@ -749,7 +749,7 @@ public class ListOrderedMap<K, V>
return parent.get(last);
}
- public V setValue(V value) {
+ public V setValue(final V value) {
if (readable == false) {
throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java Mon Jan 7 17:15:14 2013
@@ -93,7 +93,7 @@ public class MultiKeyMap<K, V> extends A
* @return a new multi key map
* @throws IllegalArgumentException if the map is null or not empty
*/
- public static <K, V> MultiKeyMap<K, V> multiKeyMap(AbstractHashedMap<MultiKey<? extends K>, V> map) {
+ public static <K, V> MultiKeyMap<K, V> multiKeyMap(final AbstractHashedMap<MultiKey<? extends K>, V> map) {
if (map == null) {
throw new IllegalArgumentException("Map must not be null");
}
@@ -119,7 +119,7 @@ public class MultiKeyMap<K, V> extends A
*
* @param map the map to decorate
*/
- protected MultiKeyMap(AbstractHashedMap<MultiKey<? extends K>, V> map) {
+ protected MultiKeyMap(final AbstractHashedMap<MultiKey<? extends K>, V> map) {
super(map);
this.map = map;
}
@@ -132,8 +132,8 @@ public class MultiKeyMap<K, V> extends A
* @param key2 the second key
* @return the mapped value, null if no match
*/
- public V get(Object key1, Object key2) {
- int hashCode = hash(key1, key2);
+ public V get(final Object key1, final Object key2) {
+ final int hashCode = hash(key1, key2);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry =
decorated().data[decorated().hashIndex(hashCode, decorated().data.length)];
while (entry != null) {
@@ -152,8 +152,8 @@ public class MultiKeyMap<K, V> extends A
* @param key2 the second key
* @return true if the map contains the key
*/
- public boolean containsKey(Object key1, Object key2) {
- int hashCode = hash(key1, key2);
+ public boolean containsKey(final Object key1, final Object key2) {
+ final int hashCode = hash(key1, key2);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry =
decorated().data[decorated().hashIndex(hashCode, decorated().data.length)];
while (entry != null) {
@@ -173,13 +173,13 @@ public class MultiKeyMap<K, V> extends A
* @param value the value to store
* @return the value previously mapped to this combined key, null if none
*/
- public V put(K key1, K key2, V value) {
- int hashCode = hash(key1, key2);
- int index = decorated().hashIndex(hashCode, decorated().data.length);
+ public V put(final K key1, final K key2, final V value) {
+ final int hashCode = hash(key1, key2);
+ final int index = decorated().hashIndex(hashCode, decorated().data.length);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry = decorated().data[index];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2)) {
- V oldValue = entry.getValue();
+ final V oldValue = entry.getValue();
decorated().updateEntry(entry, value);
return oldValue;
}
@@ -196,14 +196,14 @@ public class MultiKeyMap<K, V> extends A
* @param key2 the second key
* @return the value mapped to the removed key, null if key not in map
*/
- public V remove(Object key1, Object key2) {
- int hashCode = hash(key1, key2);
- int index = decorated().hashIndex(hashCode, decorated().data.length);
+ public V remove(final Object key1, final Object key2) {
+ final int hashCode = hash(key1, key2);
+ final int index = decorated().hashIndex(hashCode, decorated().data.length);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry = decorated().data[index];
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> previous = null;
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2)) {
- V oldValue = entry.getValue();
+ final V oldValue = entry.getValue();
decorated().removeMapping(entry, index, previous);
return oldValue;
}
@@ -220,7 +220,7 @@ public class MultiKeyMap<K, V> extends A
* @param key2 the second key
* @return the hash code
*/
- protected int hash(Object key1, Object key2) {
+ protected int hash(final Object key1, final Object key2) {
int h = 0;
if (key1 != null) {
h ^= key1.hashCode();
@@ -243,9 +243,9 @@ public class MultiKeyMap<K, V> extends A
* @param key2 the second key
* @return true if the key matches
*/
- protected boolean isEqualKey(AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry,
- Object key1, Object key2) {
- MultiKey<? extends K> multi = entry.getKey();
+ protected boolean isEqualKey(final AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry,
+ final Object key1, final Object key2) {
+ final MultiKey<? extends K> multi = entry.getKey();
return
multi.size() == 2 &&
(key1 == multi.getKey(0) || key1 != null && key1.equals(multi.getKey(0))) &&
@@ -261,8 +261,8 @@ public class MultiKeyMap<K, V> extends A
* @param key3 the third key
* @return the mapped value, null if no match
*/
- public V get(Object key1, Object key2, Object key3) {
- int hashCode = hash(key1, key2, key3);
+ public V get(final Object key1, final Object key2, final Object key3) {
+ final int hashCode = hash(key1, key2, key3);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry =
decorated().data[decorated().hashIndex(hashCode, decorated().data.length)];
while (entry != null) {
@@ -282,8 +282,8 @@ public class MultiKeyMap<K, V> extends A
* @param key3 the third key
* @return true if the map contains the key
*/
- public boolean containsKey(Object key1, Object key2, Object key3) {
- int hashCode = hash(key1, key2, key3);
+ public boolean containsKey(final Object key1, final Object key2, final Object key3) {
+ final int hashCode = hash(key1, key2, key3);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry =
decorated().data[decorated().hashIndex(hashCode, decorated().data.length)];
while (entry != null) {
@@ -304,13 +304,13 @@ public class MultiKeyMap<K, V> extends A
* @param value the value to store
* @return the value previously mapped to this combined key, null if none
*/
- public V put(K key1, K key2, K key3, V value) {
- int hashCode = hash(key1, key2, key3);
- int index = decorated().hashIndex(hashCode, decorated().data.length);
+ public V put(final K key1, final K key2, final K key3, final V value) {
+ final int hashCode = hash(key1, key2, key3);
+ final int index = decorated().hashIndex(hashCode, decorated().data.length);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry = decorated().data[index];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3)) {
- V oldValue = entry.getValue();
+ final V oldValue = entry.getValue();
decorated().updateEntry(entry, value);
return oldValue;
}
@@ -328,14 +328,14 @@ public class MultiKeyMap<K, V> extends A
* @param key3 the third key
* @return the value mapped to the removed key, null if key not in map
*/
- public V remove(Object key1, Object key2, Object key3) {
- int hashCode = hash(key1, key2, key3);
- int index = decorated().hashIndex(hashCode, decorated().data.length);
+ public V remove(final Object key1, final Object key2, final Object key3) {
+ final int hashCode = hash(key1, key2, key3);
+ final int index = decorated().hashIndex(hashCode, decorated().data.length);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry = decorated().data[index];
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> previous = null;
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3)) {
- V oldValue = entry.getValue();
+ final V oldValue = entry.getValue();
decorated().removeMapping(entry, index, previous);
return oldValue;
}
@@ -353,7 +353,7 @@ public class MultiKeyMap<K, V> extends A
* @param key3 the third key
* @return the hash code
*/
- protected int hash(Object key1, Object key2, Object key3) {
+ protected int hash(final Object key1, final Object key2, final Object key3) {
int h = 0;
if (key1 != null) {
h ^= key1.hashCode();
@@ -380,9 +380,9 @@ public class MultiKeyMap<K, V> extends A
* @param key3 the third key
* @return true if the key matches
*/
- protected boolean isEqualKey(AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry,
- Object key1, Object key2, Object key3) {
- MultiKey<? extends K> multi = entry.getKey();
+ protected boolean isEqualKey(final AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry,
+ final Object key1, final Object key2, final Object key3) {
+ final MultiKey<? extends K> multi = entry.getKey();
return
multi.size() == 3 &&
(key1 == multi.getKey(0) || key1 != null && key1.equals(multi.getKey(0))) &&
@@ -400,8 +400,8 @@ public class MultiKeyMap<K, V> extends A
* @param key4 the fourth key
* @return the mapped value, null if no match
*/
- public V get(Object key1, Object key2, Object key3, Object key4) {
- int hashCode = hash(key1, key2, key3, key4);
+ public V get(final Object key1, final Object key2, final Object key3, final Object key4) {
+ final int hashCode = hash(key1, key2, key3, key4);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry =
decorated().data[decorated().hashIndex(hashCode, decorated().data.length)];
while (entry != null) {
@@ -422,8 +422,8 @@ public class MultiKeyMap<K, V> extends A
* @param key4 the fourth key
* @return true if the map contains the key
*/
- public boolean containsKey(Object key1, Object key2, Object key3, Object key4) {
- int hashCode = hash(key1, key2, key3, key4);
+ public boolean containsKey(final Object key1, final Object key2, final Object key3, final Object key4) {
+ final int hashCode = hash(key1, key2, key3, key4);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry =
decorated().data[decorated().hashIndex(hashCode, decorated().data.length)];
while (entry != null) {
@@ -445,13 +445,13 @@ public class MultiKeyMap<K, V> extends A
* @param value the value to store
* @return the value previously mapped to this combined key, null if none
*/
- public V put(K key1, K key2, K key3, K key4, V value) {
- int hashCode = hash(key1, key2, key3, key4);
- int index = decorated().hashIndex(hashCode, decorated().data.length);
+ public V put(final K key1, final K key2, final K key3, final K key4, final V value) {
+ final int hashCode = hash(key1, key2, key3, key4);
+ final int index = decorated().hashIndex(hashCode, decorated().data.length);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry = decorated().data[index];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4)) {
- V oldValue = entry.getValue();
+ final V oldValue = entry.getValue();
decorated().updateEntry(entry, value);
return oldValue;
}
@@ -470,14 +470,14 @@ public class MultiKeyMap<K, V> extends A
* @param key4 the fourth key
* @return the value mapped to the removed key, null if key not in map
*/
- public V remove(Object key1, Object key2, Object key3, Object key4) {
- int hashCode = hash(key1, key2, key3, key4);
- int index = decorated().hashIndex(hashCode, decorated().data.length);
+ public V remove(final Object key1, final Object key2, final Object key3, final Object key4) {
+ final int hashCode = hash(key1, key2, key3, key4);
+ final int index = decorated().hashIndex(hashCode, decorated().data.length);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry = decorated().data[index];
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> previous = null;
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4)) {
- V oldValue = entry.getValue();
+ final V oldValue = entry.getValue();
decorated().removeMapping(entry, index, previous);
return oldValue;
}
@@ -496,7 +496,7 @@ public class MultiKeyMap<K, V> extends A
* @param key4 the fourth key
* @return the hash code
*/
- protected int hash(Object key1, Object key2, Object key3, Object key4) {
+ protected int hash(final Object key1, final Object key2, final Object key3, final Object key4) {
int h = 0;
if (key1 != null) {
h ^= key1.hashCode();
@@ -527,9 +527,9 @@ public class MultiKeyMap<K, V> extends A
* @param key4 the fourth key
* @return true if the key matches
*/
- protected boolean isEqualKey(AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry,
- Object key1, Object key2, Object key3, Object key4) {
- MultiKey<? extends K> multi = entry.getKey();
+ protected boolean isEqualKey(final AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry,
+ final Object key1, final Object key2, final Object key3, final Object key4) {
+ final MultiKey<? extends K> multi = entry.getKey();
return
multi.size() == 4 &&
(key1 == multi.getKey(0) || key1 != null && key1.equals(multi.getKey(0))) &&
@@ -549,8 +549,8 @@ public class MultiKeyMap<K, V> extends A
* @param key5 the fifth key
* @return the mapped value, null if no match
*/
- public V get(Object key1, Object key2, Object key3, Object key4, Object key5) {
- int hashCode = hash(key1, key2, key3, key4, key5);
+ public V get(final Object key1, final Object key2, final Object key3, final Object key4, final Object key5) {
+ final int hashCode = hash(key1, key2, key3, key4, key5);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry =
decorated().data[decorated().hashIndex(hashCode, decorated().data.length)];
while (entry != null) {
@@ -572,8 +572,8 @@ public class MultiKeyMap<K, V> extends A
* @param key5 the fifth key
* @return true if the map contains the key
*/
- public boolean containsKey(Object key1, Object key2, Object key3, Object key4, Object key5) {
- int hashCode = hash(key1, key2, key3, key4, key5);
+ public boolean containsKey(final Object key1, final Object key2, final Object key3, final Object key4, final Object key5) {
+ final int hashCode = hash(key1, key2, key3, key4, key5);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry =
decorated().data[decorated().hashIndex(hashCode, decorated().data.length)];
while (entry != null) {
@@ -596,13 +596,13 @@ public class MultiKeyMap<K, V> extends A
* @param value the value to store
* @return the value previously mapped to this combined key, null if none
*/
- public V put(K key1, K key2, K key3, K key4, K key5, V value) {
- int hashCode = hash(key1, key2, key3, key4, key5);
- int index = decorated().hashIndex(hashCode, decorated().data.length);
+ public V put(final K key1, final K key2, final K key3, final K key4, final K key5, final V value) {
+ final int hashCode = hash(key1, key2, key3, key4, key5);
+ final int index = decorated().hashIndex(hashCode, decorated().data.length);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry = decorated().data[index];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5)) {
- V oldValue = entry.getValue();
+ final V oldValue = entry.getValue();
decorated().updateEntry(entry, value);
return oldValue;
}
@@ -622,14 +622,14 @@ public class MultiKeyMap<K, V> extends A
* @param key5 the fifth key
* @return the value mapped to the removed key, null if key not in map
*/
- public V remove(Object key1, Object key2, Object key3, Object key4, Object key5) {
- int hashCode = hash(key1, key2, key3, key4, key5);
- int index = decorated().hashIndex(hashCode, decorated().data.length);
+ public V remove(final Object key1, final Object key2, final Object key3, final Object key4, final Object key5) {
+ final int hashCode = hash(key1, key2, key3, key4, key5);
+ final int index = decorated().hashIndex(hashCode, decorated().data.length);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry = decorated().data[index];
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> previous = null;
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5)) {
- V oldValue = entry.getValue();
+ final V oldValue = entry.getValue();
decorated().removeMapping(entry, index, previous);
return oldValue;
}
@@ -649,7 +649,7 @@ public class MultiKeyMap<K, V> extends A
* @param key5 the fifth key
* @return the hash code
*/
- protected int hash(Object key1, Object key2, Object key3, Object key4, Object key5) {
+ protected int hash(final Object key1, final Object key2, final Object key3, final Object key4, final Object key5) {
int h = 0;
if (key1 != null) {
h ^= key1.hashCode();
@@ -684,9 +684,9 @@ public class MultiKeyMap<K, V> extends A
* @param key5 the fifth key
* @return true if the key matches
*/
- protected boolean isEqualKey(AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry,
- Object key1, Object key2, Object key3, Object key4, Object key5) {
- MultiKey<? extends K> multi = entry.getKey();
+ protected boolean isEqualKey(final AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry,
+ final Object key1, final Object key2, final Object key3, final Object key4, final Object key5) {
+ final MultiKey<? extends K> multi = entry.getKey();
return
multi.size() == 5 &&
(key1 == multi.getKey(0) || key1 != null && key1.equals(multi.getKey(0))) &&
@@ -706,11 +706,11 @@ public class MultiKeyMap<K, V> extends A
* @param key1 the first key
* @return true if any elements were removed
*/
- public boolean removeAll(Object key1) {
+ public boolean removeAll(final Object key1) {
boolean modified = false;
- MapIterator<MultiKey<? extends K>, V> it = mapIterator();
+ final MapIterator<MultiKey<? extends K>, V> it = mapIterator();
while (it.hasNext()) {
- MultiKey<? extends K> multi = it.next();
+ final MultiKey<? extends K> multi = it.next();
if (multi.size() >= 1 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0)))) {
it.remove();
@@ -730,11 +730,11 @@ public class MultiKeyMap<K, V> extends A
* @param key2 the second key
* @return true if any elements were removed
*/
- public boolean removeAll(Object key1, Object key2) {
+ public boolean removeAll(final Object key1, final Object key2) {
boolean modified = false;
- MapIterator<MultiKey<? extends K>, V> it = mapIterator();
+ final MapIterator<MultiKey<? extends K>, V> it = mapIterator();
while (it.hasNext()) {
- MultiKey<? extends K> multi = it.next();
+ final MultiKey<? extends K> multi = it.next();
if (multi.size() >= 2 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1)))) {
@@ -756,11 +756,11 @@ public class MultiKeyMap<K, V> extends A
* @param key3 the third key
* @return true if any elements were removed
*/
- public boolean removeAll(Object key1, Object key2, Object key3) {
+ public boolean removeAll(final Object key1, final Object key2, final Object key3) {
boolean modified = false;
- MapIterator<MultiKey<? extends K>, V> it = mapIterator();
+ final MapIterator<MultiKey<? extends K>, V> it = mapIterator();
while (it.hasNext()) {
- MultiKey<? extends K> multi = it.next();
+ final MultiKey<? extends K> multi = it.next();
if (multi.size() >= 3 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
@@ -784,11 +784,11 @@ public class MultiKeyMap<K, V> extends A
* @param key4 the fourth key
* @return true if any elements were removed
*/
- public boolean removeAll(Object key1, Object key2, Object key3, Object key4) {
+ public boolean removeAll(final Object key1, final Object key2, final Object key3, final Object key4) {
boolean modified = false;
- MapIterator<MultiKey<? extends K>, V> it = mapIterator();
+ final MapIterator<MultiKey<? extends K>, V> it = mapIterator();
while (it.hasNext()) {
- MultiKey<? extends K> multi = it.next();
+ final MultiKey<? extends K> multi = it.next();
if (multi.size() >= 4 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
@@ -807,7 +807,7 @@ public class MultiKeyMap<K, V> extends A
*
* @param key the key to check
*/
- protected void checkKey(MultiKey<?> key) {
+ protected void checkKey(final MultiKey<?> key) {
if (key == null) {
throw new NullPointerException("Key must not be null");
}
@@ -834,7 +834,7 @@ public class MultiKeyMap<K, V> extends A
* @throws ClassCastException if the key is not a MultiKey
*/
@Override
- public V put(MultiKey<? extends K> key, V value) {
+ public V put(final MultiKey<? extends K> key, final V value) {
checkKey(key);
return super.put(key, value);
}
@@ -848,8 +848,8 @@ public class MultiKeyMap<K, V> extends A
* @throws ClassCastException if any key in mapToCopy is not a MultiKey
*/
@Override
- public void putAll(Map<? extends MultiKey<? extends K>, ? extends V> mapToCopy) {
- for (MultiKey<? extends K> key : mapToCopy.keySet()) {
+ public void putAll(final Map<? extends MultiKey<? extends K>, ? extends V> mapToCopy) {
+ for (final MultiKey<? extends K> key : mapToCopy.keySet()) {
checkKey(key);
}
super.putAll(mapToCopy);