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 [4/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/b...
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TransformerUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TransformerUtils.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TransformerUtils.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TransformerUtils.java Mon Jan 7 17:15:14 2013
@@ -131,7 +131,7 @@ public class TransformerUtils {
* @param constantToReturn the constant object to return each time in the transformer
* @return the transformer.
*/
- public static <I, O> Transformer<I, O> constantTransformer(O constantToReturn) {
+ public static <I, O> Transformer<I, O> constantTransformer(final O constantToReturn) {
return ConstantTransformer.constantTransformer(constantToReturn);
}
@@ -145,7 +145,7 @@ public class TransformerUtils {
* @return the transformer
* @throws IllegalArgumentException if the closure is null
*/
- public static <T> Transformer<T, T> asTransformer(Closure<? super T> closure) {
+ public static <T> Transformer<T, T> asTransformer(final Closure<? super T> closure) {
return ClosureTransformer.closureTransformer(closure);
}
@@ -159,7 +159,7 @@ public class TransformerUtils {
* @return the transformer
* @throws IllegalArgumentException if the predicate is null
*/
- public static <T> Transformer<T, Boolean> asTransformer(Predicate<? super T> predicate) {
+ public static <T> Transformer<T, Boolean> asTransformer(final Predicate<? super T> predicate) {
return PredicateTransformer.predicateTransformer(predicate);
}
@@ -173,7 +173,7 @@ public class TransformerUtils {
* @return the transformer
* @throws IllegalArgumentException if the factory is null
*/
- public static <I, O> Transformer<I, O> asTransformer(Factory<? extends O> factory) {
+ public static <I, O> Transformer<I, O> asTransformer(final Factory<? extends O> factory) {
return FactoryTransformer.factoryTransformer(factory);
}
@@ -190,8 +190,8 @@ public class TransformerUtils {
*/
@SuppressWarnings("unchecked")
public static <T> Transformer<T, T> chainedTransformer(
- Transformer<? super T, ? extends T> transformer1,
- Transformer<? super T, ? extends T> transformer2) {
+ final Transformer<? super T, ? extends T> transformer1,
+ final Transformer<? super T, ? extends T> transformer2) {
return ChainedTransformer.<T> chainedTransformer(transformer1, transformer2);
}
@@ -206,7 +206,7 @@ public class TransformerUtils {
* @throws IllegalArgumentException if the transformers array is null
* @throws IllegalArgumentException if any transformer in the array is null
*/
- public static <T> Transformer<T, T> chainedTransformer(Transformer<? super T, ? extends T>[] transformers) {
+ public static <T> Transformer<T, T> chainedTransformer(final Transformer<? super T, ? extends T>[] transformers) {
return ChainedTransformer.chainedTransformer(transformers);
}
@@ -223,7 +223,7 @@ public class TransformerUtils {
* @throws IllegalArgumentException if any transformer in the collection is null
*/
public static <T> Transformer<T, T> chainedTransformer(
- Collection<? extends Transformer<T, T>> transformers) {
+ final Collection<? extends Transformer<T, T>> transformers) {
return ChainedTransformer.chainedTransformer(transformers);
}
@@ -241,9 +241,9 @@ public class TransformerUtils {
* @throws IllegalArgumentException if either transformer is null
*/
@SuppressWarnings("unchecked")
- public static <I, O> Transformer<I, O> switchTransformer(Predicate<? super I> predicate,
- Transformer<? super I, ? extends O> trueTransformer,
- Transformer<? super I, ? extends O> falseTransformer) {
+ public static <I, O> Transformer<I, O> switchTransformer(final Predicate<? super I> predicate,
+ final Transformer<? super I, ? extends O> trueTransformer,
+ final Transformer<? super I, ? extends O> falseTransformer) {
return SwitchTransformer.switchTransformer(new Predicate[] { predicate },
new Transformer[] { trueTransformer }, falseTransformer);
}
@@ -264,8 +264,8 @@ public class TransformerUtils {
* @throws IllegalArgumentException if any element in the arrays is null
* @throws IllegalArgumentException if the arrays are different sizes
*/
- public static <I, O> Transformer<I, O> switchTransformer(Predicate<? super I>[] predicates,
- Transformer<? super I, ? extends O>[] transformers) {
+ public static <I, O> Transformer<I, O> switchTransformer(final Predicate<? super I>[] predicates,
+ final Transformer<? super I, ? extends O>[] transformers) {
return SwitchTransformer.<I, O>switchTransformer(predicates, transformers, null);
}
@@ -287,9 +287,9 @@ public class TransformerUtils {
* @throws IllegalArgumentException if any element in the arrays is null
* @throws IllegalArgumentException if the arrays are different sizes
*/
- public static <I, O> Transformer<I, O> switchTransformer(Predicate<? super I>[] predicates,
- Transformer<? super I, ? extends O>[] transformers,
- Transformer<? super I, ? extends O> defaultTransformer) {
+ public static <I, O> Transformer<I, O> switchTransformer(final Predicate<? super I>[] predicates,
+ final Transformer<? super I, ? extends O>[] transformers,
+ final Transformer<? super I, ? extends O> defaultTransformer) {
return SwitchTransformer.<I, O>switchTransformer(predicates, transformers, defaultTransformer);
}
@@ -315,7 +315,7 @@ public class TransformerUtils {
* @throws ClassCastException if the map elements are of the wrong type
*/
public static <I, O> Transformer<I, O> switchTransformer(
- Map<Predicate<I>, Transformer<I, O>> predicatesAndTransformers) {
+ final Map<Predicate<I>, Transformer<I, O>> predicatesAndTransformers) {
return SwitchTransformer.<I, O>switchTransformer(predicatesAndTransformers);
}
@@ -337,18 +337,18 @@ public class TransformerUtils {
* @throws IllegalArgumentException if any transformer in the map is null
*/
@SuppressWarnings("unchecked")
- public static <I, O> Transformer<I, O> switchMapTransformer(Map<I, Transformer<I, O>> objectsAndTransformers) {
+ public static <I, O> Transformer<I, O> switchMapTransformer(final Map<I, Transformer<I, O>> objectsAndTransformers) {
Transformer<? super I, ? extends O>[] trs = null;
Predicate<I>[] preds = null;
if (objectsAndTransformers == null) {
throw new IllegalArgumentException("The object and transformer map must not be null");
}
- Transformer<? super I, ? extends O> def = objectsAndTransformers.remove(null);
- int size = objectsAndTransformers.size();
+ final Transformer<? super I, ? extends O> def = objectsAndTransformers.remove(null);
+ final int size = objectsAndTransformers.size();
trs = new Transformer[size];
preds = new Predicate[size];
int i = 0;
- for (Map.Entry<I, Transformer<I, O>> entry : objectsAndTransformers.entrySet()) {
+ for (final Map.Entry<I, Transformer<I, O>> entry : objectsAndTransformers.entrySet()) {
preds[i] = EqualPredicate.<I>equalPredicate(entry.getKey());
trs[i++] = entry.getValue();
}
@@ -379,7 +379,7 @@ public class TransformerUtils {
* @throws IllegalArgumentException if the paramTypes and args don't match
*/
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer(
- Class<?>[] paramTypes, Object[] args) {
+ final Class<?>[] paramTypes, final Object[] args) {
return InstantiateTransformer.<T>instantiateTransformer(paramTypes, args);
}
@@ -392,7 +392,7 @@ public class TransformerUtils {
* @param map the map to use to transform the objects
* @return the transformer, or a {@link ConstantTransformer#NULL_INSTANCE} if the {@code map} is {@code null}
*/
- public static <I, O> Transformer<I, O> mapTransformer(Map<? super I, ? extends O> map) {
+ public static <I, O> Transformer<I, O> mapTransformer(final Map<? super I, ? extends O> map) {
return MapTransformer.mapTransformer(map);
}
@@ -411,7 +411,7 @@ public class TransformerUtils {
* @return the transformer
* @throws IllegalArgumentException if the methodName is null.
*/
- public static <I, O> Transformer<I, O> invokerTransformer(String methodName){
+ public static <I, O> Transformer<I, O> invokerTransformer(final String methodName){
return InvokerTransformer.<I, O>invokerTransformer(methodName, null, null);
}
@@ -429,7 +429,7 @@ public class TransformerUtils {
* @throws IllegalArgumentException if the method name is null
* @throws IllegalArgumentException if the paramTypes and args don't match
*/
- public static <I, O> Transformer<I, O> invokerTransformer(String methodName, Class<?>[] paramTypes, Object[] args){
+ public static <I, O> Transformer<I, O> invokerTransformer(final String methodName, final Class<?>[] paramTypes, final Object[] args){
return InvokerTransformer.<I, O>invokerTransformer(methodName, paramTypes, args);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TrieUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TrieUtils.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TrieUtils.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TrieUtils.java Mon Jan 7 17:15:14 2013
@@ -37,7 +37,7 @@ public class TrieUtils {
*
* @see Collections#synchronizedMap(Map)
*/
- public static <K, V> Trie<K, V> synchronizedTrie(Trie<K, V> trie) {
+ public static <K, V> Trie<K, V> synchronizedTrie(final Trie<K, V> trie) {
return SynchronizedTrie.synchronizedTrie(trie);
}
@@ -46,7 +46,7 @@ public class TrieUtils {
*
* @see Collections#unmodifiableMap(Map)
*/
- public static <K, V> Trie<K, V> unmodifiableTrie(Trie<K, V> trie) {
+ public static <K, V> Trie<K, V> unmodifiableTrie(final Trie<K, V> trie) {
return UnmodifiableTrie.unmodifiableTrie(trie);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractBagDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractBagDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractBagDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractBagDecorator.java Mon Jan 7 17:15:14 2013
@@ -49,7 +49,7 @@ public abstract class AbstractBagDecorat
* @param bag the bag to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
- protected AbstractBagDecorator(Bag<E> bag) {
+ protected AbstractBagDecorator(final Bag<E> bag) {
super(bag);
}
@@ -65,15 +65,15 @@ public abstract class AbstractBagDecorat
//-----------------------------------------------------------------------
- public int getCount(Object object) {
+ public int getCount(final Object object) {
return decorated().getCount(object);
}
- public boolean add(E object, int count) {
+ public boolean add(final E object, final int count) {
return decorated().add(object, count);
}
- public boolean remove(Object object, int count) {
+ public boolean remove(final Object object, final int count) {
return decorated().remove(object, count);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java Mon Jan 7 17:15:14 2013
@@ -65,7 +65,7 @@ public abstract class AbstractMapBag<E>
*
* @param map the map to assign
*/
- protected AbstractMapBag(Map<E, MutableInteger> map) {
+ protected AbstractMapBag(final Map<E, MutableInteger> map) {
super();
this.map = map;
}
@@ -106,8 +106,8 @@ public abstract class AbstractMapBag<E>
* @param object the object to search for
* @return the number of occurrences of the object, zero if not found
*/
- public int getCount(Object object) {
- MutableInteger count = map.get(object);
+ public int getCount(final Object object) {
+ final MutableInteger count = map.get(object);
if (count != null) {
return count.value;
}
@@ -122,7 +122,7 @@ public abstract class AbstractMapBag<E>
* @param object the object to search for
* @return true if the bag contains the given element
*/
- public boolean contains(Object object) {
+ public boolean contains(final Object object) {
return map.containsKey(object);
}
@@ -132,7 +132,7 @@ public abstract class AbstractMapBag<E>
* @param coll the collection to check against
* @return <code>true</code> if the Bag contains all the collection
*/
- public boolean containsAll(Collection<?> coll) {
+ public boolean containsAll(final Collection<?> coll) {
if (coll instanceof Bag) {
return containsAll((Bag<?>) coll);
}
@@ -146,12 +146,12 @@ public abstract class AbstractMapBag<E>
* @param other the bag to check against
* @return <code>true</code> if the Bag contains all the collection
*/
- boolean containsAll(Bag<?> other) {
+ boolean containsAll(final Bag<?> other) {
boolean result = true;
- Iterator<?> it = other.uniqueSet().iterator();
+ final Iterator<?> it = other.uniqueSet().iterator();
while (it.hasNext()) {
- Object current = it.next();
- boolean contains = getCount(current) >= other.getCount(current);
+ final Object current = it.next();
+ final boolean contains = getCount(current) >= other.getCount(current);
result = result && contains;
}
return result;
@@ -184,7 +184,7 @@ public abstract class AbstractMapBag<E>
*
* @param parent the parent bag
*/
- public BagIterator(AbstractMapBag<E> parent) {
+ public BagIterator(final AbstractMapBag<E> parent) {
this.parent = parent;
this.entryIterator = parent.map.entrySet().iterator();
this.current = null;
@@ -219,7 +219,7 @@ public abstract class AbstractMapBag<E>
if (canRemove == false) {
throw new IllegalStateException();
}
- MutableInteger mut = current.getValue();
+ final MutableInteger mut = current.getValue();
if (mut.value > 1) {
mut.value--;
} else {
@@ -239,7 +239,7 @@ public abstract class AbstractMapBag<E>
* @return <code>true</code> if the object was not already in the
* <code>uniqueSet</code>
*/
- public boolean add(E object) {
+ public boolean add(final E object) {
return add(object, 1);
}
@@ -251,10 +251,10 @@ public abstract class AbstractMapBag<E>
* @return <code>true</code> if the object was not already in the
* <code>uniqueSet</code>
*/
- public boolean add(E object, int nCopies) {
+ public boolean add(final E object, final int nCopies) {
modCount++;
if (nCopies > 0) {
- MutableInteger mut = map.get(object);
+ final MutableInteger mut = map.get(object);
size += nCopies;
if (mut == null) {
map.put(object, new MutableInteger(nCopies));
@@ -272,11 +272,11 @@ public abstract class AbstractMapBag<E>
* @param coll the collection to add
* @return <code>true</code> if this call changed the bag
*/
- public boolean addAll(Collection<? extends E> coll) {
+ public boolean addAll(final Collection<? extends E> coll) {
boolean changed = false;
- Iterator<? extends E> i = coll.iterator();
+ final Iterator<? extends E> i = coll.iterator();
while (i.hasNext()) {
- boolean added = add(i.next());
+ final boolean added = add(i.next());
changed = changed || added;
}
return changed;
@@ -298,8 +298,8 @@ public abstract class AbstractMapBag<E>
* @param object the object to remove
* @return true if the bag changed
*/
- public boolean remove(Object object) {
- MutableInteger mut = map.get(object);
+ public boolean remove(final Object object) {
+ final MutableInteger mut = map.get(object);
if (mut == null) {
return false;
}
@@ -316,8 +316,8 @@ public abstract class AbstractMapBag<E>
* @param nCopies the number of copies to remove
* @return true if the bag changed
*/
- public boolean remove(Object object, int nCopies) {
- MutableInteger mut = map.get(object);
+ public boolean remove(final Object object, final int nCopies) {
+ final MutableInteger mut = map.get(object);
if (mut == null) {
return false;
}
@@ -342,12 +342,12 @@ public abstract class AbstractMapBag<E>
* @param coll the collection to use
* @return true if the bag changed
*/
- public boolean removeAll(Collection<?> coll) {
+ public boolean removeAll(final Collection<?> coll) {
boolean result = false;
if (coll != null) {
- Iterator<?> i = coll.iterator();
+ final Iterator<?> i = coll.iterator();
while (i.hasNext()) {
- boolean changed = remove(i.next(), 1);
+ final boolean changed = remove(i.next(), 1);
result = result || changed;
}
}
@@ -361,7 +361,7 @@ public abstract class AbstractMapBag<E>
* @param coll the collection to retain
* @return true if this call changed the collection
*/
- public boolean retainAll(Collection<?> coll) {
+ public boolean retainAll(final Collection<?> coll) {
if (coll instanceof Bag) {
return retainAll((Bag<?>) coll);
}
@@ -376,14 +376,14 @@ public abstract class AbstractMapBag<E>
* @param other the bag to retain
* @return <code>true</code> if this call changed the collection
*/
- boolean retainAll(Bag<?> other) {
+ boolean retainAll(final Bag<?> other) {
boolean result = false;
- Bag<E> excess = new HashBag<E>();
- Iterator<E> i = uniqueSet().iterator();
+ final Bag<E> excess = new HashBag<E>();
+ final Iterator<E> i = uniqueSet().iterator();
while (i.hasNext()) {
- E current = i.next();
- int myCount = getCount(current);
- int otherCount = other.getCount(current);
+ final E current = i.next();
+ final int myCount = getCount(current);
+ final int otherCount = other.getCount(current);
if (1 <= otherCount && otherCount <= myCount) {
excess.add(current, myCount - otherCount);
} else {
@@ -408,12 +408,12 @@ public abstract class AbstractMapBag<E>
* Constructor.
* @param value the initial value
*/
- MutableInteger(int value) {
+ MutableInteger(final int value) {
this.value = value;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj instanceof MutableInteger == false) {
return false;
}
@@ -433,11 +433,11 @@ public abstract class AbstractMapBag<E>
* @return an array of all of this bag's elements
*/
public Object[] toArray() {
- Object[] result = new Object[size()];
+ final Object[] result = new Object[size()];
int i = 0;
- Iterator<E> it = map.keySet().iterator();
+ final Iterator<E> it = map.keySet().iterator();
while (it.hasNext()) {
- E current = it.next();
+ final E current = it.next();
for (int index = getCount(current); index > 0; index--) {
result[i++] = current;
}
@@ -454,15 +454,15 @@ public abstract class AbstractMapBag<E>
*/
@SuppressWarnings("unchecked")
public <T> T[] toArray(T[] array) {
- int size = size();
+ final int size = size();
if (array.length < size) {
array = (T[]) Array.newInstance(array.getClass().getComponentType(), size);
}
int i = 0;
- Iterator<E> it = map.keySet().iterator();
+ final Iterator<E> it = map.keySet().iterator();
while (it.hasNext()) {
- E current = it.next();
+ final E current = it.next();
for (int index = getCount(current); index > 0; index--) {
array[i++] = (T) current;
}
@@ -491,9 +491,9 @@ public abstract class AbstractMapBag<E>
* @param out the output stream
* @throws IOException any of the usual I/O related exceptions
*/
- protected void doWriteObject(ObjectOutputStream out) throws IOException {
+ protected void doWriteObject(final ObjectOutputStream out) throws IOException {
out.writeInt(map.size());
- for (Entry<E, MutableInteger> entry : map.entrySet()) {
+ for (final Entry<E, MutableInteger> entry : map.entrySet()) {
out.writeObject(entry.getKey());
out.writeInt(entry.getValue().value);
}
@@ -507,14 +507,15 @@ public abstract class AbstractMapBag<E>
* @throws ClassNotFoundException if the stream contains an object which class can not be loaded
* @throws ClassCastException if the stream does not contain the correct objects
*/
- protected void doReadObject(Map<E, MutableInteger> map, ObjectInputStream in)
+ protected void doReadObject(final Map<E, MutableInteger> map, final ObjectInputStream in)
throws IOException, ClassNotFoundException {
this.map = map;
- int entrySize = in.readInt();
+ final int entrySize = in.readInt();
for (int i = 0; i < entrySize; i++) {
@SuppressWarnings("unchecked") // This will fail at runtime if the stream is incorrect
+ final
E obj = (E) in.readObject();
- int count = in.readInt();
+ final int count = in.readInt();
map.put(obj, new MutableInteger(count));
size += count;
}
@@ -529,18 +530,18 @@ public abstract class AbstractMapBag<E>
* @return true if equal
*/
@Override
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if (object == this) {
return true;
}
if (object instanceof Bag == false) {
return false;
}
- Bag<?> other = (Bag<?>) object;
+ final Bag<?> other = (Bag<?>) object;
if (other.size() != size()) {
return false;
}
- for (E element : map.keySet()) {
+ for (final E element : map.keySet()) {
if (other.getCount(element) != getCount(element)) {
return false;
}
@@ -560,9 +561,9 @@ public abstract class AbstractMapBag<E>
@Override
public int hashCode() {
int total = 0;
- for (Entry<E, MutableInteger> entry : map.entrySet()) {
- E element = entry.getKey();
- MutableInteger count = entry.getValue();
+ for (final Entry<E, MutableInteger> entry : map.entrySet()) {
+ final E element = entry.getKey();
+ final MutableInteger count = entry.getValue();
total += (element == null ? 0 : element.hashCode()) ^ count.value;
}
return total;
@@ -578,12 +579,12 @@ public abstract class AbstractMapBag<E>
if (size() == 0) {
return "[]";
}
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append('[');
- Iterator<E> it = uniqueSet().iterator();
+ final Iterator<E> it = uniqueSet().iterator();
while (it.hasNext()) {
- Object current = it.next();
- int count = getCount(current);
+ final Object current = it.next();
+ final int count = getCount(current);
buf.append(count);
buf.append(':');
buf.append(current);
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java Mon Jan 7 17:15:14 2013
@@ -48,7 +48,7 @@ public abstract class AbstractSortedBagD
* @param bag the bag to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
- protected AbstractSortedBagDecorator(SortedBag<E> bag) {
+ protected AbstractSortedBagDecorator(final SortedBag<E> bag) {
super(bag);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/HashBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/HashBag.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/HashBag.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/HashBag.java Mon Jan 7 17:15:14 2013
@@ -55,7 +55,7 @@ public class HashBag<E> extends Abstract
*
* @param coll a collection to copy into this bag
*/
- public HashBag(Collection<? extends E> coll) {
+ public HashBag(final Collection<? extends E> coll) {
this();
addAll(coll);
}
@@ -64,7 +64,7 @@ public class HashBag<E> extends Abstract
/**
* Write the bag out using a custom routine.
*/
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
super.doWriteObject(out);
}
@@ -72,7 +72,7 @@ public class HashBag<E> extends Abstract
/**
* Read the bag in using a custom routine.
*/
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
super.doReadObject(new HashMap<E, MutableInteger>(), in);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/PredicatedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/PredicatedBag.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/PredicatedBag.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/PredicatedBag.java Mon Jan 7 17:15:14 2013
@@ -56,7 +56,7 @@ public class PredicatedBag<E> extends Pr
* @throws IllegalArgumentException if bag or predicate is null
* @throws IllegalArgumentException if the bag contains invalid elements
*/
- public static <E> PredicatedBag<E> predicatedBag(Bag<E> bag, Predicate<? super E> predicate) {
+ public static <E> PredicatedBag<E> predicatedBag(final Bag<E> bag, final Predicate<? super E> predicate) {
return new PredicatedBag<E>(bag, predicate);
}
@@ -72,7 +72,7 @@ public class PredicatedBag<E> extends Pr
* @throws IllegalArgumentException if bag or predicate is null
* @throws IllegalArgumentException if the bag contains invalid elements
*/
- protected PredicatedBag(Bag<E> bag, Predicate<? super E> predicate) {
+ protected PredicatedBag(final Bag<E> bag, final Predicate<? super E> predicate) {
super(bag, predicate);
}
@@ -88,12 +88,12 @@ public class PredicatedBag<E> extends Pr
//-----------------------------------------------------------------------
- public boolean add(E object, int count) {
+ public boolean add(final E object, final int count) {
validate(object);
return decorated().add(object, count);
}
- public boolean remove(Object object, int count) {
+ public boolean remove(final Object object, final int count) {
return decorated().remove(object, count);
}
@@ -101,7 +101,7 @@ public class PredicatedBag<E> extends Pr
return decorated().uniqueSet();
}
- public int getCount(Object object) {
+ public int getCount(final Object object) {
return decorated().getCount(object);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/PredicatedSortedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/PredicatedSortedBag.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/PredicatedSortedBag.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/PredicatedSortedBag.java Mon Jan 7 17:15:14 2013
@@ -55,7 +55,7 @@ public class PredicatedSortedBag<E> exte
* @throws IllegalArgumentException if bag or predicate is null
* @throws IllegalArgumentException if the bag contains invalid elements
*/
- public static <E> PredicatedSortedBag<E> predicatedSortedBag(SortedBag<E> bag, Predicate<? super E> predicate) {
+ public static <E> PredicatedSortedBag<E> predicatedSortedBag(final SortedBag<E> bag, final Predicate<? super E> predicate) {
return new PredicatedSortedBag<E>(bag, predicate);
}
@@ -70,7 +70,7 @@ public class PredicatedSortedBag<E> exte
* @throws IllegalArgumentException if bag or predicate is null
* @throws IllegalArgumentException if the bag contains invalid elements
*/
- protected PredicatedSortedBag(SortedBag<E> bag, Predicate<? super E> predicate) {
+ protected PredicatedSortedBag(final SortedBag<E> bag, final Predicate<? super E> predicate) {
super(bag, predicate);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/SynchronizedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/SynchronizedBag.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/SynchronizedBag.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/SynchronizedBag.java Mon Jan 7 17:15:14 2013
@@ -47,7 +47,7 @@ public class SynchronizedBag<E> extends
* @return a new synchronized Bag
* @throws IllegalArgumentException if bag is null
*/
- public static <E> SynchronizedBag<E> synchronizedBag(Bag<E> bag) {
+ public static <E> SynchronizedBag<E> synchronizedBag(final Bag<E> bag) {
return new SynchronizedBag<E>(bag);
}
@@ -58,7 +58,7 @@ public class SynchronizedBag<E> extends
* @param bag the bag to decorate, must not be null
* @throws IllegalArgumentException if bag is null
*/
- protected SynchronizedBag(Bag<E> bag) {
+ protected SynchronizedBag(final Bag<E> bag) {
super(bag);
}
@@ -69,7 +69,7 @@ public class SynchronizedBag<E> extends
* @param lock the lock to use, must not be null
* @throws IllegalArgumentException if bag is null
*/
- protected SynchronizedBag(Bag<E> bag, Object lock) {
+ protected SynchronizedBag(final Bag<E> bag, final Object lock) {
super(bag, lock);
}
@@ -84,13 +84,13 @@ public class SynchronizedBag<E> extends
//-----------------------------------------------------------------------
- public boolean add(E object, int count) {
+ public boolean add(final E object, final int count) {
synchronized (lock) {
return getBag().add(object, count);
}
}
- public boolean remove(Object object, int count) {
+ public boolean remove(final Object object, final int count) {
synchronized (lock) {
return getBag().remove(object, count);
}
@@ -98,12 +98,12 @@ public class SynchronizedBag<E> extends
public Set<E> uniqueSet() {
synchronized (lock) {
- Set<E> set = getBag().uniqueSet();
+ final Set<E> set = getBag().uniqueSet();
return new SynchronizedBagSet(set, lock);
}
}
- public int getCount(Object object) {
+ public int getCount(final Object object) {
synchronized (lock) {
return getBag().getCount(object);
}
@@ -122,7 +122,7 @@ public class SynchronizedBag<E> extends
* @param set the set to decorate
* @param lock the lock to use, shared with the bag
*/
- SynchronizedBagSet(Set<E> set, Object lock) {
+ SynchronizedBagSet(final Set<E> set, final Object lock) {
super(set, lock);
}
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/SynchronizedSortedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/SynchronizedSortedBag.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/SynchronizedSortedBag.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/SynchronizedSortedBag.java Mon Jan 7 17:15:14 2013
@@ -46,7 +46,7 @@ public class SynchronizedSortedBag<E> ex
* @return a new synchronized SortedBag
* @throws IllegalArgumentException if bag is null
*/
- public static <E> SynchronizedSortedBag<E> synchronizedSortedBag(SortedBag<E> bag) {
+ public static <E> SynchronizedSortedBag<E> synchronizedSortedBag(final SortedBag<E> bag) {
return new SynchronizedSortedBag<E>(bag);
}
@@ -57,7 +57,7 @@ public class SynchronizedSortedBag<E> ex
* @param bag the bag to decorate, must not be null
* @throws IllegalArgumentException if bag is null
*/
- protected SynchronizedSortedBag(SortedBag<E> bag) {
+ protected SynchronizedSortedBag(final SortedBag<E> bag) {
super(bag);
}
@@ -68,7 +68,7 @@ public class SynchronizedSortedBag<E> ex
* @param lock the lock to use, must not be null
* @throws IllegalArgumentException if bag is null
*/
- protected SynchronizedSortedBag(Bag<E> bag, Object lock) {
+ protected SynchronizedSortedBag(final Bag<E> bag, final Object lock) {
super(bag, lock);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TransformedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TransformedBag.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TransformedBag.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TransformedBag.java Mon Jan 7 17:15:14 2013
@@ -53,7 +53,7 @@ public class TransformedBag<E> extends T
* @return a new transformed Bag
* @throws IllegalArgumentException if bag or transformer is null
*/
- public static <E> Bag<E> transformingBag(Bag<E> bag, Transformer<? super E, ? extends E> transformer) {
+ public static <E> Bag<E> transformingBag(final Bag<E> bag, final Transformer<? super E, ? extends E> transformer) {
return new TransformedBag<E>(bag, transformer);
}
@@ -72,13 +72,14 @@ public class TransformedBag<E> extends T
* @throws IllegalArgumentException if bag or transformer is null
* @since 3.3
*/
- public static <E> Bag<E> transformedBag(Bag<E> bag, Transformer<? super E, ? extends E> transformer) {
- TransformedBag<E> decorated = new TransformedBag<E>(bag, transformer);
+ public static <E> Bag<E> transformedBag(final Bag<E> bag, final Transformer<? super E, ? extends E> transformer) {
+ final TransformedBag<E> decorated = new TransformedBag<E>(bag, transformer);
if (transformer != null && bag != null && bag.size() > 0) {
@SuppressWarnings("unchecked") // Bag is of type E
+ final
E[] values = (E[]) bag.toArray();
bag.clear();
- for (E value : values) {
+ for (final E value : values) {
decorated.decorated().add(transformer.transform(value));
}
}
@@ -96,7 +97,7 @@ public class TransformedBag<E> extends T
* @param transformer the transformer to use for conversion, must not be null
* @throws IllegalArgumentException if bag or transformer is null
*/
- protected TransformedBag(Bag<E> bag, Transformer<? super E, ? extends E> transformer) {
+ protected TransformedBag(final Bag<E> bag, final Transformer<? super E, ? extends E> transformer) {
super(bag, transformer);
}
@@ -111,22 +112,22 @@ public class TransformedBag<E> extends T
//-----------------------------------------------------------------------
- public int getCount(Object object) {
+ public int getCount(final Object object) {
return getBag().getCount(object);
}
- public boolean remove(Object object, int nCopies) {
+ public boolean remove(final Object object, final int nCopies) {
return getBag().remove(object, nCopies);
}
//-----------------------------------------------------------------------
- public boolean add(E object, int nCopies) {
+ public boolean add(final E object, final int nCopies) {
return getBag().add(transform(object), nCopies);
}
public Set<E> uniqueSet() {
- Set<E> set = getBag().uniqueSet();
+ final Set<E> set = getBag().uniqueSet();
return TransformedSet.<E>transformingSet(set, transformer);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TransformedSortedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TransformedSortedBag.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TransformedSortedBag.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TransformedSortedBag.java Mon Jan 7 17:15:14 2013
@@ -51,8 +51,8 @@ public class TransformedSortedBag<E> ext
* @return a new transformed SortedBag
* @throws IllegalArgumentException if bag or transformer is null
*/
- public static <E> TransformedSortedBag<E> transformingSortedBag(SortedBag<E> bag,
- Transformer<? super E, ? extends E> transformer) {
+ public static <E> TransformedSortedBag<E> transformingSortedBag(final SortedBag<E> bag,
+ final Transformer<? super E, ? extends E> transformer) {
return new TransformedSortedBag<E>(bag, transformer);
}
@@ -71,14 +71,15 @@ public class TransformedSortedBag<E> ext
* @throws IllegalArgumentException if bag or transformer is null
* @since 3.3
*/
- public static <E> TransformedSortedBag<E> transformedSortedBag(SortedBag<E> bag,
- Transformer<? super E, ? extends E> transformer) {
- TransformedSortedBag<E> decorated = new TransformedSortedBag<E>(bag, transformer);
+ public static <E> TransformedSortedBag<E> transformedSortedBag(final SortedBag<E> bag,
+ final Transformer<? super E, ? extends E> transformer) {
+ final TransformedSortedBag<E> decorated = new TransformedSortedBag<E>(bag, transformer);
if (transformer != null && bag != null && bag.size() > 0) {
@SuppressWarnings("unchecked") // bag is type E
+ final
E[] values = (E[]) bag.toArray();
bag.clear();
- for (E value : values) {
+ for (final E value : values) {
decorated.decorated().add(transformer.transform(value));
}
}
@@ -96,7 +97,7 @@ public class TransformedSortedBag<E> ext
* @param transformer the transformer to use for conversion, must not be null
* @throws IllegalArgumentException if bag or transformer is null
*/
- protected TransformedSortedBag(SortedBag<E> bag, Transformer<? super E, ? extends E> transformer) {
+ protected TransformedSortedBag(final SortedBag<E> bag, final Transformer<? super E, ? extends E> transformer) {
super(bag, transformer);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TreeBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TreeBag.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TreeBag.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/TreeBag.java Mon Jan 7 17:15:14 2013
@@ -61,7 +61,7 @@ public class TreeBag<E> extends Abstract
*
* @param comparator the comparator to use
*/
- public TreeBag(Comparator<? super E> comparator) {
+ public TreeBag(final Comparator<? super E> comparator) {
super(new TreeMap<E, MutableInteger>(comparator));
}
@@ -71,7 +71,7 @@ public class TreeBag<E> extends Abstract
*
* @param coll the collection to copy into the bag
*/
- public TreeBag(Collection<? extends E> coll) {
+ public TreeBag(final Collection<? extends E> coll) {
this();
addAll(coll);
}
@@ -84,7 +84,7 @@ public class TreeBag<E> extends Abstract
* {@link Comparable} and the {@link TreeBag} is using natural ordering
*/
@Override
- public boolean add(E object) {
+ public boolean add(final E object) {
if(comparator() == null && !(object instanceof Comparable)) {
throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " +
"a naturally ordered TreeBag as it does not implement Comparable");
@@ -115,7 +115,7 @@ public class TreeBag<E> extends Abstract
/**
* Write the bag out using a custom routine.
*/
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(comparator());
super.doWriteObject(out);
@@ -124,9 +124,10 @@ public class TreeBag<E> extends Abstract
/**
* Read the bag in using a custom routine.
*/
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
@SuppressWarnings("unchecked") // This will fail at runtime if the stream is incorrect
+ final
Comparator<? super E> comp = (Comparator<? super E>) in.readObject();
super.doReadObject(new TreeMap<E, MutableInteger>(comp), in);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/UnmodifiableBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/UnmodifiableBag.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/UnmodifiableBag.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/UnmodifiableBag.java Mon Jan 7 17:15:14 2013
@@ -55,7 +55,7 @@ public final class UnmodifiableBag<E>
* @return an unmodifiable Bag
* @throws IllegalArgumentException if bag is null
*/
- public static <E> Bag<E> unmodifiableBag(Bag<E> bag) {
+ public static <E> Bag<E> unmodifiableBag(final Bag<E> bag) {
if (bag instanceof Unmodifiable) {
return bag;
}
@@ -69,7 +69,7 @@ public final class UnmodifiableBag<E>
* @param bag the bag to decorate, must not be null
* @throws IllegalArgumentException if bag is null
*/
- private UnmodifiableBag(Bag<E> bag) {
+ private UnmodifiableBag(final Bag<E> bag) {
super(bag);
}
@@ -80,7 +80,7 @@ public final class UnmodifiableBag<E>
* @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(collection);
}
@@ -93,7 +93,7 @@ public final class UnmodifiableBag<E>
* @throws ClassNotFoundException
*/
@SuppressWarnings("unchecked")
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
collection = (Collection<E>) in.readObject();
}
@@ -106,12 +106,12 @@ public final class UnmodifiableBag<E>
}
@Override
- public boolean add(E object) {
+ public boolean add(final E object) {
throw new UnsupportedOperationException();
}
@Override
- public boolean addAll(Collection<? extends E> coll) {
+ public boolean addAll(final Collection<? extends E> coll) {
throw new UnsupportedOperationException();
}
@@ -121,34 +121,34 @@ public final class UnmodifiableBag<E>
}
@Override
- public boolean remove(Object object) {
+ public boolean remove(final Object object) {
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();
}
//-----------------------------------------------------------------------
@Override
- public boolean add(E object, int count) {
+ public boolean add(final E object, final int count) {
throw new UnsupportedOperationException();
}
@Override
- public boolean remove(Object object, int count) {
+ public boolean remove(final Object object, final int count) {
throw new UnsupportedOperationException();
}
@Override
public Set<E> uniqueSet() {
- Set<E> set = decorated().uniqueSet();
+ final Set<E> set = decorated().uniqueSet();
return UnmodifiableSet.<E> unmodifiableSet(set);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java Mon Jan 7 17:15:14 2013
@@ -55,7 +55,7 @@ public final class UnmodifiableSortedBag
* @return an unmodifiable SortedBag
* @throws IllegalArgumentException if bag is null
*/
- public static <E> SortedBag<E> unmodifiableSortedBag(SortedBag<E> bag) {
+ public static <E> SortedBag<E> unmodifiableSortedBag(final SortedBag<E> bag) {
if (bag instanceof Unmodifiable) {
return bag;
}
@@ -69,7 +69,7 @@ public final class UnmodifiableSortedBag
* @param bag the bag to decorate, must not be null
* @throws IllegalArgumentException if bag is null
*/
- private UnmodifiableSortedBag(SortedBag<E> bag) {
+ private UnmodifiableSortedBag(final SortedBag<E> bag) {
super(bag);
}
@@ -80,7 +80,7 @@ public final class UnmodifiableSortedBag
* @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(collection);
}
@@ -93,7 +93,7 @@ public final class UnmodifiableSortedBag
* @throws ClassNotFoundException
*/
@SuppressWarnings("unchecked")
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
collection = (Collection<E>) in.readObject();
}
@@ -105,12 +105,12 @@ public final class UnmodifiableSortedBag
}
@Override
- public boolean add(E object) {
+ public boolean add(final E object) {
throw new UnsupportedOperationException();
}
@Override
- public boolean addAll(Collection<? extends E> coll) {
+ public boolean addAll(final Collection<? extends E> coll) {
throw new UnsupportedOperationException();
}
@@ -120,34 +120,34 @@ public final class UnmodifiableSortedBag
}
@Override
- public boolean remove(Object object) {
+ public boolean remove(final Object object) {
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();
}
//-----------------------------------------------------------------------
@Override
- public boolean add(E object, int count) {
+ public boolean add(final E object, final int count) {
throw new UnsupportedOperationException();
}
@Override
- public boolean remove(Object object, int count) {
+ public boolean remove(final Object object, final int count) {
throw new UnsupportedOperationException();
}
@Override
public Set<E> uniqueSet() {
- Set<E> set = decorated().uniqueSet();
+ final Set<E> set = decorated().uniqueSet();
return UnmodifiableSet.unmodifiableSet(set);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractBidiMapDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractBidiMapDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractBidiMapDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractBidiMapDecorator.java Mon Jan 7 17:15:14 2013
@@ -44,7 +44,7 @@ public abstract class AbstractBidiMapDec
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if the collection is null
*/
- protected AbstractBidiMapDecorator(BidiMap<K, V> map) {
+ protected AbstractBidiMapDecorator(final BidiMap<K, V> map) {
super(map);
}
@@ -64,11 +64,11 @@ public abstract class AbstractBidiMapDec
return decorated().mapIterator();
}
- public K getKey(Object value) {
+ public K getKey(final Object value) {
return decorated().getKey(value);
}
- public K removeValue(Object value) {
+ public K removeValue(final Object value) {
return decorated().removeValue(value);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractDualBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractDualBidiMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractDualBidiMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractDualBidiMap.java Mon Jan 7 17:15:14 2013
@@ -96,7 +96,7 @@ public abstract class AbstractDualBidiMa
* @param reverseMap the reverse direction map
* @since 3.1
*/
- protected AbstractDualBidiMap(Map<K, V> normalMap, Map<V, K> reverseMap) {
+ protected AbstractDualBidiMap(final Map<K, V> normalMap, final Map<V, K> reverseMap) {
super();
this.normalMap = normalMap;
this.reverseMap = reverseMap;
@@ -110,7 +110,7 @@ public abstract class AbstractDualBidiMa
* @param reverseMap the reverse direction map
* @param inverseBidiMap the inverse BidiMap
*/
- protected AbstractDualBidiMap(Map<K, V> normalMap, Map<V, K> reverseMap, BidiMap<V, K> inverseBidiMap) {
+ protected AbstractDualBidiMap(final Map<K, V> normalMap, final Map<V, K> reverseMap, final BidiMap<V, K> inverseBidiMap) {
super();
this.normalMap = normalMap;
this.reverseMap = reverseMap;
@@ -130,7 +130,7 @@ public abstract class AbstractDualBidiMa
// Map delegation
//-----------------------------------------------------------------------
- public V get(Object key) {
+ public V get(final Object key) {
return normalMap.get(key);
}
@@ -142,12 +142,12 @@ public abstract class AbstractDualBidiMa
return normalMap.isEmpty();
}
- public boolean containsKey(Object key) {
+ public boolean containsKey(final Object key) {
return normalMap.containsKey(key);
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
return normalMap.equals(obj);
}
@@ -164,7 +164,7 @@ public abstract class AbstractDualBidiMa
// BidiMap changes
//-----------------------------------------------------------------------
- public V put(K key, V value) {
+ public V put(final K key, final V value) {
if (normalMap.containsKey(key)) {
reverseMap.remove(normalMap.get(key));
}
@@ -176,13 +176,13 @@ public abstract class AbstractDualBidiMa
return obj;
}
- 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());
}
}
- public V remove(Object key) {
+ public V remove(final Object key) {
V value = null;
if (normalMap.containsKey(key)) {
value = normalMap.remove(key);
@@ -196,7 +196,7 @@ public abstract class AbstractDualBidiMa
reverseMap.clear();
}
- public boolean containsValue(Object value) {
+ public boolean containsValue(final Object value) {
return reverseMap.containsKey(value);
}
@@ -217,11 +217,11 @@ public abstract class AbstractDualBidiMa
return new BidiMapIterator<K, V>(this);
}
- public K getKey(Object value) {
+ public K getKey(final Object value) {
return reverseMap.get(value);
}
- public K removeValue(Object value) {
+ public K removeValue(final Object value) {
K key = null;
if (reverseMap.containsKey(value)) {
key = reverseMap.remove(value);
@@ -260,7 +260,7 @@ public abstract class AbstractDualBidiMa
* @param iterator the iterator to decorate
* @return the keySet iterator
*/
- protected Iterator<K> createKeySetIterator(Iterator<K> iterator) {
+ protected Iterator<K> createKeySetIterator(final Iterator<K> iterator) {
return new KeySetIterator<K>(iterator, this);
}
@@ -285,7 +285,7 @@ public abstract class AbstractDualBidiMa
* @param iterator the iterator to decorate
* @return the values iterator
*/
- protected Iterator<V> createValuesIterator(Iterator<V> iterator) {
+ protected Iterator<V> createValuesIterator(final Iterator<V> iterator) {
return new ValuesIterator<V>(iterator, this);
}
@@ -314,7 +314,7 @@ public abstract class AbstractDualBidiMa
* @param iterator the iterator to decorate
* @return the entrySet iterator
*/
- protected Iterator<Map.Entry<K, V>> createEntrySetIterator(Iterator<Map.Entry<K, V>> iterator) {
+ protected Iterator<Map.Entry<K, V>> createEntrySetIterator(final Iterator<Map.Entry<K, V>> iterator) {
return new EntrySetIterator<K, V>(iterator, this);
}
@@ -334,13 +334,13 @@ public abstract class AbstractDualBidiMa
* @param coll the collection view being decorated
* @param parent the parent BidiMap
*/
- protected View(Collection<E> coll, AbstractDualBidiMap<K, V> parent) {
+ protected View(final Collection<E> coll, final AbstractDualBidiMap<K, V> parent) {
super(coll);
this.parent = parent;
}
@Override
- public boolean removeAll(Collection<?> coll) {
+ public boolean removeAll(final Collection<?> coll) {
if (parent.isEmpty() || coll.isEmpty()) {
return false;
}
@@ -353,7 +353,7 @@ public abstract class AbstractDualBidiMa
}
@Override
- public boolean retainAll(Collection<?> coll) {
+ public boolean retainAll(final Collection<?> coll) {
if (parent.isEmpty()) {
return false;
}
@@ -362,7 +362,7 @@ public abstract class AbstractDualBidiMa
return true;
}
boolean modified = false;
- Iterator<E> it = iterator();
+ final Iterator<E> it = iterator();
while (it.hasNext()) {
if (coll.contains(it.next()) == false) {
it.remove();
@@ -393,7 +393,7 @@ public abstract class AbstractDualBidiMa
* @param parent the parent BidiMap
*/
@SuppressWarnings("unchecked")
- protected KeySet(AbstractDualBidiMap<K, ?> parent) {
+ protected KeySet(final AbstractDualBidiMap<K, ?> parent) {
super(parent.normalMap.keySet(), (AbstractDualBidiMap<K, Object>) parent);
}
@@ -403,14 +403,14 @@ public abstract class AbstractDualBidiMa
}
@Override
- public boolean contains(Object key) {
+ public boolean contains(final Object key) {
return parent.normalMap.containsKey(key);
}
@Override
- public boolean remove(Object key) {
+ public boolean remove(final Object key) {
if (parent.normalMap.containsKey(key)) {
- Object value = parent.normalMap.remove(key);
+ final Object value = parent.normalMap.remove(key);
parent.reverseMap.remove(value);
return true;
}
@@ -437,7 +437,7 @@ public abstract class AbstractDualBidiMa
* @param iterator the iterator to decorate
* @param parent the parent map
*/
- protected KeySetIterator(Iterator<K> iterator, AbstractDualBidiMap<K, ?> parent) {
+ protected KeySetIterator(final Iterator<K> iterator, final AbstractDualBidiMap<K, ?> parent) {
super(iterator);
this.parent = parent;
}
@@ -454,7 +454,7 @@ public abstract class AbstractDualBidiMa
if (canRemove == false) {
throw new IllegalStateException("Iterator remove() can only be called once after next()");
}
- Object value = parent.normalMap.get(lastKey);
+ final Object value = parent.normalMap.get(lastKey);
super.remove();
parent.reverseMap.remove(value);
lastKey = null;
@@ -477,7 +477,7 @@ public abstract class AbstractDualBidiMa
* @param parent the parent BidiMap
*/
@SuppressWarnings("unchecked")
- protected Values(AbstractDualBidiMap<?, V> parent) {
+ protected Values(final AbstractDualBidiMap<?, V> parent) {
super(parent.normalMap.values(), (AbstractDualBidiMap<Object, V>) parent);
}
@@ -487,14 +487,14 @@ public abstract class AbstractDualBidiMa
}
@Override
- public boolean contains(Object value) {
+ public boolean contains(final Object value) {
return parent.reverseMap.containsKey(value);
}
@Override
- public boolean remove(Object value) {
+ public boolean remove(final Object value) {
if (parent.reverseMap.containsKey(value)) {
- Object key = parent.reverseMap.remove(value);
+ final Object key = parent.reverseMap.remove(value);
parent.normalMap.remove(key);
return true;
}
@@ -522,7 +522,7 @@ public abstract class AbstractDualBidiMa
* @param parent the parent map
*/
@SuppressWarnings("unchecked")
- protected ValuesIterator(Iterator<V> iterator, AbstractDualBidiMap<?, V> parent) {
+ protected ValuesIterator(final Iterator<V> iterator, final AbstractDualBidiMap<?, V> parent) {
super(iterator);
this.parent = (AbstractDualBidiMap<Object, V>) parent;
}
@@ -560,7 +560,7 @@ public abstract class AbstractDualBidiMa
*
* @param parent the parent BidiMap
*/
- protected EntrySet(AbstractDualBidiMap<K, V> parent) {
+ protected EntrySet(final AbstractDualBidiMap<K, V> parent) {
super(parent.normalMap.entrySet(), parent);
}
@@ -570,14 +570,14 @@ public abstract class AbstractDualBidiMa
}
@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();
+ final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
+ final Object key = entry.getKey();
if (parent.containsKey(key)) {
- V value = parent.normalMap.get(key);
+ final V value = parent.normalMap.get(key);
if (value == null ? entry.getValue() == null : value.equals(entry.getValue())) {
parent.normalMap.remove(key);
parent.reverseMap.remove(value);
@@ -607,7 +607,7 @@ public abstract class AbstractDualBidiMa
* @param iterator the iterator to decorate
* @param parent the parent map
*/
- protected EntrySetIterator(Iterator<Map.Entry<K, V>> iterator, AbstractDualBidiMap<K, V> parent) {
+ protected EntrySetIterator(final Iterator<Map.Entry<K, V>> iterator, final AbstractDualBidiMap<K, V> parent) {
super(iterator);
this.parent = parent;
}
@@ -625,7 +625,7 @@ public abstract class AbstractDualBidiMa
throw new IllegalStateException("Iterator remove() can only be called once after next()");
}
// store value as remove may change the entry in the decorator (eg.TreeMap)
- Object value = last.getValue();
+ final Object value = last.getValue();
super.remove();
parent.reverseMap.remove(value);
last = null;
@@ -646,14 +646,14 @@ public abstract class AbstractDualBidiMa
* @param entry the entry to decorate
* @param parent the parent map
*/
- protected MapEntry(Map.Entry<K, V> entry, AbstractDualBidiMap<K, V> parent) {
+ protected MapEntry(final Map.Entry<K, V> entry, final AbstractDualBidiMap<K, V> parent) {
super(entry);
this.parent = parent;
}
@Override
- public V setValue(V value) {
- K key = MapEntry.this.getKey();
+ public V setValue(final V value) {
+ final K key = MapEntry.this.getKey();
if (parent.reverseMap.containsKey(value) &&
parent.reverseMap.get(value) != key) {
throw new IllegalArgumentException(
@@ -686,7 +686,7 @@ public abstract class AbstractDualBidiMa
* Constructor.
* @param parent the parent map
*/
- protected BidiMapIterator(AbstractDualBidiMap<K, V> parent) {
+ protected BidiMapIterator(final AbstractDualBidiMap<K, V> parent) {
super();
this.parent = parent;
this.iterator = parent.normalMap.entrySet().iterator();
@@ -707,7 +707,7 @@ public abstract class AbstractDualBidiMa
throw new IllegalStateException("Iterator remove() can only be called once after next()");
}
// store value as remove may change the entry in the decorator (eg.TreeMap)
- V value = last.getValue();
+ final V value = last.getValue();
iterator.remove();
parent.reverseMap.remove(value);
last = null;
@@ -730,7 +730,7 @@ public abstract class AbstractDualBidiMa
return last.getValue();
}
- public V setValue(V value) {
+ public V setValue(final V value) {
if (last == null) {
throw new IllegalStateException(
"Iterator setValue() can only be called after next() and before remove()");
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractOrderedBidiMapDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractOrderedBidiMapDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractOrderedBidiMapDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractOrderedBidiMapDecorator.java Mon Jan 7 17:15:14 2013
@@ -44,7 +44,7 @@ public abstract class AbstractOrderedBid
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if the collection is null
*/
- protected AbstractOrderedBidiMapDecorator(OrderedBidiMap<K, V> map) {
+ protected AbstractOrderedBidiMapDecorator(final OrderedBidiMap<K, V> map) {
super(map);
}
@@ -72,11 +72,11 @@ public abstract class AbstractOrderedBid
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/bidimap/AbstractSortedBidiMapDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractSortedBidiMapDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractSortedBidiMapDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractSortedBidiMapDecorator.java Mon Jan 7 17:15:14 2013
@@ -45,7 +45,7 @@ public abstract class AbstractSortedBidi
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if the collection is null
*/
- public AbstractSortedBidiMapDecorator(SortedBidiMap<K, V> map) {
+ public AbstractSortedBidiMapDecorator(final SortedBidiMap<K, V> map) {
super(map);
}
@@ -73,15 +73,15 @@ public abstract class AbstractSortedBidi
return decorated().valueComparator();
}
- 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);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java Mon Jan 7 17:15:14 2013
@@ -57,7 +57,7 @@ public class DualHashBidiMap<K, V> exten
*
* @param map the map whose mappings are to be placed in this map
*/
- public DualHashBidiMap(Map<K, V> map) {
+ public DualHashBidiMap(final Map<K, V> map) {
super(new HashMap<K, V>(), new HashMap<V, K>());
putAll(map);
}
@@ -69,7 +69,7 @@ public class DualHashBidiMap<K, V> exten
* @param reverseMap the reverse direction map
* @param inverseBidiMap the inverse BidiMap
*/
- protected DualHashBidiMap(Map<K, V> normalMap, Map<V, K> reverseMap, BidiMap<V, K> inverseBidiMap) {
+ protected DualHashBidiMap(final Map<K, V> normalMap, final Map<V, K> reverseMap, final BidiMap<V, K> inverseBidiMap) {
super(normalMap, reverseMap, inverseBidiMap);
}
@@ -82,22 +82,23 @@ public class DualHashBidiMap<K, V> exten
* @return new bidi map
*/
@Override
- protected BidiMap<V, K> createBidiMap(Map<V, K> normalMap, Map<K, V> reverseMap, BidiMap<K, V> inverseBidiMap) {
+ protected BidiMap<V, K> createBidiMap(final Map<V, K> normalMap, final Map<K, V> reverseMap, final BidiMap<K, V> inverseBidiMap) {
return new DualHashBidiMap<V, K>(normalMap, reverseMap, inverseBidiMap);
}
// Serialization
//-----------------------------------------------------------------------
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(normalMap);
}
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
normalMap = new HashMap<K, V>();
reverseMap = new HashMap<V, K>();
@SuppressWarnings("unchecked") // will fail at runtime if stream is incorrect
+ final
Map<K, V> map = (Map<K, V>) in.readObject();
putAll(map);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java Mon Jan 7 17:15:14 2013
@@ -79,7 +79,7 @@ public class DualTreeBidiMap<K, V> exten
*
* @param map the map whose mappings are to be placed in this map
*/
- public DualTreeBidiMap(Map<K, V> map) {
+ public DualTreeBidiMap(final Map<K, V> map) {
super(new TreeMap<K, V>(), new TreeMap<V, K>());
putAll(map);
this.comparator = null;
@@ -92,7 +92,7 @@ public class DualTreeBidiMap<K, V> exten
* @param keyComparator the comparator
* @param valueComparator the values comparator to use
*/
- public DualTreeBidiMap(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator) {
+ public DualTreeBidiMap(final Comparator<? super K> keyComparator, final Comparator<? super V> valueComparator) {
super(new TreeMap<K, V>(keyComparator), new TreeMap<V, K>(valueComparator));
this.comparator = keyComparator;
this.valueComparator = valueComparator;
@@ -105,7 +105,7 @@ public class DualTreeBidiMap<K, V> exten
* @param reverseMap the reverse direction map
* @param inverseBidiMap the inverse BidiMap
*/
- protected DualTreeBidiMap(Map<K, V> normalMap, Map<V, K> reverseMap, BidiMap<V, K> inverseBidiMap) {
+ protected DualTreeBidiMap(final Map<K, V> normalMap, final Map<V, K> reverseMap, final BidiMap<V, K> inverseBidiMap) {
super(normalMap, reverseMap, inverseBidiMap);
this.comparator = ((SortedMap<K, V>) normalMap).comparator();
this.valueComparator = ((SortedMap<V, K>) reverseMap).comparator();
@@ -120,7 +120,7 @@ public class DualTreeBidiMap<K, V> exten
* @return new bidi map
*/
@Override
- protected DualTreeBidiMap<V, K> createBidiMap(Map<V, K> normalMap, Map<K, V> reverseMap, BidiMap<K, V> inverseMap) {
+ protected DualTreeBidiMap<V, K> createBidiMap(final Map<V, K> normalMap, final Map<K, V> reverseMap, final BidiMap<K, V> inverseMap) {
return new DualTreeBidiMap<V, K>(normalMap, reverseMap, inverseMap);
}
@@ -143,15 +143,15 @@ public class DualTreeBidiMap<K, V> exten
return ((SortedMap<K, V>) normalMap).lastKey();
}
- public K nextKey(K key) {
+ public K nextKey(final K key) {
if (isEmpty()) {
return null;
}
if (normalMap instanceof OrderedMap) {
return ((OrderedMap<K, ?>) normalMap).nextKey(key);
}
- SortedMap<K, V> sm = (SortedMap<K, V>) normalMap;
- Iterator<K> it = sm.tailMap(key).keySet().iterator();
+ final SortedMap<K, V> sm = (SortedMap<K, V>) normalMap;
+ final Iterator<K> it = sm.tailMap(key).keySet().iterator();
it.next();
if (it.hasNext()) {
return it.next();
@@ -159,15 +159,15 @@ public class DualTreeBidiMap<K, V> exten
return null;
}
- public K previousKey(K key) {
+ public K previousKey(final K key) {
if (isEmpty()) {
return null;
}
if (normalMap instanceof OrderedMap) {
return ((OrderedMap<K, V>) normalMap).previousKey(key);
}
- SortedMap<K, V> sm = (SortedMap<K, V>) normalMap;
- SortedMap<K, V> hm = sm.headMap(key);
+ final SortedMap<K, V> sm = (SortedMap<K, V>) normalMap;
+ final SortedMap<K, V> hm = sm.headMap(key);
if (hm.isEmpty()) {
return null;
}
@@ -198,18 +198,18 @@ public class DualTreeBidiMap<K, V> exten
//-----------------------------------------------------------------------
- public SortedMap<K, V> headMap(K toKey) {
- SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).headMap(toKey);
+ public SortedMap<K, V> headMap(final K toKey) {
+ final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).headMap(toKey);
return new ViewMap<K, V>(this, sub);
}
- public SortedMap<K, V> tailMap(K fromKey) {
- SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).tailMap(fromKey);
+ public SortedMap<K, V> tailMap(final K fromKey) {
+ final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).tailMap(fromKey);
return new ViewMap<K, V>(this, sub);
}
- public SortedMap<K, V> subMap(K fromKey, K toKey) {
- SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).subMap(fromKey, toKey);
+ public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
+ final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).subMap(fromKey, toKey);
return new ViewMap<K, V>(this, sub);
}
@@ -231,7 +231,7 @@ public class DualTreeBidiMap<K, V> exten
* @param bidi the parent bidi map
* @param sm the subMap sorted map
*/
- protected ViewMap(DualTreeBidiMap<K, V> bidi, SortedMap<K, V> sm) {
+ protected ViewMap(final DualTreeBidiMap<K, V> bidi, final SortedMap<K, V> sm) {
// the implementation is not great here...
// use the normalMap as the filtered map, but reverseMap as the full map
// this forces containsValue and clear to be overridden
@@ -240,7 +240,7 @@ public class DualTreeBidiMap<K, V> exten
}
@Override
- public boolean containsValue(Object value) {
+ public boolean containsValue(final Object value) {
// override as default implementation uses reverseMap
return decorated().normalMap.containsValue(value);
}
@@ -248,24 +248,24 @@ public class DualTreeBidiMap<K, V> exten
@Override
public void clear() {
// override as default implementation uses reverseMap
- for (Iterator<K> it = keySet().iterator(); it.hasNext();) {
+ for (final Iterator<K> it = keySet().iterator(); it.hasNext();) {
it.next();
it.remove();
}
}
@Override
- public SortedMap<K, V> headMap(K toKey) {
+ public SortedMap<K, V> headMap(final K toKey) {
return new ViewMap<K, V>(decorated(), super.headMap(toKey));
}
@Override
- public SortedMap<K, V> tailMap(K fromKey) {
+ public SortedMap<K, V> tailMap(final K fromKey) {
return new ViewMap<K, V>(decorated(), super.tailMap(fromKey));
}
@Override
- public SortedMap<K, V> subMap(K fromKey, K toKey) {
+ public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
return new ViewMap<K, V>(decorated(), super.subMap(fromKey, toKey));
}
@@ -275,12 +275,12 @@ public class DualTreeBidiMap<K, V> exten
}
@Override
- public K previousKey(K key) {
+ public K previousKey(final K key) {
return decorated().previousKey(key);
}
@Override
- public K nextKey(K key) {
+ public K nextKey(final K key) {
return decorated().nextKey(key);
}
}
@@ -304,7 +304,7 @@ public class DualTreeBidiMap<K, V> exten
* Constructor.
* @param parent the parent map
*/
- protected BidiOrderedMapIterator(AbstractDualBidiMap<K, V> parent) {
+ protected BidiOrderedMapIterator(final AbstractDualBidiMap<K, V> parent) {
super();
this.parent = parent;
iterator = new ArrayList<Map.Entry<K, V>>(parent.entrySet()).listIterator();
@@ -350,7 +350,7 @@ public class DualTreeBidiMap<K, V> exten
return last.getValue();
}
- public V setValue(V value) {
+ public V setValue(final V value) {
if (last == null) {
throw new IllegalStateException(
"Iterator setValue() can only be called after next() and before remove()");
@@ -379,16 +379,17 @@ public class DualTreeBidiMap<K, V> exten
// Serialization
//-----------------------------------------------------------------------
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(normalMap);
}
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
normalMap = new TreeMap<K, V>(comparator);
reverseMap = new TreeMap<V, K>(valueComparator);
@SuppressWarnings("unchecked") // will fail at runtime if the stream is incorrect
+ final
Map<K, V> map = (Map<K, V>) in.readObject();
putAll(map);
}