From 614013ae31c57bcd322ce2f2c2f997d94c332d59 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Mon, 6 Aug 2012 19:21:29 +0000 Subject: [PATCH] Checkstyle fixes. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1369931 13f79535-47bb-0310-9956-ffa450edef68 --- .../keyvalue/AbstractMapEntryDecorator.java | 4 +++ .../collections/list/AbstractLinkedList.java | 33 ++++++++++++++++++- .../list/AbstractListDecorator.java | 11 +++++++ .../list/CursorableLinkedList.java | 3 ++ .../collections/list/FixedSizeList.java | 2 ++ .../commons/collections/list/LazyList.java | 1 + .../collections/list/PredicatedList.java | 17 ++++++++++ .../collections/list/SynchronizedList.java | 10 ++++++ .../collections/list/TransformedList.java | 17 ++++++++++ .../commons/collections/list/TreeList.java | 2 ++ 10 files changed, 99 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/collections/keyvalue/AbstractMapEntryDecorator.java b/src/main/java/org/apache/commons/collections/keyvalue/AbstractMapEntryDecorator.java index 9725f29c1..545a078ee 100644 --- a/src/main/java/org/apache/commons/collections/keyvalue/AbstractMapEntryDecorator.java +++ b/src/main/java/org/apache/commons/collections/keyvalue/AbstractMapEntryDecorator.java @@ -55,14 +55,18 @@ public abstract class AbstractMapEntryDecorator implements Map.Entry } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public K getKey() { return entry.getKey(); } + /** {@inheritDoc} */ public V getValue() { return entry.getValue(); } + /** {@inheritDoc} */ public V setValue(V object) { return entry.setValue(object); } diff --git a/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java b/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java index f139f823e..17457b288 100644 --- a/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java +++ b/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java @@ -99,33 +99,43 @@ public abstract class AbstractLinkedList implements List { } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public int size() { return size; } + /** {@inheritDoc} */ public boolean isEmpty() { return (size() == 0); } + /** {@inheritDoc} */ public E get(int index) { Node node = getNode(index, false); return node.getValue(); } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public Iterator iterator() { return listIterator(); } + /** {@inheritDoc} */ public ListIterator listIterator() { return new LinkedListIterator(this, 0); } + /** {@inheritDoc} */ public ListIterator listIterator(int fromIndex) { return new LinkedListIterator(this, fromIndex); } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public int indexOf(Object value) { int i = 0; for (Node node = header.next; node != header; node = node.next) { @@ -137,6 +147,7 @@ public abstract class AbstractLinkedList implements List { return -1; } + /** {@inheritDoc} */ public int lastIndexOf(Object value) { int i = size - 1; for (Node node = header.previous; node != header; node = node.previous) { @@ -148,10 +159,12 @@ public abstract class AbstractLinkedList implements List { return -1; } + /** {@inheritDoc} */ public boolean contains(Object value) { return indexOf(value) != -1; } + /** {@inheritDoc} */ public boolean containsAll(Collection coll) { for (Object o : coll) { if (!contains(o)) { @@ -162,10 +175,13 @@ public abstract class AbstractLinkedList implements List { } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public Object[] toArray() { return toArray(new Object[size]); } + /** {@inheritDoc} */ @SuppressWarnings("unchecked") public T[] toArray(T[] array) { // Extend the array if needed @@ -197,20 +213,25 @@ public abstract class AbstractLinkedList implements List { } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public boolean add(E value) { addLast(value); return true; } + /** {@inheritDoc} */ public void add(int index, E value) { Node node = getNode(index, true); addNodeBefore(node, value); } + /** {@inheritDoc} */ public boolean addAll(Collection coll) { return addAll(size, coll); } + /** {@inheritDoc} */ public boolean addAll(int index, Collection coll) { Node node = getNode(index, true); for (E e : coll) { @@ -220,6 +241,8 @@ public abstract class AbstractLinkedList implements List { } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public E remove(int index) { Node node = getNode(index, false); E oldValue = node.getValue(); @@ -227,6 +250,7 @@ public abstract class AbstractLinkedList implements List { return oldValue; } + /** {@inheritDoc} */ public boolean remove(Object value) { for (Node node = header.next; node != header; node = node.next) { if (isEqualValue(node.getValue(), value)) { @@ -237,6 +261,7 @@ public abstract class AbstractLinkedList implements List { return false; } + /** {@inheritDoc} */ public boolean removeAll(Collection coll) { boolean modified = false; Iterator it = iterator(); @@ -250,6 +275,8 @@ public abstract class AbstractLinkedList implements List { } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public boolean retainAll(Collection coll) { boolean modified = false; Iterator it = iterator(); @@ -262,6 +289,7 @@ public abstract class AbstractLinkedList implements List { return modified; } + /** {@inheritDoc} */ public E set(int index, E value) { Node node = getNode(index, false); E oldValue = node.getValue(); @@ -269,11 +297,13 @@ public abstract class AbstractLinkedList implements List { return oldValue; } + /** {@inheritDoc} */ public void clear() { removeAllNodes(); } //----------------------------------------------------------------------- + public E getFirst() { Node node = header.next; if (node == header) { @@ -338,8 +368,9 @@ public abstract class AbstractLinkedList implements List { while (it1.hasNext() && it2.hasNext()) { Object o1 = it1.next(); Object o2 = it2.next(); - if (!(o1 == null ? o2 == null : o1.equals(o2))) + if (!(o1 == null ? o2 == null : o1.equals(o2))) { return false; + } } return !(it1.hasNext() || it2.hasNext()); } diff --git a/src/main/java/org/apache/commons/collections/list/AbstractListDecorator.java b/src/main/java/org/apache/commons/collections/list/AbstractListDecorator.java index f7659c158..fe07ebe36 100644 --- a/src/main/java/org/apache/commons/collections/list/AbstractListDecorator.java +++ b/src/main/java/org/apache/commons/collections/list/AbstractListDecorator.java @@ -66,42 +66,53 @@ public abstract class AbstractListDecorator extends AbstractCollectionDecorat } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public void add(int index, E object) { decorated().add(index, object); } + /** {@inheritDoc} */ public boolean addAll(int index, Collection coll) { return decorated().addAll(index, coll); } + /** {@inheritDoc} */ public E get(int index) { return decorated().get(index); } + /** {@inheritDoc} */ public int indexOf(Object object) { return decorated().indexOf(object); } + /** {@inheritDoc} */ public int lastIndexOf(Object object) { return decorated().lastIndexOf(object); } + /** {@inheritDoc} */ public ListIterator listIterator() { return decorated().listIterator(); } + /** {@inheritDoc} */ public ListIterator listIterator(int index) { return decorated().listIterator(index); } + /** {@inheritDoc} */ public E remove(int index) { return decorated().remove(index); } + /** {@inheritDoc} */ public E set(int index, E object) { return decorated().set(index, object); } + /** {@inheritDoc} */ public List subList(int fromIndex, int toIndex) { return decorated().subList(fromIndex, toIndex); } diff --git a/src/main/java/org/apache/commons/collections/list/CursorableLinkedList.java b/src/main/java/org/apache/commons/collections/list/CursorableLinkedList.java index 2672af2a2..0f0b358d5 100644 --- a/src/main/java/org/apache/commons/collections/list/CursorableLinkedList.java +++ b/src/main/java/org/apache/commons/collections/list/CursorableLinkedList.java @@ -383,6 +383,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Se * * @param subList the sublist to get an iterator for * @param fromIndex the index to start from, relative to the sublist + * @return the list iterator for the sublist */ @Override protected ListIterator createSubListListIterator(LinkedSubList subList, int fromIndex) { @@ -407,6 +408,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Se /** * Constructs a new cursor. * + * @param parent the parent list * @param index the index to start from */ protected Cursor(CursorableLinkedList parent, int index) { @@ -577,6 +579,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Se /** * Constructs a new cursor. * + * @param sub the sub list * @param index the index to start from */ protected SubCursor(LinkedSubList sub, int index) { diff --git a/src/main/java/org/apache/commons/collections/list/FixedSizeList.java b/src/main/java/org/apache/commons/collections/list/FixedSizeList.java index d350b12ca..ee9595520 100644 --- a/src/main/java/org/apache/commons/collections/list/FixedSizeList.java +++ b/src/main/java/org/apache/commons/collections/list/FixedSizeList.java @@ -170,10 +170,12 @@ public class FixedSizeList } } + /** {@inheritDoc} */ public boolean isFull() { return true; } + /** {@inheritDoc} */ public int maxSize() { return size(); } diff --git a/src/main/java/org/apache/commons/collections/list/LazyList.java b/src/main/java/org/apache/commons/collections/list/LazyList.java index 8544111a4..fe561718f 100644 --- a/src/main/java/org/apache/commons/collections/list/LazyList.java +++ b/src/main/java/org/apache/commons/collections/list/LazyList.java @@ -104,6 +104,7 @@ public class LazyList extends AbstractSerializableListDecorator { * placeholder that is replaced with a factory object when requested. * * @param index the index to retrieve + * @return the element at the given index */ @Override public E get(int index) { diff --git a/src/main/java/org/apache/commons/collections/list/PredicatedList.java b/src/main/java/org/apache/commons/collections/list/PredicatedList.java index 859f895b8..6458122c8 100644 --- a/src/main/java/org/apache/commons/collections/list/PredicatedList.java +++ b/src/main/java/org/apache/commons/collections/list/PredicatedList.java @@ -89,28 +89,36 @@ public class PredicatedList extends PredicatedCollection implements List coll) { for (E aColl : coll) { validate(aColl); @@ -118,19 +126,23 @@ public class PredicatedList extends PredicatedCollection implements List listIterator() { return listIterator(0); } + /** {@inheritDoc} */ public ListIterator listIterator(int i) { return new PredicatedListIterator(decorated().listIterator(i)); } + /** {@inheritDoc} */ public E set(int index, E object) { validate(object); return decorated().set(index, object); } + /** {@inheritDoc} */ public List subList(int fromIndex, int toIndex) { List sub = decorated().subList(fromIndex, toIndex); return new PredicatedList(sub, predicate); @@ -141,6 +153,11 @@ public class PredicatedList extends PredicatedCollection implements List { + /** + * Create a new predicated list iterator. + * + * @param iterator the list iterator to decorate + */ protected PredicatedListIterator(ListIterator iterator) { super(iterator); } diff --git a/src/main/java/org/apache/commons/collections/list/SynchronizedList.java b/src/main/java/org/apache/commons/collections/list/SynchronizedList.java index f60a30e17..cc46d11c2 100644 --- a/src/main/java/org/apache/commons/collections/list/SynchronizedList.java +++ b/src/main/java/org/apache/commons/collections/list/SynchronizedList.java @@ -82,30 +82,36 @@ public class SynchronizedList extends SynchronizedCollection implements Li } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public void add(int index, E object) { synchronized (lock) { getList().add(index, object); } } + /** {@inheritDoc} */ public boolean addAll(int index, Collection coll) { synchronized (lock) { return getList().addAll(index, coll); } } + /** {@inheritDoc} */ public E get(int index) { synchronized (lock) { return getList().get(index); } } + /** {@inheritDoc} */ public int indexOf(Object object) { synchronized (lock) { return getList().indexOf(object); } } + /** {@inheritDoc} */ public int lastIndexOf(Object object) { synchronized (lock) { return getList().lastIndexOf(object); @@ -134,24 +140,28 @@ public class SynchronizedList extends SynchronizedCollection implements Li * // do stuff with iterator * } * + * @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 listIterator(int index) { return getList().listIterator(index); } + /** {@inheritDoc} */ public E remove(int index) { synchronized (lock) { return getList().remove(index); } } + /** {@inheritDoc} */ public E set(int index, E object) { synchronized (lock) { return getList().set(index, object); } } + /** {@inheritDoc} */ public List subList(int fromIndex, int toIndex) { synchronized (lock) { List list = getList().subList(fromIndex, toIndex); diff --git a/src/main/java/org/apache/commons/collections/list/TransformedList.java b/src/main/java/org/apache/commons/collections/list/TransformedList.java index 0bc7ce6b0..84c20f983 100644 --- a/src/main/java/org/apache/commons/collections/list/TransformedList.java +++ b/src/main/java/org/apache/commons/collections/list/TransformedList.java @@ -114,46 +114,58 @@ public class TransformedList extends TransformedCollection implements List } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public E get(int index) { return getList().get(index); } + /** {@inheritDoc} */ public int indexOf(Object object) { return getList().indexOf(object); } + /** {@inheritDoc} */ public int lastIndexOf(Object object) { return getList().lastIndexOf(object); } + /** {@inheritDoc} */ public E remove(int index) { return getList().remove(index); } //----------------------------------------------------------------------- + + /** {@inheritDoc} */ public void add(int index, E object) { object = transform(object); getList().add(index, object); } + /** {@inheritDoc} */ public boolean addAll(int index, Collection coll) { coll = transform(coll); return getList().addAll(index, coll); } + /** {@inheritDoc} */ public ListIterator listIterator() { return listIterator(0); } + /** {@inheritDoc} */ public ListIterator listIterator(int i) { return new TransformedListIterator(getList().listIterator(i)); } + /** {@inheritDoc} */ public E set(int index, E object) { object = transform(object); return getList().set(index, object); } + /** {@inheritDoc} */ public List subList(int fromIndex, int toIndex) { List sub = getList().subList(fromIndex, toIndex); return new TransformedList(sub, transformer); @@ -164,6 +176,11 @@ public class TransformedList extends TransformedCollection implements List */ protected class TransformedListIterator extends AbstractListIteratorDecorator { + /** + * Create a new transformed list iterator. + * + * @param iterator the list iterator to decorate + */ protected TransformedListIterator(ListIterator iterator) { super(iterator); } diff --git a/src/main/java/org/apache/commons/collections/list/TreeList.java b/src/main/java/org/apache/commons/collections/list/TreeList.java index 5f93effa7..66e9c7d9c 100644 --- a/src/main/java/org/apache/commons/collections/list/TreeList.java +++ b/src/main/java/org/apache/commons/collections/list/TreeList.java @@ -146,6 +146,7 @@ public class TreeList extends AbstractList { /** * Searches for the index of an object in the list. * + * @param object the object to search * @return the index of the object, -1 if not found */ @Override @@ -160,6 +161,7 @@ public class TreeList extends AbstractList { /** * Searches for the presence of an object in the list. * + * @param object the object to check * @return true if the object is found */ @Override