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 [5/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/bidimap/TreeBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/TreeBidiMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/TreeBidiMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/TreeBidiMap.java Mon Jan 7 17:15:14 2013
@@ -84,7 +84,7 @@ public class TreeBidiMap<K extends Compa
*
* @param description the description for the element
*/
- private DataElement(String description) {
+ private DataElement(final String description) {
this.description = description;
}
@@ -188,7 +188,7 @@ public class TreeBidiMap<K extends Compa
*/
public V get(final Object key) {
checkKey(key);
- Node<K, V> node = lookupKey(key);
+ final Node<K, V> node = lookupKey(key);
return node == null ? null : node.getValue();
}
@@ -217,7 +217,7 @@ public class TreeBidiMap<K extends Compa
* @throws NullPointerException if the key is null
*/
public V put(final K key, final V value) {
- V result = get(key);
+ final V result = get(key);
doPut(key, value);
return result;
}
@@ -229,8 +229,8 @@ public class TreeBidiMap<K extends Compa
*
* @param map the map to copy from
*/
- public void putAll(Map<? extends K, ? extends V> map) {
- for (Map.Entry<? extends K, ? extends V> e : map.entrySet()) {
+ public void putAll(final Map<? extends K, ? extends V> map) {
+ for (final Map.Entry<? extends K, ? extends V> e : map.entrySet()) {
put(e.getKey(), e.getValue());
}
}
@@ -276,7 +276,7 @@ public class TreeBidiMap<K extends Compa
*/
public K getKey(final Object value) {
checkValue(value);
- Node<K, V> node = lookupValue(value);
+ final Node<K, V> node = lookupValue(value);
return node == null ? null : node.getKey();
}
@@ -330,9 +330,9 @@ public class TreeBidiMap<K extends Compa
* @param key the key to search for next from
* @return the next key, null if no match or at end
*/
- public K nextKey(K key) {
+ public K nextKey(final K key) {
checkKey(key);
- Node<K, V> node = nextGreater(lookupKey(key), KEY);
+ final Node<K, V> node = nextGreater(lookupKey(key), KEY);
return node == null ? null : node.getKey();
}
@@ -344,9 +344,9 @@ public class TreeBidiMap<K extends Compa
* @param key the key to search for previous from
* @return the previous key, null if no match or at start
*/
- public K previousKey(K key) {
+ public K previousKey(final K key) {
checkKey(key);
- Node<K, V> node = nextSmaller(lookupKey(key), KEY);
+ final Node<K, V> node = nextSmaller(lookupKey(key), KEY);
return node == null ? null : node.getKey();
}
@@ -442,7 +442,7 @@ public class TreeBidiMap<K extends Compa
* @return true if equal
*/
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
return this.doEquals(obj, KEY);
}
@@ -483,7 +483,7 @@ public class TreeBidiMap<K extends Compa
Node<K, V> node = rootNode[KEY.ordinal()];
if (node == null) {
// map is empty
- Node<K, V> root = new Node<K, V>(key, value);
+ final Node<K, V> root = new Node<K, V>(key, value);
rootNode[KEY.ordinal()] = root;
rootNode[VALUE.ordinal()] = root;
grow();
@@ -491,7 +491,7 @@ public class TreeBidiMap<K extends Compa
} else {
// add new mapping
while (true) {
- int cmp = compare(key, node.getKey());
+ final int cmp = compare(key, node.getKey());
if (cmp == 0) {
// shouldn't happen
@@ -500,7 +500,7 @@ public class TreeBidiMap<K extends Compa
if (node.getLeft(KEY) != null) {
node = node.getLeft(KEY);
} else {
- Node<K, V> newNode = new Node<K, V>(key, value);
+ final Node<K, V> newNode = new Node<K, V>(key, value);
insertValue(newNode);
node.setLeft(newNode, KEY);
@@ -514,7 +514,7 @@ public class TreeBidiMap<K extends Compa
if (node.getRight(KEY) != null) {
node = node.getRight(KEY);
} else {
- Node<K, V> newNode = new Node<K, V>(key, value);
+ final Node<K, V> newNode = new Node<K, V>(key, value);
insertValue(newNode);
node.setRight(newNode, KEY);
@@ -529,8 +529,8 @@ public class TreeBidiMap<K extends Compa
}
}
- private V doRemoveKey(Object key) {
- Node<K, V> node = lookupKey(key);
+ private V doRemoveKey(final Object key) {
+ final Node<K, V> node = lookupKey(key);
if (node == null) {
return null;
}
@@ -538,8 +538,8 @@ public class TreeBidiMap<K extends Compa
return node.getValue();
}
- private K doRemoveValue(Object value) {
- Node<K, V> node = lookupValue(value);
+ private K doRemoveValue(final Object value) {
+ final Node<K, V> node = lookupValue(value);
if (node == null) {
return null;
}
@@ -561,7 +561,7 @@ public class TreeBidiMap<K extends Compa
Node<K, V> node = rootNode[dataElement.ordinal()];
while (node != null) {
- int cmp = compare((T) data, (T) node.getData(dataElement));
+ final int cmp = compare((T) data, (T) node.getData(dataElement));
if (cmp == 0) {
rval = node;
break;
@@ -573,11 +573,11 @@ public class TreeBidiMap<K extends Compa
return rval;
}
- private Node<K, V> lookupKey(Object key) {
+ private Node<K, V> lookupKey(final Object key) {
return this.<K>lookup(key, KEY);
}
- private Node<K, V> lookupValue(Object value) {
+ private Node<K, V> lookupValue(final Object value) {
return this.<V>lookup(value, VALUE);
}
@@ -815,7 +815,7 @@ public class TreeBidiMap<K extends Compa
* @param index the KEY or VALUE int
*/
private void rotateLeft(final Node<K, V> node, final DataElement dataElement) {
- Node<K, V> rightChild = node.getRight(dataElement);
+ final Node<K, V> rightChild = node.getRight(dataElement);
node.setRight(rightChild.getLeft(dataElement), dataElement);
if (rightChild.getLeft(dataElement) != null) {
@@ -843,7 +843,7 @@ public class TreeBidiMap<K extends Compa
* @param index the KEY or VALUE int
*/
private void rotateRight(final Node<K, V> node, final DataElement dataElement) {
- Node<K, V> leftChild = node.getLeft(dataElement);
+ final Node<K, V> leftChild = node.getLeft(dataElement);
node.setLeft(leftChild.getRight(dataElement), dataElement);
if (leftChild.getRight(dataElement) != null) {
leftChild.getRight(dataElement).setParent(node, dataElement);
@@ -878,7 +878,7 @@ public class TreeBidiMap<K extends Compa
&& currentNode != rootNode[dataElement.ordinal()]
&& isRed(currentNode.getParent(dataElement), dataElement)) {
if (currentNode.isLeftChild(dataElement)) {
- Node<K, V> y = getRightChild(getGrandParent(currentNode, dataElement), dataElement);
+ final Node<K, V> y = getRightChild(getGrandParent(currentNode, dataElement), dataElement);
if (isRed(y, dataElement)) {
makeBlack(getParent(currentNode, dataElement), dataElement);
@@ -904,7 +904,7 @@ public class TreeBidiMap<K extends Compa
} else {
// just like clause above, except swap left for right
- Node<K, V> y = getLeftChild(getGrandParent(currentNode, dataElement), dataElement);
+ final Node<K, V> y = getLeftChild(getGrandParent(currentNode, dataElement), dataElement);
if (isRed(y, dataElement)) {
makeBlack(getParent(currentNode, dataElement), dataElement);
@@ -940,14 +940,14 @@ public class TreeBidiMap<K extends Compa
* @param deletedNode the node to be deleted
*/
private void doRedBlackDelete(final Node<K, V> deletedNode) {
- for (DataElement dataElement : DataElement.values()) {
+ for (final DataElement dataElement : DataElement.values()) {
// if deleted node has both left and children, swap with
// the next greater node
if (deletedNode.getLeft(dataElement) != null && deletedNode.getRight(dataElement) != null) {
swapPosition(nextGreater(deletedNode, dataElement), deletedNode, dataElement);
}
- Node<K, V> replacement = deletedNode.getLeft(dataElement) != null ?
+ final Node<K, V> replacement = deletedNode.getLeft(dataElement) != null ?
deletedNode.getLeft(dataElement) : deletedNode.getRight(dataElement);
if (replacement != null) {
@@ -1091,15 +1091,15 @@ public class TreeBidiMap<K extends Compa
*/
private void swapPosition(final Node<K, V> x, final Node<K, V> y, final DataElement dataElement) {
// Save initial values.
- Node<K, V> xFormerParent = x.getParent(dataElement);
- Node<K, V> xFormerLeftChild = x.getLeft(dataElement);
- Node<K, V> xFormerRightChild = x.getRight(dataElement);
- Node<K, V> yFormerParent = y.getParent(dataElement);
- Node<K, V> yFormerLeftChild = y.getLeft(dataElement);
- Node<K, V> yFormerRightChild = y.getRight(dataElement);
- boolean xWasLeftChild =
+ final Node<K, V> xFormerParent = x.getParent(dataElement);
+ final Node<K, V> xFormerLeftChild = x.getLeft(dataElement);
+ final Node<K, V> xFormerRightChild = x.getRight(dataElement);
+ final Node<K, V> yFormerParent = y.getParent(dataElement);
+ final Node<K, V> yFormerLeftChild = y.getLeft(dataElement);
+ final Node<K, V> yFormerRightChild = y.getRight(dataElement);
+ final boolean xWasLeftChild =
x.getParent(dataElement) != null && x == x.getParent(dataElement).getLeft(dataElement);
- boolean yWasLeftChild =
+ final boolean yWasLeftChild =
y.getParent(dataElement) != null && y == y.getParent(dataElement).getLeft(dataElement);
// Swap, handling special cases of one being the other's parent.
@@ -1276,7 +1276,7 @@ public class TreeBidiMap<K extends Compa
Node<K, V> node = rootNode[VALUE.ordinal()];
while (true) {
- int cmp = compare(newNode.getValue(), node.getValue());
+ final int cmp = compare(newNode.getValue(), node.getValue());
if (cmp == 0) {
throw new IllegalArgumentException(
@@ -1313,30 +1313,30 @@ public class TreeBidiMap<K extends Compa
* @param type the KEY or VALUE int
* @return true if equal
*/
- private boolean doEquals(Object obj, DataElement dataElement) {
+ private boolean doEquals(final Object obj, final DataElement dataElement) {
if (obj == this) {
return true;
}
if (obj instanceof Map == false) {
return false;
}
- Map<?, ?> other = (Map<?, ?>) obj;
+ final Map<?, ?> other = (Map<?, ?>) obj;
if (other.size() != size()) {
return false;
}
if (nodeCount > 0) {
try {
- for (MapIterator<?, ?> it = getMapIterator(dataElement); it.hasNext(); ) {
- Object key = it.next();
- Object value = it.getValue();
+ for (final MapIterator<?, ?> it = getMapIterator(dataElement); it.hasNext(); ) {
+ final Object key = it.next();
+ final Object value = it.getValue();
if (value.equals(other.get(key)) == false) {
return false;
}
}
- } catch (ClassCastException ex) {
+ } catch (final ClassCastException ex) {
return false;
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
return false;
}
}
@@ -1349,12 +1349,12 @@ public class TreeBidiMap<K extends Compa
* @param type the KEY or VALUE int
* @return the hash code value for this map
*/
- private int doHashCode(DataElement dataElement) {
+ private int doHashCode(final DataElement dataElement) {
int total = 0;
if (nodeCount > 0) {
- for (MapIterator<?, ?> it = getMapIterator(dataElement); it.hasNext(); ) {
- Object key = it.next();
- Object value = it.getValue();
+ for (final MapIterator<?, ?> it = getMapIterator(dataElement); it.hasNext(); ) {
+ final Object key = it.next();
+ final Object value = it.getValue();
total += key.hashCode() ^ value.hashCode();
}
}
@@ -1367,17 +1367,17 @@ public class TreeBidiMap<K extends Compa
* @param type the KEY or VALUE int
* @return the string form of this map
*/
- private String doToString(DataElement dataElement) {
+ private String doToString(final DataElement dataElement) {
if (nodeCount == 0) {
return "{}";
}
- StringBuilder buf = new StringBuilder(nodeCount * 32);
+ final StringBuilder buf = new StringBuilder(nodeCount * 32);
buf.append('{');
- MapIterator<?, ?> it = getMapIterator(dataElement);
+ final MapIterator<?, ?> it = getMapIterator(dataElement);
boolean hasNext = it.hasNext();
while (hasNext) {
- Object key = it.next();
- Object value = it.getValue();
+ final Object key = it.next();
+ final Object value = it.getValue();
buf.append(key == this ? "(this Map)" : key)
.append('=')
.append(value == this ? "(this Map)" : value);
@@ -1392,7 +1392,7 @@ public class TreeBidiMap<K extends Compa
return buf.toString();
}
- private MapIterator<?, ?> getMapIterator(DataElement dataElement) {
+ private MapIterator<?, ?> getMapIterator(final DataElement dataElement) {
switch (dataElement) {
case KEY:
return new ViewMapIterator(KEY);
@@ -1438,7 +1438,7 @@ public class TreeBidiMap<K extends Compa
/**
* Create a new TreeBidiMap.KeyView.
*/
- public KeyView(DataElement orderType) {
+ public KeyView(final DataElement orderType) {
super(orderType);
}
@@ -1454,7 +1454,7 @@ public class TreeBidiMap<K extends Compa
}
@Override
- public boolean remove(Object o) {
+ public boolean remove(final Object o) {
return doRemoveKey(o) != null;
}
@@ -1465,7 +1465,7 @@ public class TreeBidiMap<K extends Compa
/**
* Create a new TreeBidiMap.ValueView.
*/
- public ValueView(DataElement orderType) {
+ public ValueView(final DataElement orderType) {
super(orderType);
}
@@ -1481,7 +1481,7 @@ public class TreeBidiMap<K extends Compa
}
@Override
- public boolean remove(Object o) {
+ public boolean remove(final Object o) {
return doRemoveValue(o) != null;
}
@@ -1497,24 +1497,24 @@ public class TreeBidiMap<K extends Compa
}
@Override
- public boolean contains(Object obj) {
+ public boolean contains(final Object obj) {
if (obj instanceof Map.Entry == false) {
return false;
}
- Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
- Object value = entry.getValue();
- Node<K, V> node = lookupKey(entry.getKey());
+ final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
+ final Object value = entry.getValue();
+ final Node<K, V> node = lookupKey(entry.getKey());
return node != null && node.getValue().equals(value);
}
@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 value = entry.getValue();
- Node<K, V> node = lookupKey(entry.getKey());
+ final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
+ final Object value = entry.getValue();
+ final Node<K, V> node = lookupKey(entry.getKey());
if (node != null && node.getValue().equals(value)) {
doRedBlackDelete(node);
return true;
@@ -1538,24 +1538,24 @@ public class TreeBidiMap<K extends Compa
}
@Override
- public boolean contains(Object obj) {
+ public boolean contains(final Object obj) {
if (obj instanceof Map.Entry == false) {
return false;
}
- Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
- Object value = entry.getValue();
- Node<K, V> node = lookupValue(entry.getKey());
+ final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
+ final Object value = entry.getValue();
+ final Node<K, V> node = lookupValue(entry.getKey());
return node != null && node.getKey().equals(value);
}
@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 value = entry.getValue();
- Node<K, V> node = lookupValue(entry.getKey());
+ final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
+ final Object value = entry.getValue();
+ final Node<K, V> node = lookupValue(entry.getKey());
if (node != null && node.getKey().equals(value)) {
doRedBlackDelete(node);
return true;
@@ -1664,7 +1664,7 @@ public class TreeBidiMap<K extends Compa
/**
* Constructor.
*/
- ViewMapIterator(DataElement orderType) {
+ ViewMapIterator(final DataElement orderType) {
super(orderType);
}
@@ -1705,7 +1705,7 @@ public class TreeBidiMap<K extends Compa
/**
* Create a new TreeBidiMap.InverseViewMapIterator.
*/
- public InverseViewMapIterator(DataElement orderType) {
+ public InverseViewMapIterator(final DataElement orderType) {
super(orderType);
}
@@ -1779,7 +1779,7 @@ public class TreeBidiMap<K extends Compa
return createEntry(navigatePrevious());
}
- private Map.Entry<V, K> createEntry(Node<K, V> node) {
+ private Map.Entry<V, K> createEntry(final Node<K, V> node) {
return new UnmodifiableMapEntry<V, K>(node.getValue(), node.getKey());
}
}
@@ -1983,7 +1983,7 @@ public class TreeBidiMap<K extends Compa
if (!(obj instanceof Map.Entry)) {
return false;
}
- Map.Entry<?, ?> e = (Map.Entry<?, ?>) obj;
+ final Map.Entry<?, ?> e = (Map.Entry<?, ?>) obj;
return getKey().equals(e.getKey()) && getValue().equals(e.getValue());
}
@@ -2051,26 +2051,26 @@ public class TreeBidiMap<K extends Compa
return greatestNode(TreeBidiMap.this.rootNode[VALUE.ordinal()], VALUE).getValue();
}
- public V nextKey(V key) {
+ public V nextKey(final V key) {
checkKey(key);
- Node<K, V> node = nextGreater(TreeBidiMap.this.<V>lookup(key, VALUE), VALUE);
+ final Node<K, V> node = nextGreater(TreeBidiMap.this.<V>lookup(key, VALUE), VALUE);
return node == null ? null : node.getValue();
}
- public V previousKey(V key) {
+ public V previousKey(final V key) {
checkKey(key);
- Node<K, V> node = TreeBidiMap.this.nextSmaller(TreeBidiMap.this.<V>lookup(key, VALUE), VALUE);
+ final Node<K, V> node = TreeBidiMap.this.nextSmaller(TreeBidiMap.this.<V>lookup(key, VALUE), VALUE);
return node == null ? null : node.getValue();
}
public K put(final V key, final K value) {
- K result = get(key);
+ final K result = get(key);
TreeBidiMap.this.doPut(value, key);
return result;
}
- public void putAll(Map<? extends V, ? extends K> map) {
- for (Map.Entry<? extends V, ? extends K> e : map.entrySet()) {
+ public void putAll(final Map<? extends V, ? extends K> map) {
+ for (final Map.Entry<? extends V, ? extends K> e : map.entrySet()) {
put(e.getKey(), e.getValue());
}
}
@@ -2120,7 +2120,7 @@ public class TreeBidiMap<K extends Compa
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
return TreeBidiMap.this.doEquals(obj, DataElement.VALUE);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableBidiMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableBidiMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableBidiMap.java Mon Jan 7 17:15:14 2013
@@ -53,7 +53,7 @@ public final class UnmodifiableBidiMap<K
* @return an unmodifiable BidiMap
* @throws IllegalArgumentException if map is null
*/
- public static <K, V> BidiMap<K, V> unmodifiableBidiMap(BidiMap<K, V> map) {
+ public static <K, V> BidiMap<K, V> unmodifiableBidiMap(final BidiMap<K, V> map) {
if (map instanceof Unmodifiable) {
return map;
}
@@ -67,7 +67,7 @@ public final class UnmodifiableBidiMap<K
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if map is null
*/
- private UnmodifiableBidiMap(BidiMap<K, V> map) {
+ private UnmodifiableBidiMap(final BidiMap<K, V> map) {
super(map);
}
@@ -78,47 +78,47 @@ public final class UnmodifiableBidiMap<K
}
@Override
- public V put(K key, V value) {
+ public V put(final K key, final V value) {
throw new UnsupportedOperationException();
}
@Override
- public void putAll(Map<? extends K, ? extends V> mapToCopy) {
+ public void putAll(final Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException();
}
@Override
- public V remove(Object key) {
+ public V remove(final Object key) {
throw new UnsupportedOperationException();
}
@Override
public Set<Map.Entry<K, V>> entrySet() {
- Set<Map.Entry<K, V>> set = super.entrySet();
+ final Set<Map.Entry<K, V>> set = super.entrySet();
return UnmodifiableEntrySet.unmodifiableEntrySet(set);
}
@Override
public Set<K> keySet() {
- Set<K> set = super.keySet();
+ final Set<K> set = super.keySet();
return UnmodifiableSet.unmodifiableSet(set);
}
@Override
public Collection<V> values() {
- Collection<V> coll = super.values();
+ final Collection<V> coll = super.values();
return UnmodifiableCollection.unmodifiableCollection(coll);
}
//-----------------------------------------------------------------------
@Override
- public K removeValue(Object value) {
+ public K removeValue(final Object value) {
throw new UnsupportedOperationException();
}
@Override
public MapIterator<K, V> mapIterator() {
- MapIterator<K, V> it = decorated().mapIterator();
+ final MapIterator<K, V> it = decorated().mapIterator();
return UnmodifiableMapIterator.unmodifiableMapIterator(it);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableOrderedBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableOrderedBidiMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableOrderedBidiMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableOrderedBidiMap.java Mon Jan 7 17:15:14 2013
@@ -53,7 +53,7 @@ public final class UnmodifiableOrderedBi
* @return an unmodifiable OrderedBidiMap
* @throws IllegalArgumentException if map is null
*/
- public static <K, V> OrderedBidiMap<K, V> unmodifiableOrderedBidiMap(OrderedBidiMap<K, V> map) {
+ public static <K, V> OrderedBidiMap<K, V> unmodifiableOrderedBidiMap(final OrderedBidiMap<K, V> map) {
if (map instanceof Unmodifiable) {
return map;
}
@@ -67,7 +67,7 @@ public final class UnmodifiableOrderedBi
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if map is null
*/
- private UnmodifiableOrderedBidiMap(OrderedBidiMap<K, V> map) {
+ private UnmodifiableOrderedBidiMap(final OrderedBidiMap<K, V> map) {
super(map);
}
@@ -78,41 +78,41 @@ public final class UnmodifiableOrderedBi
}
@Override
- public V put(K key, V value) {
+ public V put(final K key, final V value) {
throw new UnsupportedOperationException();
}
@Override
- public void putAll(Map<? extends K, ? extends V> mapToCopy) {
+ public void putAll(final Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException();
}
@Override
- public V remove(Object key) {
+ public V remove(final Object key) {
throw new UnsupportedOperationException();
}
@Override
public Set<Map.Entry<K, V>> entrySet() {
- Set<Map.Entry<K, V>> set = super.entrySet();
+ final Set<Map.Entry<K, V>> set = super.entrySet();
return UnmodifiableEntrySet.unmodifiableEntrySet(set);
}
@Override
public Set<K> keySet() {
- Set<K> set = super.keySet();
+ final Set<K> set = super.keySet();
return UnmodifiableSet.unmodifiableSet(set);
}
@Override
public Collection<V> values() {
- Collection<V> coll = super.values();
+ final Collection<V> coll = super.values();
return UnmodifiableCollection.unmodifiableCollection(coll);
}
//-----------------------------------------------------------------------
@Override
- public K removeValue(Object value) {
+ public K removeValue(final Object value) {
throw new UnsupportedOperationException();
}
@@ -124,7 +124,7 @@ public final class UnmodifiableOrderedBi
//-----------------------------------------------------------------------
@Override
public OrderedMapIterator<K, V> mapIterator() {
- OrderedMapIterator<K, V> it = decorated().mapIterator();
+ final OrderedMapIterator<K, V> it = decorated().mapIterator();
return UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableSortedBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableSortedBidiMap.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableSortedBidiMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/UnmodifiableSortedBidiMap.java Mon Jan 7 17:15:14 2013
@@ -55,7 +55,7 @@ public final class UnmodifiableSortedBid
* @return an unmodifiable SortedBidiMap
* @throws IllegalArgumentException if map is null
*/
- public static <K, V> SortedBidiMap<K, V> unmodifiableSortedBidiMap(SortedBidiMap<K, V> map) {
+ public static <K, V> SortedBidiMap<K, V> unmodifiableSortedBidiMap(final SortedBidiMap<K, V> map) {
if (map instanceof Unmodifiable) {
return map;
}
@@ -69,7 +69,7 @@ public final class UnmodifiableSortedBid
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if map is null
*/
- private UnmodifiableSortedBidiMap(SortedBidiMap<K, V> map) {
+ private UnmodifiableSortedBidiMap(final SortedBidiMap<K, V> map) {
super(map);
}
@@ -80,48 +80,48 @@ public final class UnmodifiableSortedBid
}
@Override
- public V put(K key, V value) {
+ public V put(final K key, final V value) {
throw new UnsupportedOperationException();
}
@Override
- public void putAll(Map<? extends K, ? extends V> mapToCopy) {
+ public void putAll(final Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException();
}
@Override
- public V remove(Object key) {
+ public V remove(final Object key) {
throw new UnsupportedOperationException();
}
@Override
public Set<Map.Entry<K, V>> entrySet() {
- Set<Map.Entry<K, V>> set = super.entrySet();
+ final Set<Map.Entry<K, V>> set = super.entrySet();
return UnmodifiableEntrySet.unmodifiableEntrySet(set);
}
@Override
public Set<K> keySet() {
- Set<K> set = super.keySet();
+ final Set<K> set = super.keySet();
return UnmodifiableSet.unmodifiableSet(set);
}
@Override
public Collection<V> values() {
- Collection<V> coll = super.values();
+ final Collection<V> coll = super.values();
return UnmodifiableCollection.unmodifiableCollection(coll);
}
//-----------------------------------------------------------------------
@Override
- public K removeValue(Object value) {
+ public K removeValue(final Object value) {
throw new UnsupportedOperationException();
}
//-----------------------------------------------------------------------
@Override
public OrderedMapIterator<K, V> mapIterator() {
- OrderedMapIterator<K, V> it = decorated().mapIterator();
+ final OrderedMapIterator<K, V> it = decorated().mapIterator();
return UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it);
}
@@ -136,20 +136,20 @@ public final class UnmodifiableSortedBid
}
@Override
- public SortedMap<K, V> subMap(K fromKey, K toKey) {
- SortedMap<K, V> sm = decorated().subMap(fromKey, toKey);
+ public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
+ final SortedMap<K, V> sm = decorated().subMap(fromKey, toKey);
return UnmodifiableSortedMap.unmodifiableSortedMap(sm);
}
@Override
- public SortedMap<K, V> headMap(K toKey) {
- SortedMap<K, V> sm = decorated().headMap(toKey);
+ public SortedMap<K, V> headMap(final K toKey) {
+ final SortedMap<K, V> sm = decorated().headMap(toKey);
return UnmodifiableSortedMap.unmodifiableSortedMap(sm);
}
@Override
- public SortedMap<K, V> tailMap(K fromKey) {
- SortedMap<K, V> sm = decorated().tailMap(fromKey);
+ public SortedMap<K, V> tailMap(final K fromKey) {
+ final SortedMap<K, V> sm = decorated().tailMap(fromKey);
return UnmodifiableSortedMap.unmodifiableSortedMap(sm);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/AbstractBufferDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/AbstractBufferDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/AbstractBufferDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/AbstractBufferDecorator.java Mon Jan 7 17:15:14 2013
@@ -48,7 +48,7 @@ public abstract class AbstractBufferDeco
* @param buffer the buffer to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
- protected AbstractBufferDecorator(Buffer<E> buffer) {
+ protected AbstractBufferDecorator(final Buffer<E> buffer) {
super(buffer);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BlockingBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BlockingBuffer.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BlockingBuffer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BlockingBuffer.java Mon Jan 7 17:15:14 2013
@@ -60,7 +60,7 @@ public class BlockingBuffer<E> extends S
* @return a new blocking Buffer
* @throws IllegalArgumentException if buffer is null
*/
- public static <E> BlockingBuffer<E> blockingBuffer(Buffer<E> buffer) {
+ public static <E> BlockingBuffer<E> blockingBuffer(final Buffer<E> buffer) {
return new BlockingBuffer<E>(buffer);
}
@@ -74,7 +74,7 @@ public class BlockingBuffer<E> extends S
* @throws IllegalArgumentException if the buffer is null
* @since 3.2
*/
- public static <E> BlockingBuffer<E> blockingBuffer(Buffer<E> buffer, long timeoutMillis) {
+ public static <E> BlockingBuffer<E> blockingBuffer(final Buffer<E> buffer, final long timeoutMillis) {
return new BlockingBuffer<E>(buffer, timeoutMillis);
}
@@ -85,7 +85,7 @@ public class BlockingBuffer<E> extends S
* @param buffer the buffer to decorate, must not be null
* @throws IllegalArgumentException if the buffer is null
*/
- protected BlockingBuffer(Buffer<E> buffer) {
+ protected BlockingBuffer(final Buffer<E> buffer) {
super(buffer);
this.timeout = 0;
}
@@ -98,25 +98,25 @@ public class BlockingBuffer<E> extends S
* @throws IllegalArgumentException if the buffer is null
* @since 3.2
*/
- protected BlockingBuffer(Buffer<E> buffer, long timeoutMillis) {
+ protected BlockingBuffer(final Buffer<E> buffer, final long timeoutMillis) {
super(buffer);
this.timeout = timeoutMillis < 0 ? 0 : timeoutMillis;
}
//-----------------------------------------------------------------------
@Override
- public boolean add(E o) {
+ public boolean add(final E o) {
synchronized (lock) {
- boolean result = collection.add(o);
+ final boolean result = collection.add(o);
lock.notifyAll();
return result;
}
}
@Override
- public boolean addAll(Collection<? extends E> c) {
+ public boolean addAll(final Collection<? extends E> c) {
synchronized (lock) {
- boolean result = collection.addAll(c);
+ final boolean result = collection.addAll(c);
lock.notifyAll();
return result;
}
@@ -140,8 +140,8 @@ public class BlockingBuffer<E> extends S
} else {
return get(timeout);
}
- } catch (InterruptedException e) {
- PrintWriter out = new PrintWriter(new StringWriter());
+ } catch (final InterruptedException e) {
+ final PrintWriter out = new PrintWriter(new StringWriter());
e.printStackTrace(out);
throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString());
}
@@ -168,8 +168,8 @@ public class BlockingBuffer<E> extends S
try {
lock.wait(timeLeft);
timeLeft = expiration - System.currentTimeMillis();
- } catch(InterruptedException e) {
- PrintWriter out = new PrintWriter(new StringWriter());
+ } catch(final InterruptedException e) {
+ final PrintWriter out = new PrintWriter(new StringWriter());
e.printStackTrace(out);
throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString());
}
@@ -199,8 +199,8 @@ public class BlockingBuffer<E> extends S
} else {
return remove(timeout);
}
- } catch (InterruptedException e) {
- PrintWriter out = new PrintWriter(new StringWriter());
+ } catch (final InterruptedException e) {
+ final PrintWriter out = new PrintWriter(new StringWriter());
e.printStackTrace(out);
throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString());
}
@@ -227,8 +227,8 @@ public class BlockingBuffer<E> extends S
try {
lock.wait(timeLeft);
timeLeft = expiration - System.currentTimeMillis();
- } catch(InterruptedException e) {
- PrintWriter out = new PrintWriter(new StringWriter());
+ } catch(final InterruptedException e) {
+ final PrintWriter out = new PrintWriter(new StringWriter());
e.printStackTrace(out);
throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString());
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedBuffer.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedBuffer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedBuffer.java Mon Jan 7 17:15:14 2013
@@ -66,7 +66,7 @@ public class BoundedBuffer<E> extends Sy
* @throws IllegalArgumentException if the buffer is null
* @throws IllegalArgumentException if the maximum size is zero or less
*/
- public static <E> BoundedBuffer<E> boundedBuffer(Buffer<E> buffer, int maximumSize) {
+ public static <E> BoundedBuffer<E> boundedBuffer(final Buffer<E> buffer, final int maximumSize) {
return new BoundedBuffer<E>(buffer, maximumSize, 0L);
}
@@ -82,7 +82,7 @@ public class BoundedBuffer<E> extends Sy
* @throws IllegalArgumentException if the buffer is null
* @throws IllegalArgumentException if the maximum size is zero or less
*/
- public static <E> BoundedBuffer<E> boundedBuffer(Buffer<E> buffer, int maximumSize, long timeout) {
+ public static <E> BoundedBuffer<E> boundedBuffer(final Buffer<E> buffer, final int maximumSize, final long timeout) {
return new BoundedBuffer<E>(buffer, maximumSize, timeout);
}
@@ -97,7 +97,7 @@ public class BoundedBuffer<E> extends Sy
* @throws IllegalArgumentException if the buffer is null
* @throws IllegalArgumentException if the maximum size is zero or less
*/
- protected BoundedBuffer(Buffer<E> buffer, int maximumSize, long timeout) {
+ protected BoundedBuffer(final Buffer<E> buffer, final int maximumSize, final long timeout) {
super(buffer);
if (maximumSize < 1) {
throw new IllegalArgumentException();
@@ -110,14 +110,14 @@ public class BoundedBuffer<E> extends Sy
@Override
public E remove() {
synchronized (lock) {
- E returnValue = decorated().remove();
+ final E returnValue = decorated().remove();
lock.notifyAll();
return returnValue;
}
}
@Override
- public boolean add(E o) {
+ public boolean add(final E o) {
synchronized (lock) {
timeoutWait(1);
return decorated().add(o);
@@ -165,8 +165,8 @@ public class BoundedBuffer<E> extends Sy
try {
lock.wait(timeLeft);
timeLeft = expiration - System.currentTimeMillis();
- } catch (InterruptedException ex) {
- PrintWriter out = new PrintWriter(new StringWriter());
+ } catch (final InterruptedException ex) {
+ final PrintWriter out = new PrintWriter(new StringWriter());
ex.printStackTrace(out);
throw new BufferUnderflowException(
"Caused by InterruptedException: " + out.toString());
@@ -197,7 +197,7 @@ public class BoundedBuffer<E> extends Sy
*
* @param it the decorated {@link Iterator}
*/
- public NotifyingIterator(Iterator<E> it) {
+ public NotifyingIterator(final Iterator<E> it) {
super(it);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java Mon Jan 7 17:15:14 2013
@@ -99,7 +99,7 @@ public class BoundedFifoBuffer<E> extend
* @throws IllegalArgumentException if the size is less than 1
*/
@SuppressWarnings("unchecked")
- public BoundedFifoBuffer(int size) {
+ public BoundedFifoBuffer(final int size) {
if (size <= 0) {
throw new IllegalArgumentException("The size must be greater than 0");
}
@@ -115,7 +115,7 @@ public class BoundedFifoBuffer<E> extend
* @param coll the collection whose elements to add, may not be null
* @throws NullPointerException if the collection is null
*/
- public BoundedFifoBuffer(Collection<? extends E> coll) {
+ public BoundedFifoBuffer(final Collection<? extends E> coll) {
this(coll.size());
addAll(coll);
}
@@ -127,10 +127,10 @@ public class BoundedFifoBuffer<E> extend
* @param out the output stream
* @throws IOException if an I/O error occurs while writing to the output stream
*/
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeInt(size());
- for (E e : this) {
+ for (final E e : this) {
out.writeObject(e);
}
}
@@ -143,10 +143,10 @@ public class BoundedFifoBuffer<E> extend
* @throws ClassNotFoundException if the class of a serialized object can not be found
*/
@SuppressWarnings("unchecked")
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
elements = (E[]) new Object[maxElements];
- int size = in.readInt();
+ final int size = in.readInt();
for (int i = 0; i < size; i++) {
elements[i] = (E) in.readObject();
}
@@ -228,7 +228,7 @@ public class BoundedFifoBuffer<E> extend
* @throws BufferOverflowException if this buffer is full
*/
@Override
- public boolean add(E element) {
+ public boolean add(final E element) {
if (null == element) {
throw new NullPointerException("Attempted to add null object to buffer");
}
@@ -270,7 +270,7 @@ public class BoundedFifoBuffer<E> extend
* @return the element at position {@code index}
* @throws NoSuchElementException if the requested position is outside the range [0, size)
*/
- public E get(int index) {
+ public E get(final int index) {
final int sz = size();
if (index < 0 || index >= sz) {
throw new NoSuchElementException(
@@ -293,7 +293,7 @@ public class BoundedFifoBuffer<E> extend
throw new BufferUnderflowException("The buffer is already empty");
}
- E element = elements[start];
+ final E element = elements[start];
if (null != element) {
elements[start++] = null;
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/CircularFifoBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/CircularFifoBuffer.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/CircularFifoBuffer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/CircularFifoBuffer.java Mon Jan 7 17:15:14 2013
@@ -61,7 +61,7 @@ public class CircularFifoBuffer<E> exten
* @param size the size of the buffer (cannot be changed)
* @throws IllegalArgumentException if the size is less than 1
*/
- public CircularFifoBuffer(int size) {
+ public CircularFifoBuffer(final int size) {
super(size);
}
@@ -72,7 +72,7 @@ public class CircularFifoBuffer<E> exten
* @param coll the collection to copy into the buffer, may not be null
* @throws NullPointerException if the collection is null
*/
- public CircularFifoBuffer(Collection<E> coll) {
+ public CircularFifoBuffer(final Collection<E> coll) {
super(coll);
}
@@ -84,7 +84,7 @@ public class CircularFifoBuffer<E> exten
* @return true, always
*/
@Override
- public boolean add(E element) {
+ public boolean add(final E element) {
if (isFull()) {
remove();
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/PredicatedBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/PredicatedBuffer.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/PredicatedBuffer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/PredicatedBuffer.java Mon Jan 7 17:15:14 2013
@@ -54,7 +54,7 @@ public class PredicatedBuffer<E> extends
* @throws IllegalArgumentException if buffer or predicate is null
* @throws IllegalArgumentException if the buffer contains invalid elements
*/
- public static <E> PredicatedBuffer<E> predicatedBuffer(Buffer<E> buffer, Predicate<? super E> predicate) {
+ public static <E> PredicatedBuffer<E> predicatedBuffer(final Buffer<E> buffer, final Predicate<? super E> predicate) {
return new PredicatedBuffer<E>(buffer, predicate);
}
@@ -70,7 +70,7 @@ public class PredicatedBuffer<E> extends
* @throws IllegalArgumentException if buffer or predicate is null
* @throws IllegalArgumentException if the buffer contains invalid elements
*/
- protected PredicatedBuffer(Buffer<E> buffer, Predicate<? super E> predicate) {
+ protected PredicatedBuffer(final Buffer<E> buffer, final Predicate<? super E> predicate) {
super(buffer, predicate);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/PriorityBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/PriorityBuffer.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/PriorityBuffer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/PriorityBuffer.java Mon Jan 7 17:15:14 2013
@@ -104,7 +104,7 @@ public class PriorityBuffer<E> extends A
* @param comparator the comparator used to order the elements,
* null means use natural order
*/
- public PriorityBuffer(Comparator<? super E> comparator) {
+ public PriorityBuffer(final Comparator<? super E> comparator) {
this(DEFAULT_CAPACITY, true, comparator);
}
@@ -115,7 +115,7 @@ public class PriorityBuffer<E> extends A
* @param ascendingOrder if <code>true</code> the heap is created as a
* minimum heap; otherwise, the heap is created as a maximum heap
*/
- public PriorityBuffer(boolean ascendingOrder) {
+ public PriorityBuffer(final boolean ascendingOrder) {
this(DEFAULT_CAPACITY, ascendingOrder, null);
}
@@ -127,7 +127,7 @@ public class PriorityBuffer<E> extends A
* @param comparator the comparator used to order the elements,
* null means use natural order
*/
- public PriorityBuffer(boolean ascendingOrder, Comparator<? super E> comparator) {
+ public PriorityBuffer(final boolean ascendingOrder, final Comparator<? super E> comparator) {
this(DEFAULT_CAPACITY, ascendingOrder, comparator);
}
@@ -138,7 +138,7 @@ public class PriorityBuffer<E> extends A
* @param capacity the initial capacity for the buffer, greater than zero
* @throws IllegalArgumentException if <code>capacity</code> is <= <code>0</code>
*/
- public PriorityBuffer(int capacity) {
+ public PriorityBuffer(final int capacity) {
this(capacity, true, null);
}
@@ -151,7 +151,7 @@ public class PriorityBuffer<E> extends A
* null means use natural order
* @throws IllegalArgumentException if <code>capacity</code> is <= <code>0</code>
*/
- public PriorityBuffer(int capacity, Comparator<? super E> comparator) {
+ public PriorityBuffer(final int capacity, final Comparator<? super E> comparator) {
this(capacity, true, comparator);
}
@@ -164,7 +164,7 @@ public class PriorityBuffer<E> extends A
* minimum heap; otherwise, the heap is created as a maximum heap.
* @throws IllegalArgumentException if <code>capacity</code> is <code><= 0</code>
*/
- public PriorityBuffer(int capacity, boolean ascendingOrder) {
+ public PriorityBuffer(final int capacity, final boolean ascendingOrder) {
this(capacity, ascendingOrder, null);
}
@@ -180,7 +180,7 @@ public class PriorityBuffer<E> extends A
* @throws IllegalArgumentException if <code>capacity</code> is <code><= 0</code>
*/
@SuppressWarnings("unchecked")
- public PriorityBuffer(int capacity, boolean ascendingOrder, Comparator<? super E> comparator) {
+ public PriorityBuffer(final int capacity, final boolean ascendingOrder, final Comparator<? super E> comparator) {
super();
if (capacity <= 0) {
throw new IllegalArgumentException("invalid capacity");
@@ -241,7 +241,7 @@ public class PriorityBuffer<E> extends A
* @return true always
*/
@Override
- public boolean add(E element) {
+ public boolean add(final E element) {
if (isAtCapacity()) {
grow();
}
@@ -378,7 +378,7 @@ public class PriorityBuffer<E> extends A
*/
protected void percolateUpMinHeap(final int index) {
int hole = index;
- E element = elements[hole];
+ final E element = elements[hole];
while (hole > 1 && compare(element, elements[hole / 2]) < 0) {
// save element that is being pushed down
// as the element "bubble" is percolated up
@@ -410,7 +410,7 @@ public class PriorityBuffer<E> extends A
*/
protected void percolateUpMaxHeap(final int index) {
int hole = index;
- E element = elements[hole];
+ final E element = elements[hole];
while (hole > 1 && compare(element, elements[hole / 2]) > 0) {
// save element that is being pushed down
@@ -443,7 +443,7 @@ public class PriorityBuffer<E> extends A
* @param b the second object
* @return -ve if a less than b, 0 if they are equal, +ve if a greater than b
*/
- protected int compare(E a, E b) {
+ protected int compare(final E a, final E b) {
return comparator.compare(a, b);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java Mon Jan 7 17:15:14 2013
@@ -46,7 +46,7 @@ public class SynchronizedBuffer<E>
* @return a new synchronized Buffer
* @throws IllegalArgumentException if buffer is null
*/
- public static <E> SynchronizedBuffer<E> synchronizedBuffer(Buffer<E> buffer) {
+ public static <E> SynchronizedBuffer<E> synchronizedBuffer(final Buffer<E> buffer) {
return new SynchronizedBuffer<E>(buffer);
}
@@ -57,7 +57,7 @@ public class SynchronizedBuffer<E>
* @param buffer the buffer to decorate, must not be null
* @throws IllegalArgumentException if the buffer is null
*/
- protected SynchronizedBuffer(Buffer<E> buffer) {
+ protected SynchronizedBuffer(final Buffer<E> buffer) {
super(buffer);
}
@@ -68,7 +68,7 @@ public class SynchronizedBuffer<E>
* @param lock the lock object to use, must not be null
* @throws IllegalArgumentException if the buffer is null
*/
- protected SynchronizedBuffer(Buffer<E> buffer, Object lock) {
+ protected SynchronizedBuffer(final Buffer<E> buffer, final Object lock) {
super(buffer, lock);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/TransformedBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/TransformedBuffer.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/TransformedBuffer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/TransformedBuffer.java Mon Jan 7 17:15:14 2013
@@ -51,8 +51,8 @@ public class TransformedBuffer<E> extend
* @return a new transformed Buffer
* @throws IllegalArgumentException if buffer or transformer is null
*/
- public static <E> TransformedBuffer<E> transformingBuffer(Buffer<E> buffer,
- Transformer<? super E, ? extends E> transformer) {
+ public static <E> TransformedBuffer<E> transformingBuffer(final Buffer<E> buffer,
+ final Transformer<? super E, ? extends E> transformer) {
return new TransformedBuffer<E>(buffer, transformer);
}
@@ -71,15 +71,16 @@ public class TransformedBuffer<E> extend
* @throws IllegalArgumentException if buffer or transformer is null
* @since 3.3
*/
- public static <E> TransformedBuffer<E> transformedBuffer(Buffer<E> buffer,
- Transformer<? super E, ? extends E> transformer) {
+ public static <E> TransformedBuffer<E> transformedBuffer(final Buffer<E> buffer,
+ final Transformer<? super E, ? extends E> transformer) {
// throws IAE if buffer or transformer is null
final TransformedBuffer<E> decorated = new TransformedBuffer<E>(buffer, transformer);
if (buffer.size() > 0) {
@SuppressWarnings("unchecked") // buffer is type <E>
+ final
E[] values = (E[]) buffer.toArray();
buffer.clear();
- for (E value : values) {
+ for (final E value : values) {
decorated.decorated().add(transformer.transform(value));
}
}
@@ -97,7 +98,7 @@ public class TransformedBuffer<E> extend
* @param transformer the transformer to use for conversion, must not be null
* @throws IllegalArgumentException if buffer or transformer is null
*/
- protected TransformedBuffer(Buffer<E> buffer, Transformer<? super E, ? extends E> transformer) {
+ protected TransformedBuffer(final Buffer<E> buffer, final Transformer<? super E, ? extends E> transformer) {
super(buffer, transformer);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/UnboundedFifoBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/UnboundedFifoBuffer.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/UnboundedFifoBuffer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/UnboundedFifoBuffer.java Mon Jan 7 17:15:14 2013
@@ -90,7 +90,7 @@ public class UnboundedFifoBuffer<E> exte
* @throws IllegalArgumentException if the size is less than 1
*/
@SuppressWarnings("unchecked")
- public UnboundedFifoBuffer(int initialSize) {
+ public UnboundedFifoBuffer(final int initialSize) {
if (initialSize <= 0) {
throw new IllegalArgumentException("The size must be greater than 0");
}
@@ -106,11 +106,11 @@ public class UnboundedFifoBuffer<E> exte
* @param out the output stream
* @throws IOException if an I/O error occurs while writing to the output stream
*/
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeInt(size());
out.writeInt(buffer.length);
- for (E e : this) {
+ for (final E e : this) {
out.writeObject(e);
}
}
@@ -123,10 +123,10 @@ public class UnboundedFifoBuffer<E> exte
* @throws ClassNotFoundException if the class of a serialized object can not be found
*/
@SuppressWarnings("unchecked")
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
- int size = in.readInt();
- int length = in.readInt();
+ final int size = in.readInt();
+ final int length = in.readInt();
buffer = (E[]) new Object[length];
for (int i = 0; i < size; i++) {
buffer[i] = (E) in.readObject();
@@ -180,7 +180,7 @@ public class UnboundedFifoBuffer<E> exte
if (size() + 1 >= buffer.length) {
// copy contents to a new buffer array
- E[] tmp = (E[]) new Object[(buffer.length - 1) * 2 + 1];
+ final E[] tmp = (E[]) new Object[(buffer.length - 1) * 2 + 1];
int j = 0;
// move head to element zero in the new array
for (int i = head; i != tail;) {
@@ -225,7 +225,7 @@ public class UnboundedFifoBuffer<E> exte
throw new BufferUnderflowException("The buffer is already empty");
}
- E element = buffer[head];
+ final E element = buffer[head];
if (element != null) {
buffer[head] = null;
head = increment(head);
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java Mon Jan 7 17:15:14 2013
@@ -54,7 +54,7 @@ public final class UnmodifiableBuffer<E>
* @return an unmodifiable Buffer
* @throws IllegalArgumentException if buffer is null
*/
- public static <E> Buffer<E> unmodifiableBuffer(Buffer<E> buffer) {
+ public static <E> Buffer<E> unmodifiableBuffer(final Buffer<E> buffer) {
if (buffer instanceof Unmodifiable) {
return buffer;
}
@@ -68,7 +68,7 @@ public final class UnmodifiableBuffer<E>
* @param buffer the buffer to decorate, must not be null
* @throws IllegalArgumentException if buffer is null
*/
- private UnmodifiableBuffer(Buffer<E> buffer) {
+ private UnmodifiableBuffer(final Buffer<E> buffer) {
super(buffer);
}
@@ -79,7 +79,7 @@ public final class UnmodifiableBuffer<E>
* @param out the output stream
* @throws IOException if an I/O error occurs while writing to the output stream
*/
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(collection);
}
@@ -92,7 +92,7 @@ public final class UnmodifiableBuffer<E>
* @throws ClassNotFoundException if the class of a serialized object can not be found
*/
@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();
}
@@ -104,12 +104,12 @@ public final class UnmodifiableBuffer<E>
}
@Override
- public boolean add(Object object) {
+ public boolean add(final Object object) {
throw new UnsupportedOperationException();
}
@Override
- public boolean addAll(Collection<? extends E> coll) {
+ public boolean addAll(final Collection<? extends E> coll) {
throw new UnsupportedOperationException();
}
@@ -119,17 +119,17 @@ public final class UnmodifiableBuffer<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();
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java Mon Jan 7 17:15:14 2013
@@ -62,7 +62,7 @@ public abstract class AbstractCollection
* @param coll the collection to decorate, must not be null
* @throws IllegalArgumentException if the collection is null
*/
- protected AbstractCollectionDecorator(Collection<E> coll) {
+ protected AbstractCollectionDecorator(final Collection<E> coll) {
if (coll == null) {
throw new IllegalArgumentException("Collection must not be null");
}
@@ -81,11 +81,11 @@ public abstract class AbstractCollection
//-----------------------------------------------------------------------
- public boolean add(E object) {
+ public boolean add(final E object) {
return decorated().add(object);
}
- public boolean addAll(Collection<? extends E> coll) {
+ public boolean addAll(final Collection<? extends E> coll) {
return decorated().addAll(coll);
}
@@ -93,7 +93,7 @@ public abstract class AbstractCollection
decorated().clear();
}
- public boolean contains(Object object) {
+ public boolean contains(final Object object) {
return decorated().contains(object);
}
@@ -105,7 +105,7 @@ public abstract class AbstractCollection
return decorated().iterator();
}
- public boolean remove(Object object) {
+ public boolean remove(final Object object) {
return decorated().remove(object);
}
@@ -117,24 +117,24 @@ public abstract class AbstractCollection
return decorated().toArray();
}
- public <T> T[] toArray(T[] object) {
+ public <T> T[] toArray(final T[] object) {
return decorated().toArray(object);
}
- public boolean containsAll(Collection<?> coll) {
+ public boolean containsAll(final Collection<?> coll) {
return decorated().containsAll(coll);
}
- public boolean removeAll(Collection<?> coll) {
+ public boolean removeAll(final Collection<?> coll) {
return decorated().removeAll(coll);
}
- public boolean retainAll(Collection<?> coll) {
+ public boolean retainAll(final Collection<?> coll) {
return decorated().retainAll(coll);
}
@Override
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
return object == this || decorated().equals(object);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/AbstractUntypedCollectionDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/AbstractUntypedCollectionDecorator.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/AbstractUntypedCollectionDecorator.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/AbstractUntypedCollectionDecorator.java Mon Jan 7 17:15:14 2013
@@ -70,7 +70,7 @@ public abstract class AbstractUntypedCol
decorated().clear();
}
- public boolean contains(Object object) {
+ public boolean contains(final Object object) {
return decorated().contains(object);
}
@@ -78,7 +78,7 @@ public abstract class AbstractUntypedCol
return decorated().isEmpty();
}
- public boolean remove(Object object) {
+ public boolean remove(final Object object) {
return decorated().remove(object);
}
@@ -90,24 +90,24 @@ public abstract class AbstractUntypedCol
return decorated().toArray();
}
- public <T> T[] toArray(T[] object) {
+ public <T> T[] toArray(final T[] object) {
return decorated().toArray(object);
}
- public boolean containsAll(Collection<?> coll) {
+ public boolean containsAll(final Collection<?> coll) {
return decorated().containsAll(coll);
}
- public boolean removeAll(Collection<?> coll) {
+ public boolean removeAll(final Collection<?> coll) {
return decorated().removeAll(coll);
}
- public boolean retainAll(Collection<?> coll) {
+ public boolean retainAll(final Collection<?> coll) {
return decorated().retainAll(coll);
}
@Override
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
return object == this || decorated().equals(object);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/CompositeCollection.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/CompositeCollection.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/CompositeCollection.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/CompositeCollection.java Mon Jan 7 17:15:14 2013
@@ -62,7 +62,7 @@ public class CompositeCollection<E> impl
*
* @param compositeCollection the Collection to be appended to the composite
*/
- public CompositeCollection(Collection<E> compositeCollection) {
+ public CompositeCollection(final Collection<E> compositeCollection) {
super();
addComposited(compositeCollection);
}
@@ -73,7 +73,7 @@ public class CompositeCollection<E> impl
* @param compositeCollection1 the Collection to be appended to the composite
* @param compositeCollection2 the Collection to be appended to the composite
*/
- public CompositeCollection(Collection<E> compositeCollection1, Collection<E> compositeCollection2) {
+ public CompositeCollection(final Collection<E> compositeCollection1, final Collection<E> compositeCollection2) {
super();
addComposited(compositeCollection1, compositeCollection2);
}
@@ -83,7 +83,7 @@ public class CompositeCollection<E> impl
*
* @param compositeCollections the collections to composite
*/
- public CompositeCollection(Collection<E>[] compositeCollections) {
+ public CompositeCollection(final Collection<E>[] compositeCollections) {
super();
addComposited(compositeCollections);
}
@@ -108,7 +108,7 @@ public class CompositeCollection<E> impl
*/
public int size() {
int size = 0;
- for (Collection<E> item : all) {
+ for (final Collection<E> item : all) {
size += item.size();
}
return size;
@@ -122,7 +122,7 @@ public class CompositeCollection<E> impl
* @return true if all of the contained collections are empty
*/
public boolean isEmpty() {
- for (Collection<? extends E> item : all) {
+ for (final Collection<? extends E> item : all) {
if (item.isEmpty() == false) {
return false;
}
@@ -138,8 +138,8 @@ public class CompositeCollection<E> impl
* @param obj the object to search for
* @return true if obj is contained in any of the contained collections
*/
- public boolean contains(Object obj) {
- for (Collection<? extends E> item : all) {
+ public boolean contains(final Object obj) {
+ for (final Collection<? extends E> item : all) {
if (item.contains(obj)) {
return true;
}
@@ -161,8 +161,8 @@ public class CompositeCollection<E> impl
if (all.isEmpty()) {
return EmptyIterator.<E>emptyIterator();
}
- IteratorChain<E> chain = new IteratorChain<E>();
- for (Collection<? extends E> item : all) {
+ final IteratorChain<E> chain = new IteratorChain<E>();
+ for (final Collection<? extends E> item : all) {
chain.addIterator(item.iterator());
}
return chain;
@@ -176,7 +176,7 @@ public class CompositeCollection<E> impl
public Object[] toArray() {
final Object[] result = new Object[size()];
int i = 0;
- for (Iterator<E> it = iterator(); it.hasNext(); i++) {
+ for (final Iterator<E> it = iterator(); it.hasNext(); i++) {
result[i] = it.next();
}
return result;
@@ -191,8 +191,8 @@ public class CompositeCollection<E> impl
* @return an array of all the elements in the collection
*/
@SuppressWarnings("unchecked")
- public <T> T[] toArray(T[] array) {
- int size = size();
+ public <T> T[] toArray(final T[] array) {
+ final int size = size();
Object[] result = null;
if (array.length >= size) {
result = array;
@@ -201,8 +201,8 @@ public class CompositeCollection<E> impl
}
int offset = 0;
- for (Collection<? extends E> item : all) {
- for (E e : item) {
+ for (final Collection<? extends E> item : all) {
+ for (final E e : item) {
result[offset++] = e;
}
}
@@ -224,7 +224,7 @@ public class CompositeCollection<E> impl
* @throws NullPointerException if the object cannot be added because its null
* @throws IllegalArgumentException if the object cannot be added
*/
- public boolean add(E obj) {
+ public boolean add(final E obj) {
if (mutator == null) {
throw new UnsupportedOperationException(
"add() is not supported on CompositeCollection without a CollectionMutator strategy");
@@ -243,7 +243,7 @@ public class CompositeCollection<E> impl
* @throws NullPointerException if the object cannot be removed because its null
* @throws IllegalArgumentException if the object cannot be removed
*/
- public boolean remove(Object obj) {
+ public boolean remove(final Object obj) {
if (mutator == null) {
throw new UnsupportedOperationException(
"remove() is not supported on CompositeCollection without a CollectionMutator strategy");
@@ -260,8 +260,8 @@ public class CompositeCollection<E> impl
* @param coll the collection to check for
* @return true if all elements contained
*/
- public boolean containsAll(Collection<?> coll) {
- for (Object item : coll) {
+ public boolean containsAll(final Collection<?> coll) {
+ for (final Object item : coll) {
if (contains(item) == false) {
return false;
}
@@ -281,7 +281,7 @@ public class CompositeCollection<E> impl
* @throws NullPointerException if the object cannot be added because its null
* @throws IllegalArgumentException if the object cannot be added
*/
- public boolean addAll(Collection<? extends E> coll) {
+ public boolean addAll(final Collection<? extends E> coll) {
if (mutator == null) {
throw new UnsupportedOperationException(
"addAll() is not supported on CompositeCollection without a CollectionMutator strategy");
@@ -298,12 +298,12 @@ public class CompositeCollection<E> impl
* @return true if the collection was modified
* @throws UnsupportedOperationException if removeAll is unsupported
*/
- public boolean removeAll(Collection<?> coll) {
+ public boolean removeAll(final Collection<?> coll) {
if (coll.size() == 0) {
return false;
}
boolean changed = false;
- for (Collection<? extends E> item : all) {
+ for (final Collection<? extends E> item : all) {
changed |= item.removeAll(coll);
}
return changed;
@@ -321,7 +321,7 @@ public class CompositeCollection<E> impl
*/
public boolean retainAll(final Collection<?> coll) {
boolean changed = false;
- for (Collection<? extends E> item : all) {
+ for (final Collection<? extends E> item : all) {
changed |= item.retainAll(coll);
}
return changed;
@@ -335,7 +335,7 @@ public class CompositeCollection<E> impl
* @throws UnsupportedOperationException if clear is unsupported
*/
public void clear() {
- for (Collection<? extends E> coll : all) {
+ for (final Collection<? extends E> coll : all) {
coll.clear();
}
}
@@ -346,7 +346,7 @@ public class CompositeCollection<E> impl
*
* @param mutator the mutator to use
*/
- public void setMutator(CollectionMutator<E> mutator) {
+ public void setMutator(final CollectionMutator<E> mutator) {
this.mutator = mutator;
}
@@ -355,7 +355,7 @@ public class CompositeCollection<E> impl
*
* @param compositeCollection the Collection to be appended to the composite
*/
- public void addComposited(Collection<E> compositeCollection) {
+ public void addComposited(final Collection<E> compositeCollection) {
all.add(compositeCollection);
}
@@ -365,7 +365,7 @@ public class CompositeCollection<E> impl
* @param compositeCollection1 the Collection to be appended to the composite
* @param compositeCollection2 the Collection to be appended to the composite
*/
- public void addComposited(Collection<E> compositeCollection1, Collection<E> compositeCollection2) {
+ public void addComposited(final Collection<E> compositeCollection1, final Collection<E> compositeCollection2) {
all.add(compositeCollection1);
all.add(compositeCollection2);
}
@@ -375,7 +375,7 @@ public class CompositeCollection<E> impl
*
* @param compositeCollections the Collections to be appended to the composite
*/
- public void addComposited(Collection<E>[] compositeCollections) {
+ public void addComposited(final Collection<E>[] compositeCollections) {
all.addAll(Arrays.asList(compositeCollections));
}
@@ -395,7 +395,7 @@ public class CompositeCollection<E> impl
*
* @param coll collection to be removed
*/
- public void removeComposited(Collection<E> coll) {
+ public void removeComposited(final Collection<E> coll) {
all.remove(coll);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/IndexedCollection.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/IndexedCollection.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/IndexedCollection.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/IndexedCollection.java Mon Jan 7 17:15:14 2013
@@ -73,7 +73,7 @@ public class IndexedCollection<K, C> ext
* @param keyTransformer {@link Transformer} for generating index keys
* @param map map to use as index
*/
- public IndexedCollection(Collection<C> coll, Transformer<C, K> keyTransformer, HashMap<K, C> map) {
+ public IndexedCollection(final Collection<C> coll, final Transformer<C, K> keyTransformer, final HashMap<K, C> map) {
super(coll);
this.keyTransformer = keyTransformer;
this.index = new HashMap<K, C>();
@@ -81,7 +81,7 @@ public class IndexedCollection<K, C> ext
}
@Override
- public boolean add(C object) {
+ public boolean add(final C object) {
final boolean added = super.add(object);
if (added) {
addToIndex(object);
@@ -90,9 +90,9 @@ public class IndexedCollection<K, C> ext
}
@Override
- public boolean addAll(Collection<? extends C> coll) {
+ public boolean addAll(final Collection<? extends C> coll) {
boolean changed = false;
- for (C c: coll) {
+ for (final C c: coll) {
changed |= add(c);
}
return changed;
@@ -111,7 +111,7 @@ public class IndexedCollection<K, C> ext
*/
@SuppressWarnings("unchecked")
@Override
- public boolean contains(Object object) {
+ public boolean contains(final Object object) {
return index.containsKey(keyTransformer.transform((C) object));
}
@@ -121,8 +121,8 @@ public class IndexedCollection<K, C> ext
* Note: uses the index for fast lookup
*/
@Override
- public boolean containsAll(Collection<?> coll) {
- for (Object o : coll) {
+ public boolean containsAll(final Collection<?> coll) {
+ for (final Object o : coll) {
if (!contains(o)) {
return false;
}
@@ -136,7 +136,7 @@ public class IndexedCollection<K, C> ext
* @param key key to look up
* @return element found
*/
- public C get(K key) {
+ public C get(final K key) {
return index.get(key);
}
@@ -145,14 +145,14 @@ public class IndexedCollection<K, C> ext
*/
public void reindex() {
index.clear();
- for (C c : decorated()) {
+ for (final C c : decorated()) {
addToIndex(c);
}
}
@SuppressWarnings("unchecked")
@Override
- public boolean remove(Object object) {
+ public boolean remove(final Object object) {
final boolean removed = super.remove(object);
if (removed) {
removeFromIndex((C) object);
@@ -161,16 +161,16 @@ public class IndexedCollection<K, C> ext
}
@Override
- public boolean removeAll(Collection<?> coll) {
+ public boolean removeAll(final Collection<?> coll) {
boolean changed = false;
- for (Object o : coll) {
+ for (final Object o : coll) {
changed |= remove(o);
}
return changed;
}
@Override
- public boolean retainAll(Collection<?> coll) {
+ public boolean retainAll(final Collection<?> coll) {
final boolean changed = super.retainAll(coll);
if (changed) {
reindex();
@@ -185,7 +185,7 @@ public class IndexedCollection<K, C> ext
*
* @param object the object to index
*/
- private void addToIndex(C object) {
+ private void addToIndex(final C object) {
final C existingObject = index.put(keyTransformer.transform(object), object);
if (existingObject != null) {
throw new IllegalArgumentException("Duplicate key in uniquely indexed collection.");
@@ -197,7 +197,7 @@ public class IndexedCollection<K, C> ext
*
* @param object the object to remove
*/
- private void removeFromIndex(C object) {
+ private void removeFromIndex(final C object) {
index.remove(keyTransformer.transform(object));
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/PredicatedCollection.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/PredicatedCollection.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/PredicatedCollection.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/PredicatedCollection.java Mon Jan 7 17:15:14 2013
@@ -58,8 +58,8 @@ public class PredicatedCollection<E> ext
* @throws IllegalArgumentException if collection or predicate is null
* @throws IllegalArgumentException if the collection contains invalid elements
*/
- public static <T> PredicatedCollection<T> predicatedCollection(Collection<T> coll,
- Predicate<? super T> predicate) {
+ public static <T> PredicatedCollection<T> predicatedCollection(final Collection<T> coll,
+ final Predicate<? super T> predicate) {
return new PredicatedCollection<T>(coll, predicate);
}
@@ -75,13 +75,13 @@ public class PredicatedCollection<E> ext
* @throws IllegalArgumentException if collection or predicate is null
* @throws IllegalArgumentException if the collection contains invalid elements
*/
- protected PredicatedCollection(Collection<E> coll, Predicate<? super E> predicate) {
+ protected PredicatedCollection(final Collection<E> coll, final Predicate<? super E> predicate) {
super(coll);
if (predicate == null) {
throw new IllegalArgumentException("Predicate must not be null");
}
this.predicate = predicate;
- for (E item : coll) {
+ for (final E item : coll) {
validate(item);
}
}
@@ -95,7 +95,7 @@ public class PredicatedCollection<E> ext
* @param object the object being added
* @throws IllegalArgumentException if the add is invalid
*/
- protected void validate(E object) {
+ protected void validate(final E object) {
if (predicate.evaluate(object) == false) {
throw new IllegalArgumentException("Cannot add Object '" + object + "' - Predicate '" +
predicate + "' rejected it");
@@ -112,7 +112,7 @@ public class PredicatedCollection<E> ext
* @throws IllegalArgumentException if the add is invalid
*/
@Override
- public boolean add(E object) {
+ public boolean add(final E object) {
validate(object);
return decorated().add(object);
}
@@ -127,8 +127,8 @@ public class PredicatedCollection<E> ext
* @throws IllegalArgumentException if the add is invalid
*/
@Override
- public boolean addAll(Collection<? extends E> coll) {
- for (E item : coll) {
+ public boolean addAll(final Collection<? extends E> coll) {
+ for (final E item : coll) {
validate(item);
}
return decorated().addAll(coll);