Checkstyle fixes.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1369931 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart 2012-08-06 19:21:29 +00:00
parent cf940ca403
commit 614013ae31
10 changed files with 99 additions and 1 deletions

View File

@ -55,14 +55,18 @@ public abstract class AbstractMapEntryDecorator<K, V> implements Map.Entry<K, V>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public K getKey() { public K getKey() {
return entry.getKey(); return entry.getKey();
} }
/** {@inheritDoc} */
public V getValue() { public V getValue() {
return entry.getValue(); return entry.getValue();
} }
/** {@inheritDoc} */
public V setValue(V object) { public V setValue(V object) {
return entry.setValue(object); return entry.setValue(object);
} }

View File

@ -99,33 +99,43 @@ public abstract class AbstractLinkedList<E> implements List<E> {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public int size() { public int size() {
return size; return size;
} }
/** {@inheritDoc} */
public boolean isEmpty() { public boolean isEmpty() {
return (size() == 0); return (size() == 0);
} }
/** {@inheritDoc} */
public E get(int index) { public E get(int index) {
Node<E> node = getNode(index, false); Node<E> node = getNode(index, false);
return node.getValue(); return node.getValue();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public Iterator<E> iterator() { public Iterator<E> iterator() {
return listIterator(); return listIterator();
} }
/** {@inheritDoc} */
public ListIterator<E> listIterator() { public ListIterator<E> listIterator() {
return new LinkedListIterator<E>(this, 0); return new LinkedListIterator<E>(this, 0);
} }
/** {@inheritDoc} */
public ListIterator<E> listIterator(int fromIndex) { public ListIterator<E> listIterator(int fromIndex) {
return new LinkedListIterator<E>(this, fromIndex); return new LinkedListIterator<E>(this, fromIndex);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public int indexOf(Object value) { public int indexOf(Object value) {
int i = 0; int i = 0;
for (Node<E> node = header.next; node != header; node = node.next) { for (Node<E> node = header.next; node != header; node = node.next) {
@ -137,6 +147,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return -1; return -1;
} }
/** {@inheritDoc} */
public int lastIndexOf(Object value) { public int lastIndexOf(Object value) {
int i = size - 1; int i = size - 1;
for (Node<E> node = header.previous; node != header; node = node.previous) { for (Node<E> node = header.previous; node != header; node = node.previous) {
@ -148,10 +159,12 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return -1; return -1;
} }
/** {@inheritDoc} */
public boolean contains(Object value) { public boolean contains(Object value) {
return indexOf(value) != -1; return indexOf(value) != -1;
} }
/** {@inheritDoc} */
public boolean containsAll(Collection<?> coll) { public boolean containsAll(Collection<?> coll) {
for (Object o : coll) { for (Object o : coll) {
if (!contains(o)) { if (!contains(o)) {
@ -162,10 +175,13 @@ public abstract class AbstractLinkedList<E> implements List<E> {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public Object[] toArray() { public Object[] toArray() {
return toArray(new Object[size]); return toArray(new Object[size]);
} }
/** {@inheritDoc} */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] array) { public <T> T[] toArray(T[] array) {
// Extend the array if needed // Extend the array if needed
@ -197,20 +213,25 @@ public abstract class AbstractLinkedList<E> implements List<E> {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public boolean add(E value) { public boolean add(E value) {
addLast(value); addLast(value);
return true; return true;
} }
/** {@inheritDoc} */
public void add(int index, E value) { public void add(int index, E value) {
Node<E> node = getNode(index, true); Node<E> node = getNode(index, true);
addNodeBefore(node, value); addNodeBefore(node, value);
} }
/** {@inheritDoc} */
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
return addAll(size, coll); return addAll(size, coll);
} }
/** {@inheritDoc} */
public boolean addAll(int index, Collection<? extends E> coll) { public boolean addAll(int index, Collection<? extends E> coll) {
Node<E> node = getNode(index, true); Node<E> node = getNode(index, true);
for (E e : coll) { for (E e : coll) {
@ -220,6 +241,8 @@ public abstract class AbstractLinkedList<E> implements List<E> {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public E remove(int index) { public E remove(int index) {
Node<E> node = getNode(index, false); Node<E> node = getNode(index, false);
E oldValue = node.getValue(); E oldValue = node.getValue();
@ -227,6 +250,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return oldValue; return oldValue;
} }
/** {@inheritDoc} */
public boolean remove(Object value) { public boolean remove(Object value) {
for (Node<E> node = header.next; node != header; node = node.next) { for (Node<E> node = header.next; node != header; node = node.next) {
if (isEqualValue(node.getValue(), value)) { if (isEqualValue(node.getValue(), value)) {
@ -237,6 +261,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return false; return false;
} }
/** {@inheritDoc} */
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
boolean modified = false; boolean modified = false;
Iterator<E> it = iterator(); Iterator<E> it = iterator();
@ -250,6 +275,8 @@ public abstract class AbstractLinkedList<E> implements List<E> {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
boolean modified = false; boolean modified = false;
Iterator<E> it = iterator(); Iterator<E> it = iterator();
@ -262,6 +289,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return modified; return modified;
} }
/** {@inheritDoc} */
public E set(int index, E value) { public E set(int index, E value) {
Node<E> node = getNode(index, false); Node<E> node = getNode(index, false);
E oldValue = node.getValue(); E oldValue = node.getValue();
@ -269,11 +297,13 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return oldValue; return oldValue;
} }
/** {@inheritDoc} */
public void clear() { public void clear() {
removeAllNodes(); removeAllNodes();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
public E getFirst() { public E getFirst() {
Node<E> node = header.next; Node<E> node = header.next;
if (node == header) { if (node == header) {
@ -338,8 +368,9 @@ public abstract class AbstractLinkedList<E> implements List<E> {
while (it1.hasNext() && it2.hasNext()) { while (it1.hasNext() && it2.hasNext()) {
Object o1 = it1.next(); Object o1 = it1.next();
Object o2 = it2.next(); Object o2 = it2.next();
if (!(o1 == null ? o2 == null : o1.equals(o2))) if (!(o1 == null ? o2 == null : o1.equals(o2))) {
return false; return false;
}
} }
return !(it1.hasNext() || it2.hasNext()); return !(it1.hasNext() || it2.hasNext());
} }

View File

@ -66,42 +66,53 @@ public abstract class AbstractListDecorator<E> extends AbstractCollectionDecorat
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public void add(int index, E object) { public void add(int index, E object) {
decorated().add(index, object); decorated().add(index, object);
} }
/** {@inheritDoc} */
public boolean addAll(int index, Collection<? extends E> coll) { public boolean addAll(int index, Collection<? extends E> coll) {
return decorated().addAll(index, coll); return decorated().addAll(index, coll);
} }
/** {@inheritDoc} */
public E get(int index) { public E get(int index) {
return decorated().get(index); return decorated().get(index);
} }
/** {@inheritDoc} */
public int indexOf(Object object) { public int indexOf(Object object) {
return decorated().indexOf(object); return decorated().indexOf(object);
} }
/** {@inheritDoc} */
public int lastIndexOf(Object object) { public int lastIndexOf(Object object) {
return decorated().lastIndexOf(object); return decorated().lastIndexOf(object);
} }
/** {@inheritDoc} */
public ListIterator<E> listIterator() { public ListIterator<E> listIterator() {
return decorated().listIterator(); return decorated().listIterator();
} }
/** {@inheritDoc} */
public ListIterator<E> listIterator(int index) { public ListIterator<E> listIterator(int index) {
return decorated().listIterator(index); return decorated().listIterator(index);
} }
/** {@inheritDoc} */
public E remove(int index) { public E remove(int index) {
return decorated().remove(index); return decorated().remove(index);
} }
/** {@inheritDoc} */
public E set(int index, E object) { public E set(int index, E object) {
return decorated().set(index, object); return decorated().set(index, object);
} }
/** {@inheritDoc} */
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
return decorated().subList(fromIndex, toIndex); return decorated().subList(fromIndex, toIndex);
} }

View File

@ -383,6 +383,7 @@ public class CursorableLinkedList<E> extends AbstractLinkedList<E> implements Se
* *
* @param subList the sublist to get an iterator for * @param subList the sublist to get an iterator for
* @param fromIndex the index to start from, relative to the sublist * @param fromIndex the index to start from, relative to the sublist
* @return the list iterator for the sublist
*/ */
@Override @Override
protected ListIterator<E> createSubListListIterator(LinkedSubList<E> subList, int fromIndex) { protected ListIterator<E> createSubListListIterator(LinkedSubList<E> subList, int fromIndex) {
@ -407,6 +408,7 @@ public class CursorableLinkedList<E> extends AbstractLinkedList<E> implements Se
/** /**
* Constructs a new cursor. * Constructs a new cursor.
* *
* @param parent the parent list
* @param index the index to start from * @param index the index to start from
*/ */
protected Cursor(CursorableLinkedList<E> parent, int index) { protected Cursor(CursorableLinkedList<E> parent, int index) {
@ -577,6 +579,7 @@ public class CursorableLinkedList<E> extends AbstractLinkedList<E> implements Se
/** /**
* Constructs a new cursor. * Constructs a new cursor.
* *
* @param sub the sub list
* @param index the index to start from * @param index the index to start from
*/ */
protected SubCursor(LinkedSubList<E> sub, int index) { protected SubCursor(LinkedSubList<E> sub, int index) {

View File

@ -170,10 +170,12 @@ public class FixedSizeList<E>
} }
} }
/** {@inheritDoc} */
public boolean isFull() { public boolean isFull() {
return true; return true;
} }
/** {@inheritDoc} */
public int maxSize() { public int maxSize() {
return size(); return size();
} }

View File

@ -104,6 +104,7 @@ public class LazyList<E> extends AbstractSerializableListDecorator<E> {
* placeholder that is replaced with a factory object when requested. * placeholder that is replaced with a factory object when requested.
* *
* @param index the index to retrieve * @param index the index to retrieve
* @return the element at the given index
*/ */
@Override @Override
public E get(int index) { public E get(int index) {

View File

@ -89,28 +89,36 @@ public class PredicatedList<E> extends PredicatedCollection<E> implements List<E
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public E get(int index) { public E get(int index) {
return decorated().get(index); return decorated().get(index);
} }
/** {@inheritDoc} */
public int indexOf(Object object) { public int indexOf(Object object) {
return decorated().indexOf(object); return decorated().indexOf(object);
} }
/** {@inheritDoc} */
public int lastIndexOf(Object object) { public int lastIndexOf(Object object) {
return decorated().lastIndexOf(object); return decorated().lastIndexOf(object);
} }
/** {@inheritDoc} */
public E remove(int index) { public E remove(int index) {
return decorated().remove(index); return decorated().remove(index);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public void add(int index, E object) { public void add(int index, E object) {
validate(object); validate(object);
decorated().add(index, object); decorated().add(index, object);
} }
/** {@inheritDoc} */
public boolean addAll(int index, Collection<? extends E> coll) { public boolean addAll(int index, Collection<? extends E> coll) {
for (E aColl : coll) { for (E aColl : coll) {
validate(aColl); validate(aColl);
@ -118,19 +126,23 @@ public class PredicatedList<E> extends PredicatedCollection<E> implements List<E
return decorated().addAll(index, coll); return decorated().addAll(index, coll);
} }
/** {@inheritDoc} */
public ListIterator<E> listIterator() { public ListIterator<E> listIterator() {
return listIterator(0); return listIterator(0);
} }
/** {@inheritDoc} */
public ListIterator<E> listIterator(int i) { public ListIterator<E> listIterator(int i) {
return new PredicatedListIterator(decorated().listIterator(i)); return new PredicatedListIterator(decorated().listIterator(i));
} }
/** {@inheritDoc} */
public E set(int index, E object) { public E set(int index, E object) {
validate(object); validate(object);
return decorated().set(index, object); return decorated().set(index, object);
} }
/** {@inheritDoc} */
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
List<E> sub = decorated().subList(fromIndex, toIndex); List<E> sub = decorated().subList(fromIndex, toIndex);
return new PredicatedList<E>(sub, predicate); return new PredicatedList<E>(sub, predicate);
@ -141,6 +153,11 @@ public class PredicatedList<E> extends PredicatedCollection<E> implements List<E
*/ */
protected class PredicatedListIterator extends AbstractListIteratorDecorator<E> { protected class PredicatedListIterator extends AbstractListIteratorDecorator<E> {
/**
* Create a new predicated list iterator.
*
* @param iterator the list iterator to decorate
*/
protected PredicatedListIterator(ListIterator<E> iterator) { protected PredicatedListIterator(ListIterator<E> iterator) {
super(iterator); super(iterator);
} }

View File

@ -82,30 +82,36 @@ public class SynchronizedList<E> extends SynchronizedCollection<E> implements Li
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public void add(int index, E object) { public void add(int index, E object) {
synchronized (lock) { synchronized (lock) {
getList().add(index, object); getList().add(index, object);
} }
} }
/** {@inheritDoc} */
public boolean addAll(int index, Collection<? extends E> coll) { public boolean addAll(int index, Collection<? extends E> coll) {
synchronized (lock) { synchronized (lock) {
return getList().addAll(index, coll); return getList().addAll(index, coll);
} }
} }
/** {@inheritDoc} */
public E get(int index) { public E get(int index) {
synchronized (lock) { synchronized (lock) {
return getList().get(index); return getList().get(index);
} }
} }
/** {@inheritDoc} */
public int indexOf(Object object) { public int indexOf(Object object) {
synchronized (lock) { synchronized (lock) {
return getList().indexOf(object); return getList().indexOf(object);
} }
} }
/** {@inheritDoc} */
public int lastIndexOf(Object object) { public int lastIndexOf(Object object) {
synchronized (lock) { synchronized (lock) {
return getList().lastIndexOf(object); return getList().lastIndexOf(object);
@ -134,24 +140,28 @@ public class SynchronizedList<E> extends SynchronizedCollection<E> implements Li
* // do stuff with iterator * // 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 * @return an iterator that must be manually synchronized on the collection
*/ */
public ListIterator<E> listIterator(int index) { public ListIterator<E> listIterator(int index) {
return getList().listIterator(index); return getList().listIterator(index);
} }
/** {@inheritDoc} */
public E remove(int index) { public E remove(int index) {
synchronized (lock) { synchronized (lock) {
return getList().remove(index); return getList().remove(index);
} }
} }
/** {@inheritDoc} */
public E set(int index, E object) { public E set(int index, E object) {
synchronized (lock) { synchronized (lock) {
return getList().set(index, object); return getList().set(index, object);
} }
} }
/** {@inheritDoc} */
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
synchronized (lock) { synchronized (lock) {
List<E> list = getList().subList(fromIndex, toIndex); List<E> list = getList().subList(fromIndex, toIndex);

View File

@ -114,46 +114,58 @@ public class TransformedList<E> extends TransformedCollection<E> implements List
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public E get(int index) { public E get(int index) {
return getList().get(index); return getList().get(index);
} }
/** {@inheritDoc} */
public int indexOf(Object object) { public int indexOf(Object object) {
return getList().indexOf(object); return getList().indexOf(object);
} }
/** {@inheritDoc} */
public int lastIndexOf(Object object) { public int lastIndexOf(Object object) {
return getList().lastIndexOf(object); return getList().lastIndexOf(object);
} }
/** {@inheritDoc} */
public E remove(int index) { public E remove(int index) {
return getList().remove(index); return getList().remove(index);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** {@inheritDoc} */
public void add(int index, E object) { public void add(int index, E object) {
object = transform(object); object = transform(object);
getList().add(index, object); getList().add(index, object);
} }
/** {@inheritDoc} */
public boolean addAll(int index, Collection<? extends E> coll) { public boolean addAll(int index, Collection<? extends E> coll) {
coll = transform(coll); coll = transform(coll);
return getList().addAll(index, coll); return getList().addAll(index, coll);
} }
/** {@inheritDoc} */
public ListIterator<E> listIterator() { public ListIterator<E> listIterator() {
return listIterator(0); return listIterator(0);
} }
/** {@inheritDoc} */
public ListIterator<E> listIterator(int i) { public ListIterator<E> listIterator(int i) {
return new TransformedListIterator(getList().listIterator(i)); return new TransformedListIterator(getList().listIterator(i));
} }
/** {@inheritDoc} */
public E set(int index, E object) { public E set(int index, E object) {
object = transform(object); object = transform(object);
return getList().set(index, object); return getList().set(index, object);
} }
/** {@inheritDoc} */
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
List<E> sub = getList().subList(fromIndex, toIndex); List<E> sub = getList().subList(fromIndex, toIndex);
return new TransformedList<E>(sub, transformer); return new TransformedList<E>(sub, transformer);
@ -164,6 +176,11 @@ public class TransformedList<E> extends TransformedCollection<E> implements List
*/ */
protected class TransformedListIterator extends AbstractListIteratorDecorator<E> { protected class TransformedListIterator extends AbstractListIteratorDecorator<E> {
/**
* Create a new transformed list iterator.
*
* @param iterator the list iterator to decorate
*/
protected TransformedListIterator(ListIterator<E> iterator) { protected TransformedListIterator(ListIterator<E> iterator) {
super(iterator); super(iterator);
} }

View File

@ -146,6 +146,7 @@ public class TreeList<E> extends AbstractList<E> {
/** /**
* Searches for the index of an object in the list. * 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 * @return the index of the object, -1 if not found
*/ */
@Override @Override
@ -160,6 +161,7 @@ public class TreeList<E> extends AbstractList<E> {
/** /**
* Searches for the presence of an object in the list. * Searches for the presence of an object in the list.
* *
* @param object the object to check
* @return true if the object is found * @return true if the object is found
*/ */
@Override @Override