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 [9/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/list/CursorableLinkedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/CursorableLinkedList.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/CursorableLinkedList.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/CursorableLinkedList.java Mon Jan 7 17:15:14 2013
@@ -77,7 +77,7 @@ public class CursorableLinkedList<E> ext
*
* @param coll the collection to copy
*/
- public CursorableLinkedList(Collection<E> coll) {
+ public CursorableLinkedList(final Collection<E> coll) {
super(coll);
}
@@ -143,7 +143,7 @@ public class CursorableLinkedList<E> ext
* @return a new cursor iterator
*/
@Override
- public ListIterator<E> listIterator(int fromIndex) {
+ public ListIterator<E> listIterator(final int fromIndex) {
return cursor(fromIndex);
}
@@ -201,8 +201,8 @@ public class CursorableLinkedList<E> ext
* @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index > size()).
*/
- public CursorableLinkedList.Cursor<E> cursor(int fromIndex) {
- Cursor<E> cursor = new Cursor<E>(this, fromIndex);
+ public CursorableLinkedList.Cursor<E> cursor(final int fromIndex) {
+ final Cursor<E> cursor = new Cursor<E>(this, fromIndex);
registerCursor(cursor);
return cursor;
}
@@ -217,7 +217,7 @@ public class CursorableLinkedList<E> ext
* @param value new value of the node
*/
@Override
- protected void updateNode(Node<E> node, E value) {
+ protected void updateNode(final Node<E> node, final E value) {
super.updateNode(node, value);
broadcastNodeChanged(node);
}
@@ -230,7 +230,7 @@ public class CursorableLinkedList<E> ext
* @throws NullPointerException if either node is null
*/
@Override
- protected void addNode(Node<E> nodeToInsert, Node<E> insertBeforeNode) {
+ protected void addNode(final Node<E> nodeToInsert, final Node<E> insertBeforeNode) {
super.addNode(nodeToInsert, insertBeforeNode);
broadcastNodeInserted(nodeToInsert);
}
@@ -242,7 +242,7 @@ public class CursorableLinkedList<E> ext
* @throws NullPointerException if <code>node</code> is null
*/
@Override
- protected void removeNode(Node<E> node) {
+ protected void removeNode(final Node<E> node) {
super.removeNode(node);
broadcastNodeRemoved(node);
}
@@ -254,7 +254,7 @@ public class CursorableLinkedList<E> ext
protected void removeAllNodes() {
if (size() > 0) {
// superclass implementation would break all the iterators
- Iterator<E> it = iterator();
+ final Iterator<E> it = iterator();
while (it.hasNext()) {
it.next();
it.remove();
@@ -268,11 +268,11 @@ public class CursorableLinkedList<E> ext
*
* @param cursor the cursor to register
*/
- protected void registerCursor(Cursor<E> cursor) {
+ protected void registerCursor(final Cursor<E> cursor) {
// We take this opportunity to clean the cursors list
// of WeakReference objects to garbage-collected cursors.
- for (Iterator<WeakReference<Cursor<E>>> it = cursors.iterator(); it.hasNext();) {
- WeakReference<Cursor<E>> ref = it.next();
+ for (final Iterator<WeakReference<Cursor<E>>> it = cursors.iterator(); it.hasNext();) {
+ final WeakReference<Cursor<E>> ref = it.next();
if (ref.get() == null) {
it.remove();
}
@@ -285,10 +285,10 @@ public class CursorableLinkedList<E> ext
*
* @param cursor the cursor to deregister
*/
- protected void unregisterCursor(Cursor<E> cursor) {
- for (Iterator<WeakReference<Cursor<E>>> it = cursors.iterator(); it.hasNext();) {
- WeakReference<Cursor<E>> ref = it.next();
- Cursor<E> cur = ref.get();
+ protected void unregisterCursor(final Cursor<E> cursor) {
+ for (final Iterator<WeakReference<Cursor<E>>> it = cursors.iterator(); it.hasNext();) {
+ final WeakReference<Cursor<E>> ref = it.next();
+ final Cursor<E> cur = ref.get();
if (cur == null) {
// some other unrelated cursor object has been
// garbage-collected; let's take the opportunity to
@@ -309,11 +309,11 @@ public class CursorableLinkedList<E> ext
*
* @param node the node that was changed
*/
- protected void broadcastNodeChanged(Node<E> node) {
- Iterator<WeakReference<Cursor<E>>> it = cursors.iterator();
+ protected void broadcastNodeChanged(final Node<E> node) {
+ final Iterator<WeakReference<Cursor<E>>> it = cursors.iterator();
while (it.hasNext()) {
- WeakReference<Cursor<E>> ref = it.next();
- Cursor<E> cursor = ref.get();
+ final WeakReference<Cursor<E>> ref = it.next();
+ final Cursor<E> cursor = ref.get();
if (cursor == null) {
it.remove(); // clean up list
} else {
@@ -328,11 +328,11 @@ public class CursorableLinkedList<E> ext
*
* @param node the node that was changed
*/
- protected void broadcastNodeRemoved(Node<E> node) {
- Iterator<WeakReference<Cursor<E>>> it = cursors.iterator();
+ protected void broadcastNodeRemoved(final Node<E> node) {
+ final Iterator<WeakReference<Cursor<E>>> it = cursors.iterator();
while (it.hasNext()) {
- WeakReference<Cursor<E>> ref = it.next();
- Cursor<E> cursor = ref.get();
+ final WeakReference<Cursor<E>> ref = it.next();
+ final Cursor<E> cursor = ref.get();
if (cursor == null) {
it.remove(); // clean up list
} else {
@@ -347,11 +347,11 @@ public class CursorableLinkedList<E> ext
*
* @param node the node that was changed
*/
- protected void broadcastNodeInserted(Node<E> node) {
- Iterator<WeakReference<Cursor<E>>> it = cursors.iterator();
+ protected void broadcastNodeInserted(final Node<E> node) {
+ final Iterator<WeakReference<Cursor<E>>> it = cursors.iterator();
while (it.hasNext()) {
- WeakReference<Cursor<E>> ref = it.next();
- Cursor<E> cursor = ref.get();
+ final WeakReference<Cursor<E>> ref = it.next();
+ final Cursor<E> cursor = ref.get();
if (cursor == null) {
it.remove(); // clean up list
} else {
@@ -364,7 +364,7 @@ public class CursorableLinkedList<E> ext
/**
* Serializes the data held in this object to the stream specified.
*/
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
doWriteObject(out);
}
@@ -372,7 +372,7 @@ public class CursorableLinkedList<E> ext
/**
* Deserializes the data held in this object to the stream specified.
*/
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
doReadObject(in);
}
@@ -386,8 +386,8 @@ public class CursorableLinkedList<E> ext
* @return the list iterator for the sublist
*/
@Override
- protected ListIterator<E> createSubListListIterator(LinkedSubList<E> subList, int fromIndex) {
- SubCursor<E> cursor = new SubCursor<E>(subList, fromIndex);
+ protected ListIterator<E> createSubListListIterator(final LinkedSubList<E> subList, final int fromIndex) {
+ final SubCursor<E> cursor = new SubCursor<E>(subList, fromIndex);
registerCursor(cursor);
return cursor;
}
@@ -411,7 +411,7 @@ public class CursorableLinkedList<E> ext
* @param parent the parent list
* @param index the index to start from
*/
- protected Cursor(CursorableLinkedList<E> parent, int index) {
+ protected Cursor(final CursorableLinkedList<E> parent, final int index) {
super(parent, index);
valid = true;
}
@@ -450,7 +450,7 @@ public class CursorableLinkedList<E> ext
* @param obj the object to add
*/
@Override
- public void add(E obj) {
+ public void add(final E obj) {
// overridden, as the nodeInserted() method updates the iterator state
super.add(obj);
// matches the (next.previous == node) clause in nodeInserted()
@@ -492,7 +492,7 @@ public class CursorableLinkedList<E> ext
*
* @param node the node that changed
*/
- protected void nodeChanged(Node<E> node) {
+ protected void nodeChanged(final Node<E> node) {
// do nothing
}
@@ -501,7 +501,7 @@ public class CursorableLinkedList<E> ext
*
* @param node the node that was removed
*/
- protected void nodeRemoved(Node<E> node) {
+ protected void nodeRemoved(final Node<E> node) {
if (node == next && node == current) {
// state where next() followed by previous()
next = node.next;
@@ -529,7 +529,7 @@ public class CursorableLinkedList<E> ext
*
* @param node the node that was added
*/
- protected void nodeInserted(Node<E> node) {
+ protected void nodeInserted(final Node<E> node) {
if (node.previous == current) {
next = node;
} else if (next.previous == node) {
@@ -582,7 +582,7 @@ public class CursorableLinkedList<E> ext
* @param sub the sub list
* @param index the index to start from
*/
- protected SubCursor(LinkedSubList<E> sub, int index) {
+ protected SubCursor(final LinkedSubList<E> sub, final int index) {
super((CursorableLinkedList<E>) sub.parent, index + sub.offset);
this.sub = sub;
}
@@ -603,7 +603,7 @@ public class CursorableLinkedList<E> ext
}
@Override
- public void add(E obj) {
+ public void add(final E obj) {
super.add(obj);
sub.expectedModCount = parent.modCount;
sub.size++;
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/FixedSizeList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/FixedSizeList.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/FixedSizeList.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/FixedSizeList.java Mon Jan 7 17:15:14 2013
@@ -51,7 +51,7 @@ public class FixedSizeList<E>
* @return a new fixed size list
* @throws IllegalArgumentException if list is null
*/
- public static <E> FixedSizeList<E> fixedSizeList(List<E> list) {
+ public static <E> FixedSizeList<E> fixedSizeList(final List<E> list) {
return new FixedSizeList<E>(list);
}
@@ -62,28 +62,28 @@ public class FixedSizeList<E>
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
- protected FixedSizeList(List<E> list) {
+ protected FixedSizeList(final List<E> list) {
super(list);
}
//-----------------------------------------------------------------------
@Override
- public boolean add(E object) {
+ public boolean add(final E object) {
throw new UnsupportedOperationException("List is fixed size");
}
@Override
- public void add(int index, E object) {
+ public void add(final int index, final E object) {
throw new UnsupportedOperationException("List is fixed size");
}
@Override
- public boolean addAll(Collection<? extends E> coll) {
+ public boolean addAll(final Collection<? extends E> coll) {
throw new UnsupportedOperationException("List is fixed size");
}
@Override
- public boolean addAll(int index, Collection<? extends E> coll) {
+ public boolean addAll(final int index, final Collection<? extends E> coll) {
throw new UnsupportedOperationException("List is fixed size");
}
@@ -93,12 +93,12 @@ public class FixedSizeList<E>
}
@Override
- public E get(int index) {
+ public E get(final int index) {
return decorated().get(index);
}
@Override
- public int indexOf(Object object) {
+ public int indexOf(final Object object) {
return decorated().indexOf(object);
}
@@ -108,7 +108,7 @@ public class FixedSizeList<E>
}
@Override
- public int lastIndexOf(Object object) {
+ public int lastIndexOf(final Object object) {
return decorated().lastIndexOf(object);
}
@@ -118,38 +118,38 @@ public class FixedSizeList<E>
}
@Override
- public ListIterator<E> listIterator(int index) {
+ public ListIterator<E> listIterator(final int index) {
return new FixedSizeListIterator(decorated().listIterator(index));
}
@Override
- public E remove(int index) {
+ public E remove(final int index) {
throw new UnsupportedOperationException("List is fixed size");
}
@Override
- public boolean remove(Object object) {
+ public boolean remove(final Object object) {
throw new UnsupportedOperationException("List is fixed size");
}
@Override
- public boolean removeAll(Collection<?> coll) {
+ public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException("List is fixed size");
}
@Override
- public boolean retainAll(Collection<?> coll) {
+ public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException("List is fixed size");
}
@Override
- public E set(int index, E object) {
+ public E set(final int index, final E object) {
return decorated().set(index, object);
}
@Override
- public List<E> subList(int fromIndex, int toIndex) {
- List<E> sub = decorated().subList(fromIndex, toIndex);
+ public List<E> subList(final int fromIndex, final int toIndex) {
+ final List<E> sub = decorated().subList(fromIndex, toIndex);
return new FixedSizeList<E>(sub);
}
@@ -157,7 +157,7 @@ public class FixedSizeList<E>
* List iterator that only permits changes via set()
*/
private class FixedSizeListIterator extends AbstractListIteratorDecorator<E> {
- protected FixedSizeListIterator(ListIterator<E> iterator) {
+ protected FixedSizeListIterator(final ListIterator<E> iterator) {
super(iterator);
}
@Override
@@ -165,7 +165,7 @@ public class FixedSizeList<E>
throw new UnsupportedOperationException("List is fixed size");
}
@Override
- public void add(Object object) {
+ public void add(final Object object) {
throw new UnsupportedOperationException("List is fixed size");
}
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/GrowthList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/GrowthList.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/GrowthList.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/GrowthList.java Mon Jan 7 17:15:14 2013
@@ -65,7 +65,7 @@ public class GrowthList<E> extends Abstr
* @return a new growth list
* @throws IllegalArgumentException if list is null
*/
- public static <E> GrowthList<E> growthList(List<E> list) {
+ public static <E> GrowthList<E> growthList(final List<E> list) {
return new GrowthList<E>(list);
}
@@ -83,7 +83,7 @@ public class GrowthList<E> extends Abstr
* @param initialSize the initial size of the ArrayList
* @throws IllegalArgumentException if initial size is invalid
*/
- public GrowthList(int initialSize) {
+ public GrowthList(final int initialSize) {
super(new ArrayList<E>(initialSize));
}
@@ -93,7 +93,7 @@ public class GrowthList<E> extends Abstr
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
- protected GrowthList(List<E> list) {
+ protected GrowthList(final List<E> list) {
super(list);
}
@@ -117,8 +117,8 @@ public class GrowthList<E> extends Abstr
* @throws IllegalArgumentException if the underlying list rejects the element
*/
@Override
- public void add(int index, E element) {
- int size = decorated().size();
+ public void add(final int index, final E element) {
+ final int size = decorated().size();
if (index > size) {
decorated().addAll(Collections.<E>nCopies(index - size, null));
}
@@ -146,8 +146,8 @@ public class GrowthList<E> extends Abstr
* @throws IllegalArgumentException if the underlying list rejects the element
*/
@Override
- public boolean addAll(int index, Collection<? extends E> coll) {
- int size = decorated().size();
+ public boolean addAll(final int index, final Collection<? extends E> coll) {
+ final int size = decorated().size();
boolean result = false;
if (index > size) {
decorated().addAll(Collections.<E>nCopies(index - size, null));
@@ -177,8 +177,8 @@ public class GrowthList<E> extends Abstr
* @throws IllegalArgumentException if the underlying list rejects the element
*/
@Override
- public E set(int index, E element) {
- int size = decorated().size();
+ public E set(final int index, final E element) {
+ final int size = decorated().size();
if (index >= size) {
decorated().addAll(Collections.<E>nCopies(index - size + 1, null));
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/LazyList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/LazyList.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/LazyList.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/LazyList.java Mon Jan 7 17:15:14 2013
@@ -74,7 +74,7 @@ public class LazyList<E> extends Abstrac
* @return a new lazy list
* @throws IllegalArgumentException if list or factory is null
*/
- public static <E> LazyList<E> lazyList(List<E> list, Factory<? extends E> factory) {
+ public static <E> LazyList<E> lazyList(final List<E> list, final Factory<? extends E> factory) {
return new LazyList<E>(list, factory);
}
@@ -86,7 +86,7 @@ public class LazyList<E> extends Abstrac
* @param factory the factory to use for creation, must not be null
* @throws IllegalArgumentException if list or factory is null
*/
- protected LazyList(List<E> list, Factory<? extends E> factory) {
+ protected LazyList(final List<E> list, final Factory<? extends E> factory) {
super(list);
if (factory == null) {
throw new IllegalArgumentException("Factory must not be null");
@@ -107,8 +107,8 @@ public class LazyList<E> extends Abstrac
* @return the element at the given index
*/
@Override
- public E get(int index) {
- int size = decorated().size();
+ public E get(final int index) {
+ final int size = decorated().size();
if (index < size) {
// within bounds, get the object
E object = decorated().get(index);
@@ -126,14 +126,14 @@ public class LazyList<E> extends Abstrac
decorated().add(null);
}
// create our last object, set and return
- E object = factory.create();
+ final E object = factory.create();
decorated().add(object);
return object;
}
@Override
- public List<E> subList(int fromIndex, int toIndex) {
- List<E> sub = decorated().subList(fromIndex, toIndex);
+ public List<E> subList(final int fromIndex, final int toIndex) {
+ final List<E> sub = decorated().subList(fromIndex, toIndex);
return new LazyList<E>(sub, factory);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/NodeCachingLinkedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/NodeCachingLinkedList.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/NodeCachingLinkedList.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/NodeCachingLinkedList.java Mon Jan 7 17:15:14 2013
@@ -79,7 +79,7 @@ public class NodeCachingLinkedList<E> ex
*
* @param coll the collection to copy
*/
- public NodeCachingLinkedList(Collection<E> coll) {
+ public NodeCachingLinkedList(final Collection<E> coll) {
super(coll);
this.maximumCacheSize = DEFAULT_MAXIMUM_CACHE_SIZE;
}
@@ -89,7 +89,7 @@ public class NodeCachingLinkedList<E> ex
*
* @param maximumCacheSize the maximum cache size
*/
- public NodeCachingLinkedList(int maximumCacheSize) {
+ public NodeCachingLinkedList(final int maximumCacheSize) {
super();
this.maximumCacheSize = maximumCacheSize;
init(); // must call init() as use super();
@@ -110,7 +110,7 @@ public class NodeCachingLinkedList<E> ex
*
* @param maximumCacheSize the new maximum cache size
*/
- protected void setMaximumCacheSize(int maximumCacheSize) {
+ protected void setMaximumCacheSize(final int maximumCacheSize) {
this.maximumCacheSize = maximumCacheSize;
shrinkCacheToMaximumSize();
}
@@ -136,7 +136,7 @@ public class NodeCachingLinkedList<E> ex
if (cacheSize == 0) {
return null;
}
- Node<E> cachedNode = firstCachedNode;
+ final Node<E> cachedNode = firstCachedNode;
firstCachedNode = cachedNode.next;
cachedNode.next = null; // This should be changed anyway, but defensively
// set it to null.
@@ -159,13 +159,13 @@ public class NodeCachingLinkedList<E> ex
*
* @param node the node to add to the cache
*/
- protected void addNodeToCache(Node<E> node) {
+ protected void addNodeToCache(final Node<E> node) {
if (isCacheFull()) {
// don't cache the node.
return;
}
// clear the node's contents and add it to the cache.
- Node<E> nextCachedNode = firstCachedNode;
+ final Node<E> nextCachedNode = firstCachedNode;
node.previous = null;
node.next = nextCachedNode;
node.setValue(null);
@@ -182,8 +182,8 @@ public class NodeCachingLinkedList<E> ex
* @return the newly created node
*/
@Override
- protected Node<E> createNode(E value) {
- Node<E> cachedNode = getNodeFromCache();
+ protected Node<E> createNode(final E value) {
+ final Node<E> cachedNode = getNodeFromCache();
if (cachedNode == null) {
return super.createNode(value);
}
@@ -198,7 +198,7 @@ public class NodeCachingLinkedList<E> ex
* @param node the node to remove
*/
@Override
- protected void removeNode(Node<E> node) {
+ protected void removeNode(final Node<E> node) {
super.removeNode(node);
addNodeToCache(node);
}
@@ -214,10 +214,10 @@ public class NodeCachingLinkedList<E> ex
// We can add them to the cache before removing them, since
// {@link AbstractLinkedList.removeAllNodes()} removes the
// nodes by removing references directly from {@link #header}.
- int numberOfNodesToCache = Math.min(size, maximumCacheSize - cacheSize);
+ final int numberOfNodesToCache = Math.min(size, maximumCacheSize - cacheSize);
Node<E> node = header.next;
for (int currentIndex = 0; currentIndex < numberOfNodesToCache; currentIndex++) {
- Node<E> oldNode = node;
+ final Node<E> oldNode = node;
node = node.next;
addNodeToCache(oldNode);
}
@@ -228,7 +228,7 @@ public class NodeCachingLinkedList<E> ex
/**
* Serializes the data held in this object to the stream specified.
*/
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
doWriteObject(out);
}
@@ -236,7 +236,7 @@ public class NodeCachingLinkedList<E> ex
/**
* Deserializes the data held in this object to the stream specified.
*/
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
doReadObject(in);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/PredicatedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/PredicatedList.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/PredicatedList.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/PredicatedList.java Mon Jan 7 17:15:14 2013
@@ -58,7 +58,7 @@ public class PredicatedList<E> extends P
* @throws IllegalArgumentException if list or predicate is null
* @throws IllegalArgumentException if the list contains invalid elements
*/
- public static <T> PredicatedList<T> predicatedList(List<T> list, Predicate<? super T> predicate) {
+ public static <T> PredicatedList<T> predicatedList(final List<T> list, final Predicate<? super T> predicate) {
return new PredicatedList<T>(list, predicate);
}
@@ -74,7 +74,7 @@ public class PredicatedList<E> extends P
* @throws IllegalArgumentException if list or predicate is null
* @throws IllegalArgumentException if the list contains invalid elements
*/
- protected PredicatedList(List<E> list, Predicate<? super E> predicate) {
+ protected PredicatedList(final List<E> list, final Predicate<? super E> predicate) {
super(list, predicate);
}
@@ -90,31 +90,31 @@ public class PredicatedList<E> extends P
//-----------------------------------------------------------------------
- public E get(int index) {
+ public E get(final int index) {
return decorated().get(index);
}
- public int indexOf(Object object) {
+ public int indexOf(final Object object) {
return decorated().indexOf(object);
}
- public int lastIndexOf(Object object) {
+ public int lastIndexOf(final Object object) {
return decorated().lastIndexOf(object);
}
- public E remove(int index) {
+ public E remove(final int index) {
return decorated().remove(index);
}
//-----------------------------------------------------------------------
- public void add(int index, E object) {
+ public void add(final int index, final E object) {
validate(object);
decorated().add(index, object);
}
- public boolean addAll(int index, Collection<? extends E> coll) {
- for (E aColl : coll) {
+ public boolean addAll(final int index, final Collection<? extends E> coll) {
+ for (final E aColl : coll) {
validate(aColl);
}
return decorated().addAll(index, coll);
@@ -124,17 +124,17 @@ public class PredicatedList<E> extends P
return listIterator(0);
}
- public ListIterator<E> listIterator(int i) {
+ public ListIterator<E> listIterator(final int i) {
return new PredicatedListIterator(decorated().listIterator(i));
}
- public E set(int index, E object) {
+ public E set(final int index, final E object) {
validate(object);
return decorated().set(index, object);
}
- public List<E> subList(int fromIndex, int toIndex) {
- List<E> sub = decorated().subList(fromIndex, toIndex);
+ public List<E> subList(final int fromIndex, final int toIndex) {
+ final List<E> sub = decorated().subList(fromIndex, toIndex);
return new PredicatedList<E>(sub, predicate);
}
@@ -148,18 +148,18 @@ public class PredicatedList<E> extends P
*
* @param iterator the list iterator to decorate
*/
- protected PredicatedListIterator(ListIterator<E> iterator) {
+ protected PredicatedListIterator(final ListIterator<E> iterator) {
super(iterator);
}
@Override
- public void add(E object) {
+ public void add(final E object) {
validate(object);
iterator.add(object);
}
@Override
- public void set(E object) {
+ public void set(final E object) {
validate(object);
iterator.set(object);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/SetUniqueList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/SetUniqueList.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/SetUniqueList.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/SetUniqueList.java Mon Jan 7 17:15:14 2013
@@ -70,16 +70,16 @@ public class SetUniqueList<E> extends Ab
* @throws IllegalArgumentException
* if list is null
*/
- public static <E> SetUniqueList<E> setUniqueList(List<E> list) {
+ public static <E> SetUniqueList<E> setUniqueList(final List<E> list) {
if (list == null) {
throw new IllegalArgumentException("List must not be null");
}
if (list.isEmpty()) {
return new SetUniqueList<E>(list, new HashSet<E>());
}
- List<E> temp = new ArrayList<E>(list);
+ final List<E> temp = new ArrayList<E>(list);
list.clear();
- SetUniqueList<E> sl = new SetUniqueList<E>(list, new HashSet<E>());
+ final SetUniqueList<E> sl = new SetUniqueList<E>(list, new HashSet<E>());
sl.addAll(temp);
return sl;
}
@@ -98,7 +98,7 @@ public class SetUniqueList<E> extends Ab
* @throws IllegalArgumentException
* if set or list is null
*/
- protected SetUniqueList(List<E> list, Set<E> set) {
+ protected SetUniqueList(final List<E> list, final Set<E> set) {
super(list);
if (set == null) {
throw new IllegalArgumentException("Set must not be null");
@@ -129,7 +129,7 @@ public class SetUniqueList<E> extends Ab
* @return true if object was added
*/
@Override
- public boolean add(E object) {
+ public boolean add(final E object) {
// gets initial size
final int sizeBefore = size();
@@ -154,7 +154,7 @@ public class SetUniqueList<E> extends Ab
* the object to add
*/
@Override
- public void add(int index, E object) {
+ public void add(final int index, final E object) {
// adds element if it is not contained already
if (set.contains(object) == false) {
super.add(index, object);
@@ -177,7 +177,7 @@ public class SetUniqueList<E> extends Ab
* @return true if this collection changed
*/
@Override
- public boolean addAll(Collection<? extends E> coll) {
+ public boolean addAll(final Collection<? extends E> coll) {
return addAll(size(), coll);
}
@@ -199,9 +199,9 @@ public class SetUniqueList<E> extends Ab
* @return true if this collection changed
*/
@Override
- public boolean addAll(int index, Collection<? extends E> coll) {
+ public boolean addAll(final int index, final Collection<? extends E> coll) {
final List<E> temp = new ArrayList<E>();
- for (E e : coll) {
+ for (final E e : coll) {
if (set.add(e)) {
temp.add(e);
}
@@ -224,9 +224,9 @@ public class SetUniqueList<E> extends Ab
* @return the previous object
*/
@Override
- public E set(int index, E object) {
- int pos = indexOf(object);
- E removed = super.set(index, object);
+ public E set(final int index, final E object) {
+ final int pos = indexOf(object);
+ final E removed = super.set(index, object);
if (pos != -1 && pos != index) {
// the object is already in the uniq list
@@ -241,8 +241,8 @@ public class SetUniqueList<E> extends Ab
}
@Override
- public boolean remove(Object object) {
- boolean result = set.remove(object);
+ public boolean remove(final Object object) {
+ final boolean result = set.remove(object);
if (result) {
super.remove(object);
}
@@ -250,25 +250,25 @@ public class SetUniqueList<E> extends Ab
}
@Override
- public E remove(int index) {
- E result = super.remove(index);
+ public E remove(final int index) {
+ final E result = super.remove(index);
set.remove(result);
return result;
}
@Override
- public boolean removeAll(Collection<?> coll) {
+ public boolean removeAll(final Collection<?> coll) {
boolean result = false;
- for (Object name : coll) {
+ for (final Object name : coll) {
result |= remove(name);
}
return result;
}
@Override
- public boolean retainAll(Collection<?> coll) {
- Set<Object> setRetainAll = new HashSet<Object>();
- for (Object next : coll) {
+ public boolean retainAll(final Collection<?> coll) {
+ final Set<Object> setRetainAll = new HashSet<Object>();
+ for (final Object next : coll) {
if (set.contains(next)) {
setRetainAll.add(next);
}
@@ -279,7 +279,7 @@ public class SetUniqueList<E> extends Ab
if (setRetainAll.size() == 0) {
clear();
} else {
- for (Iterator<E> it = iterator(); it.hasNext();) {
+ for (final Iterator<E> it = iterator(); it.hasNext();) {
if (!setRetainAll.contains(it.next())) {
it.remove();
}
@@ -295,12 +295,12 @@ public class SetUniqueList<E> extends Ab
}
@Override
- public boolean contains(Object object) {
+ public boolean contains(final Object object) {
return set.contains(object);
}
@Override
- public boolean containsAll(Collection<?> coll) {
+ public boolean containsAll(final Collection<?> coll) {
return set.containsAll(coll);
}
@@ -315,14 +315,14 @@ public class SetUniqueList<E> extends Ab
}
@Override
- public ListIterator<E> listIterator(int index) {
+ public ListIterator<E> listIterator(final int index) {
return new SetListListIterator<E>(super.listIterator(index), set);
}
@Override
- public List<E> subList(int fromIndex, int toIndex) {
- List<E> superSubList = super.subList(fromIndex, toIndex);
- Set<E> subSet = createSetBasedOnList(set, superSubList);
+ public List<E> subList(final int fromIndex, final int toIndex) {
+ final List<E> superSubList = super.subList(fromIndex, toIndex);
+ final Set<E> subSet = createSetBasedOnList(set, superSubList);
return new SetUniqueList<E>(superSubList, subSet);
}
@@ -338,16 +338,16 @@ public class SetUniqueList<E> extends Ab
* {@link List}
*/
@SuppressWarnings("unchecked")
- protected Set<E> createSetBasedOnList(Set<E> set, List<E> list) {
+ protected Set<E> createSetBasedOnList(final Set<E> set, final List<E> list) {
Set<E> subSet;
if (set.getClass().equals(HashSet.class)) {
subSet = new HashSet<E>(list.size());
} else {
try {
subSet = set.getClass().newInstance();
- } catch (InstantiationException ie) {
+ } catch (final InstantiationException ie) {
subSet = new HashSet<E>();
- } catch (IllegalAccessException iae) {
+ } catch (final IllegalAccessException iae) {
subSet = new HashSet<E>();
}
}
@@ -364,7 +364,7 @@ public class SetUniqueList<E> extends Ab
protected final Set<E> set;
protected E last = null;
- protected SetListIterator(Iterator<E> it, Set<E> set) {
+ protected SetListIterator(final Iterator<E> it, final Set<E> set) {
super(it);
this.set = set;
}
@@ -392,7 +392,7 @@ public class SetUniqueList<E> extends Ab
protected final Set<E> set;
protected E last = null;
- protected SetListListIterator(ListIterator<E> it, Set<E> set) {
+ protected SetListListIterator(final ListIterator<E> it, final Set<E> set) {
super(it);
this.set = set;
}
@@ -417,7 +417,7 @@ public class SetUniqueList<E> extends Ab
}
@Override
- public void add(E object) {
+ public void add(final E object) {
if (set.contains(object) == false) {
super.add(object);
set.add(object);
@@ -425,7 +425,7 @@ public class SetUniqueList<E> extends Ab
}
@Override
- public void set(E object) {
+ public void set(final E object) {
throw new UnsupportedOperationException("ListIterator does not support set");
}
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/SynchronizedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/SynchronizedList.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/SynchronizedList.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/SynchronizedList.java Mon Jan 7 17:15:14 2013
@@ -46,7 +46,7 @@ public class SynchronizedList<E> extends
* @return a new synchronized list
* @throws IllegalArgumentException if list is null
*/
- public static <T> SynchronizedList<T> synchronizedList(List<T> list) {
+ public static <T> SynchronizedList<T> synchronizedList(final List<T> list) {
return new SynchronizedList<T>(list);
}
@@ -57,7 +57,7 @@ public class SynchronizedList<E> extends
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
- protected SynchronizedList(List<E> list) {
+ protected SynchronizedList(final List<E> list) {
super(list);
}
@@ -68,7 +68,7 @@ public class SynchronizedList<E> extends
* @param lock the lock to use, must not be null
* @throws IllegalArgumentException if list is null
*/
- protected SynchronizedList(List<E> list, Object lock) {
+ protected SynchronizedList(final List<E> list, final Object lock) {
super(list, lock);
}
@@ -83,31 +83,31 @@ public class SynchronizedList<E> extends
//-----------------------------------------------------------------------
- public void add(int index, E object) {
+ public void add(final int index, final E object) {
synchronized (lock) {
getList().add(index, object);
}
}
- public boolean addAll(int index, Collection<? extends E> coll) {
+ public boolean addAll(final int index, final Collection<? extends E> coll) {
synchronized (lock) {
return getList().addAll(index, coll);
}
}
- public E get(int index) {
+ public E get(final int index) {
synchronized (lock) {
return getList().get(index);
}
}
- public int indexOf(Object object) {
+ public int indexOf(final Object object) {
synchronized (lock) {
return getList().indexOf(object);
}
}
- public int lastIndexOf(Object object) {
+ public int lastIndexOf(final Object object) {
synchronized (lock) {
return getList().lastIndexOf(object);
}
@@ -138,25 +138,25 @@ public class SynchronizedList<E> extends
* @param index index of first element to be returned by this list iterator
* @return an iterator that must be manually synchronized on the collection
*/
- public ListIterator<E> listIterator(int index) {
+ public ListIterator<E> listIterator(final int index) {
return getList().listIterator(index);
}
- public E remove(int index) {
+ public E remove(final int index) {
synchronized (lock) {
return getList().remove(index);
}
}
- public E set(int index, E object) {
+ public E set(final int index, final E object) {
synchronized (lock) {
return getList().set(index, object);
}
}
- public List<E> subList(int fromIndex, int toIndex) {
+ public List<E> subList(final int fromIndex, final int toIndex) {
synchronized (lock) {
- List<E> list = getList().subList(fromIndex, toIndex);
+ final List<E> list = getList().subList(fromIndex, toIndex);
// the lock is passed into the constructor here to ensure that the sublist is
// synchronized on the same lock as the parent list
return new SynchronizedList<E>(list, lock);
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TransformedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TransformedList.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TransformedList.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TransformedList.java Mon Jan 7 17:15:14 2013
@@ -55,8 +55,8 @@ public class TransformedList<E> extends
* @return a new transformed list
* @throws IllegalArgumentException if list or transformer is null
*/
- public static <E> TransformedList<E> transformingList(List<E> list,
- Transformer<? super E, ? extends E> transformer) {
+ public static <E> TransformedList<E> transformingList(final List<E> list,
+ final Transformer<? super E, ? extends E> transformer) {
return new TransformedList<E>(list, transformer);
}
@@ -75,14 +75,15 @@ public class TransformedList<E> extends
* @throws IllegalArgumentException if list or transformer is null
* @since 3.3
*/
- public static <E> TransformedList<E> transformedList(List<E> list,
- Transformer<? super E, ? extends E> transformer) {
- TransformedList<E> decorated = new TransformedList<E>(list, transformer);
+ public static <E> TransformedList<E> transformedList(final List<E> list,
+ final Transformer<? super E, ? extends E> transformer) {
+ final TransformedList<E> decorated = new TransformedList<E>(list, transformer);
if (transformer != null && list != null && list.size() > 0) {
@SuppressWarnings("unchecked") // list is of type E
+ final
E[] values = (E[]) list.toArray();
list.clear();
- for (E value : values) {
+ for (final E value : values) {
decorated.decorated().add(transformer.transform(value));
}
}
@@ -100,7 +101,7 @@ public class TransformedList<E> extends
* @param transformer the transformer to use for conversion, must not be null
* @throws IllegalArgumentException if list or transformer is null
*/
- protected TransformedList(List<E> list, Transformer<? super E, ? extends E> transformer) {
+ protected TransformedList(final List<E> list, final Transformer<? super E, ? extends E> transformer) {
super(list, transformer);
}
@@ -115,30 +116,30 @@ public class TransformedList<E> extends
//-----------------------------------------------------------------------
- public E get(int index) {
+ public E get(final int index) {
return getList().get(index);
}
- public int indexOf(Object object) {
+ public int indexOf(final Object object) {
return getList().indexOf(object);
}
- public int lastIndexOf(Object object) {
+ public int lastIndexOf(final Object object) {
return getList().lastIndexOf(object);
}
- public E remove(int index) {
+ public E remove(final int index) {
return getList().remove(index);
}
//-----------------------------------------------------------------------
- public void add(int index, E object) {
+ public void add(final int index, E object) {
object = transform(object);
getList().add(index, object);
}
- public boolean addAll(int index, Collection<? extends E> coll) {
+ public boolean addAll(final int index, Collection<? extends E> coll) {
coll = transform(coll);
return getList().addAll(index, coll);
}
@@ -147,17 +148,17 @@ public class TransformedList<E> extends
return listIterator(0);
}
- public ListIterator<E> listIterator(int i) {
+ public ListIterator<E> listIterator(final int i) {
return new TransformedListIterator(getList().listIterator(i));
}
- public E set(int index, E object) {
+ public E set(final int index, E object) {
object = transform(object);
return getList().set(index, object);
}
- public List<E> subList(int fromIndex, int toIndex) {
- List<E> sub = getList().subList(fromIndex, toIndex);
+ public List<E> subList(final int fromIndex, final int toIndex) {
+ final List<E> sub = getList().subList(fromIndex, toIndex);
return new TransformedList<E>(sub, transformer);
}
@@ -171,7 +172,7 @@ public class TransformedList<E> extends
*
* @param iterator the list iterator to decorate
*/
- protected TransformedListIterator(ListIterator<E> iterator) {
+ protected TransformedListIterator(final ListIterator<E> iterator) {
super(iterator);
}
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TreeList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TreeList.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TreeList.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TreeList.java Mon Jan 7 17:15:14 2013
@@ -79,7 +79,7 @@ public class TreeList<E> extends Abstrac
* @param coll the collection to copy
* @throws NullPointerException if the collection is null
*/
- public TreeList(Collection<E> coll) {
+ public TreeList(final Collection<E> coll) {
super();
addAll(coll);
}
@@ -92,7 +92,7 @@ public class TreeList<E> extends Abstrac
* @return the element at the specified index
*/
@Override
- public E get(int index) {
+ public E get(final int index) {
checkInterval(index, 0, size() - 1);
return root.get(index).getValue();
}
@@ -136,7 +136,7 @@ public class TreeList<E> extends Abstrac
* @return the new iterator
*/
@Override
- public ListIterator<E> listIterator(int fromIndex) {
+ public ListIterator<E> listIterator(final int fromIndex) {
// override to go 75% faster
// cannot use EmptyIterator as iterator.add() must work
checkInterval(fromIndex, 0, size());
@@ -150,7 +150,7 @@ public class TreeList<E> extends Abstrac
* @return the index of the object, -1 if not found
*/
@Override
- public int indexOf(Object object) {
+ public int indexOf(final Object object) {
// override to go 75% faster
if (root == null) {
return -1;
@@ -165,7 +165,7 @@ public class TreeList<E> extends Abstrac
* @return true if the object is found
*/
@Override
- public boolean contains(Object object) {
+ public boolean contains(final Object object) {
return indexOf(object) >= 0;
}
@@ -177,7 +177,7 @@ public class TreeList<E> extends Abstrac
@Override
public Object[] toArray() {
// override to go 20% faster
- Object[] array = new Object[size()];
+ final Object[] array = new Object[size()];
if (root != null) {
root.toArray(array, root.relativePosition);
}
@@ -192,7 +192,7 @@ public class TreeList<E> extends Abstrac
* @param obj the element to add
*/
@Override
- public void add(int index, E obj) {
+ public void add(final int index, final E obj) {
modCount++;
checkInterval(index, 0, size());
if (root == null) {
@@ -212,10 +212,10 @@ public class TreeList<E> extends Abstrac
* @throws IndexOutOfBoundsException if the index is invalid
*/
@Override
- public E set(int index, E obj) {
+ public E set(final int index, final E obj) {
checkInterval(index, 0, size() - 1);
- AVLNode<E> node = root.get(index);
- E result = node.value;
+ final AVLNode<E> node = root.get(index);
+ final E result = node.value;
node.setValue(obj);
return result;
}
@@ -227,10 +227,10 @@ public class TreeList<E> extends Abstrac
* @return the previous object at that index
*/
@Override
- public E remove(int index) {
+ public E remove(final int index) {
modCount++;
checkInterval(index, 0, size() - 1);
- E result = get(index);
+ final E result = get(index);
root = root.remove(index);
size--;
return result;
@@ -255,7 +255,7 @@ public class TreeList<E> extends Abstrac
* @param endIndex the last allowed index
* @throws IndexOutOfBoundsException if the index is invalid
*/
- private void checkInterval(int index, int startIndex, int endIndex) {
+ private void checkInterval(final int index, final int startIndex, final int endIndex) {
if (index < startIndex || index > endIndex) {
throw new IndexOutOfBoundsException("Invalid index:" + index + ", size=" + size());
}
@@ -298,7 +298,7 @@ public class TreeList<E> extends Abstrac
* @param rightFollower the node with the value following this one
* @param leftFollower the node with the value leading this one
*/
- private AVLNode(int relativePosition, E obj, AVLNode<E> rightFollower, AVLNode<E> leftFollower) {
+ private AVLNode(final int relativePosition, final E obj, final AVLNode<E> rightFollower, final AVLNode<E> leftFollower) {
this.relativePosition = relativePosition;
value = obj;
rightIsNext = true;
@@ -321,7 +321,7 @@ public class TreeList<E> extends Abstrac
*
* @param obj the value to store
*/
- void setValue(E obj) {
+ void setValue(final E obj) {
this.value = obj;
}
@@ -329,14 +329,14 @@ public class TreeList<E> extends Abstrac
* Locate the element with the given index relative to the
* offset of the parent of this node.
*/
- AVLNode<E> get(int index) {
- int indexRelativeToMe = index - relativePosition;
+ AVLNode<E> get(final int index) {
+ final int indexRelativeToMe = index - relativePosition;
if (indexRelativeToMe == 0) {
return this;
}
- AVLNode<E> nextNode = indexRelativeToMe < 0 ? getLeftSubTree() : getRightSubTree();
+ final AVLNode<E> nextNode = indexRelativeToMe < 0 ? getLeftSubTree() : getRightSubTree();
if (nextNode == null) {
return null;
}
@@ -346,9 +346,9 @@ public class TreeList<E> extends Abstrac
/**
* Locate the index that contains the specified object.
*/
- int indexOf(Object object, int index) {
+ int indexOf(final Object object, final int index) {
if (getLeftSubTree() != null) {
- int result = left.indexOf(object, index + left.relativePosition);
+ final int result = left.indexOf(object, index + left.relativePosition);
if (result != -1) {
return result;
}
@@ -368,7 +368,7 @@ public class TreeList<E> extends Abstrac
* @param array the array to be filled
* @param index the index of this node
*/
- void toArray(Object[] array, int index) {
+ void toArray(final Object[] array, final int index) {
array[index] = value;
if (getLeftSubTree() != null) {
left.toArray(array, index + left.relativePosition);
@@ -409,8 +409,8 @@ public class TreeList<E> extends Abstrac
* the parent node.
* @param obj is the object to be stored in the position.
*/
- AVLNode<E> insert(int index, E obj) {
- int indexRelativeToMe = index - relativePosition;
+ AVLNode<E> insert(final int index, final E obj) {
+ final int indexRelativeToMe = index - relativePosition;
if (indexRelativeToMe <= 0) {
return insertOnLeft(indexRelativeToMe, obj);
@@ -418,7 +418,7 @@ public class TreeList<E> extends Abstrac
return insertOnRight(indexRelativeToMe, obj);
}
- private AVLNode<E> insertOnLeft(int indexRelativeToMe, E obj) {
+ private AVLNode<E> insertOnLeft(final int indexRelativeToMe, final E obj) {
AVLNode<E> ret = this;
if (getLeftSubTree() == null) {
@@ -435,7 +435,7 @@ public class TreeList<E> extends Abstrac
return ret;
}
- private AVLNode<E> insertOnRight(int indexRelativeToMe, E obj) {
+ private AVLNode<E> insertOnRight(final int indexRelativeToMe, final E obj) {
AVLNode<E> ret = this;
if (getRightSubTree() == null) {
@@ -490,8 +490,8 @@ public class TreeList<E> extends Abstrac
* @param index is the index of the element to be removed relative to the position of
* the parent node of the current node.
*/
- AVLNode<E> remove(int index) {
- int indexRelativeToMe = index - relativePosition;
+ AVLNode<E> remove(final int index) {
+ final int indexRelativeToMe = index - relativePosition;
if (indexRelativeToMe == 0) {
return removeSelf();
@@ -559,7 +559,7 @@ public class TreeList<E> extends Abstrac
if (heightRightMinusLeft() > 0) {
// more on the right, so delete from the right
- AVLNode<E> rightMin = right.min();
+ final AVLNode<E> rightMin = right.min();
value = rightMin.value;
if (leftIsPrevious) {
left = rightMin.left;
@@ -570,12 +570,12 @@ public class TreeList<E> extends Abstrac
}
} else {
// more on the left or equal, so delete from the left
- AVLNode<E> leftMax = left.max();
+ final AVLNode<E> leftMax = left.max();
value = leftMax.value;
if (rightIsNext) {
right = leftMax.right;
}
- AVLNode<E> leftPrevious = left.left;
+ final AVLNode<E> leftPrevious = left.left;
left = left.removeMax();
if (left == null) {
// special case where left that was deleted was a double link
@@ -619,7 +619,7 @@ public class TreeList<E> extends Abstrac
/**
* Gets the relative position.
*/
- private int getOffset(AVLNode<E> node) {
+ private int getOffset(final AVLNode<E> node) {
if (node == null) {
return 0;
}
@@ -629,11 +629,11 @@ public class TreeList<E> extends Abstrac
/**
* Sets the relative position.
*/
- private int setOffset(AVLNode<E> node, int newOffest) {
+ private int setOffset(final AVLNode<E> node, final int newOffest) {
if (node == null) {
return 0;
}
- int oldOffset = getOffset(node);
+ final int oldOffset = getOffset(node);
node.relativePosition = newOffest;
return oldOffset;
}
@@ -650,7 +650,7 @@ public class TreeList<E> extends Abstrac
/**
* Returns the height of the node or -1 if the node is null.
*/
- private int getHeight(AVLNode<E> node) {
+ private int getHeight(final AVLNode<E> node) {
return node == null ? -1 : node.height;
}
@@ -662,12 +662,12 @@ public class TreeList<E> extends Abstrac
}
private AVLNode<E> rotateLeft() {
- AVLNode<E> newTop = right; // can't be faedelung!
- AVLNode<E> movedNode = getRightSubTree().getLeftSubTree();
+ final AVLNode<E> newTop = right; // can't be faedelung!
+ final AVLNode<E> movedNode = getRightSubTree().getLeftSubTree();
- int newTopPosition = relativePosition + getOffset(newTop);
- int myNewPosition = -newTop.relativePosition;
- int movedPosition = getOffset(newTop) + getOffset(movedNode);
+ final int newTopPosition = relativePosition + getOffset(newTop);
+ final int myNewPosition = -newTop.relativePosition;
+ final int movedPosition = getOffset(newTop) + getOffset(movedNode);
setRight(movedNode, newTop);
newTop.setLeft(this, null);
@@ -679,12 +679,12 @@ public class TreeList<E> extends Abstrac
}
private AVLNode<E> rotateRight() {
- AVLNode<E> newTop = left; // can't be faedelung
- AVLNode<E> movedNode = getLeftSubTree().getRightSubTree();
+ final AVLNode<E> newTop = left; // can't be faedelung
+ final AVLNode<E> movedNode = getLeftSubTree().getRightSubTree();
- int newTopPosition = relativePosition + getOffset(newTop);
- int myNewPosition = -newTop.relativePosition;
- int movedPosition = getOffset(newTop) + getOffset(movedNode);
+ final int newTopPosition = relativePosition + getOffset(newTop);
+ final int myNewPosition = -newTop.relativePosition;
+ final int movedPosition = getOffset(newTop) + getOffset(movedNode);
setLeft(movedNode, newTop);
newTop.setRight(this, null);
@@ -701,7 +701,7 @@ public class TreeList<E> extends Abstrac
* @param node the new left subtree node
* @param previous the previous node in the linked list
*/
- private void setLeft(AVLNode<E> node, AVLNode<E> previous) {
+ private void setLeft(final AVLNode<E> node, final AVLNode<E> previous) {
leftIsPrevious = node == null;
left = leftIsPrevious ? previous : node;
recalcHeight();
@@ -713,7 +713,7 @@ public class TreeList<E> extends Abstrac
* @param node the new left subtree node
* @param next the next node in the linked list
*/
- private void setRight(AVLNode<E> node, AVLNode<E> next) {
+ private void setRight(final AVLNode<E> node, final AVLNode<E> next) {
rightIsNext = node == null;
right = rightIsNext ? next : node;
recalcHeight();
@@ -818,7 +818,7 @@ public class TreeList<E> extends Abstrac
* @param parent the parent list
* @param fromIndex the index to start at
*/
- protected TreeListIterator(TreeList<E> parent, int fromIndex) throws IndexOutOfBoundsException {
+ protected TreeListIterator(final TreeList<E> parent, final int fromIndex) throws IndexOutOfBoundsException {
super();
this.parent = parent;
this.expectedModCount = parent.modCount;
@@ -852,7 +852,7 @@ public class TreeList<E> extends Abstrac
if (next == null) {
next = parent.root.get(nextIndex);
}
- E value = next.getValue();
+ final E value = next.getValue();
current = next;
currentIndex = nextIndex++;
next = next.next();
@@ -873,7 +873,7 @@ public class TreeList<E> extends Abstrac
} else {
next = next.previous();
}
- E value = next.getValue();
+ final E value = next.getValue();
current = next;
currentIndex = --nextIndex;
return value;
@@ -906,7 +906,7 @@ public class TreeList<E> extends Abstrac
expectedModCount++;
}
- public void set(E obj) {
+ public void set(final E obj) {
checkModCount();
if (current == null) {
throw new IllegalStateException();
@@ -914,7 +914,7 @@ public class TreeList<E> extends Abstrac
current.setValue(obj);
}
- public void add(E obj) {
+ public void add(final E obj) {
checkModCount();
parent.add(nextIndex, obj);
current = null;
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/UnmodifiableList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/UnmodifiableList.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/UnmodifiableList.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/UnmodifiableList.java Mon Jan 7 17:15:14 2013
@@ -50,7 +50,7 @@ public final class UnmodifiableList<E>
* @return a new unmodifiable list
* @throws IllegalArgumentException if list is null
*/
- public static <E> List<E> unmodifiableList(List<E> list) {
+ public static <E> List<E> unmodifiableList(final List<E> list) {
if (list instanceof Unmodifiable) {
return list;
}
@@ -65,7 +65,7 @@ public final class UnmodifiableList<E>
* @throws IllegalArgumentException if list is null
* @since Commons Collection 5
*/
- public UnmodifiableList(List<E> list) {
+ public UnmodifiableList(final List<E> list) {
super(list);
}
@@ -76,12 +76,12 @@ public final class UnmodifiableList<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();
}
@@ -91,17 +91,17 @@ public final class UnmodifiableList<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();
}
@@ -112,33 +112,33 @@ public final class UnmodifiableList<E>
}
@Override
- public ListIterator<E> listIterator(int index) {
+ public ListIterator<E> listIterator(final int index) {
return UnmodifiableListIterator.umodifiableListIterator(decorated().listIterator(index));
}
@Override
- public void add(int index, E object) {
+ public void add(final int index, final E object) {
throw new UnsupportedOperationException();
}
@Override
- public boolean addAll(int index, Collection<? extends E> coll) {
+ public boolean addAll(final int index, final Collection<? extends E> coll) {
throw new UnsupportedOperationException();
}
@Override
- public E remove(int index) {
+ public E remove(final int index) {
throw new UnsupportedOperationException();
}
@Override
- public E set(int index, E object) {
+ public E set(final int index, final E object) {
throw new UnsupportedOperationException();
}
@Override
- public List<E> subList(int fromIndex, int toIndex) {
- List<E> sub = decorated().subList(fromIndex, toIndex);
+ public List<E> subList(final int fromIndex, final int toIndex) {
+ final List<E> sub = decorated().subList(fromIndex, toIndex);
return new UnmodifiableList<E>(sub);
}