diff --git a/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java b/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java index 4a76fc8ee7..59a5d3feaa 100644 --- a/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java +++ b/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java @@ -76,6 +76,11 @@ public int hash(final T o) { return o == null ? HASHCODE_NULL : o.hashCode(); } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/functors/ExceptionClosure.java b/src/main/java/org/apache/commons/collections4/functors/ExceptionClosure.java index ee366661ec..1b5196d256 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ExceptionClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/ExceptionClosure.java @@ -63,6 +63,11 @@ public void execute(final E input) { throw new FunctorException("ExceptionClosure invoked"); } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/functors/ExceptionFactory.java b/src/main/java/org/apache/commons/collections4/functors/ExceptionFactory.java index 518551bce4..04925c9a4a 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ExceptionFactory.java +++ b/src/main/java/org/apache/commons/collections4/functors/ExceptionFactory.java @@ -63,6 +63,11 @@ public T create() { throw new FunctorException("ExceptionFactory invoked"); } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java b/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java index 3348cbba48..bf46f60eae 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java @@ -65,6 +65,11 @@ public boolean evaluate(final T object) { throw new FunctorException("ExceptionPredicate invoked"); } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java b/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java index 68deb5697d..b5978605ee 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java @@ -53,6 +53,11 @@ public static Transformer exceptionTransformer() { private ExceptionTransformer() { } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java b/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java index b52a0a0a0e..184234c6bf 100644 --- a/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java @@ -63,6 +63,11 @@ public boolean evaluate(final T object) { return false; } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/functors/NOPClosure.java b/src/main/java/org/apache/commons/collections4/functors/NOPClosure.java index 5bfb050b40..252221e7fb 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NOPClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/NOPClosure.java @@ -61,6 +61,11 @@ public void execute(final E input) { // do nothing } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java b/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java index 306792e13a..e025fc5531 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java @@ -51,6 +51,11 @@ public static Transformer nopTransformer() { private NOPTransformer() { } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java b/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java index e8ebbf604c..6913cfdb45 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java @@ -63,6 +63,11 @@ public boolean evaluate(final T object) { return object != null; } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java b/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java index 8aca8c8709..93820fc54f 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java @@ -63,6 +63,11 @@ public boolean evaluate(final T object) { return object == null; } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java b/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java index 3205edfb2a..e39caa6cff 100644 --- a/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java @@ -52,6 +52,11 @@ public static Transformer stringValueTransformer() { private StringValueTransformer() { } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java b/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java index a17d319b22..ef1dd6a948 100644 --- a/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java @@ -63,6 +63,11 @@ public boolean evaluate(final T object) { return true; } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ private Object readResolve() { return INSTANCE; } diff --git a/src/main/java/org/apache/commons/collections4/keyvalue/AbstractKeyValue.java b/src/main/java/org/apache/commons/collections4/keyvalue/AbstractKeyValue.java index 1a743f315c..3c13e71d0d 100644 --- a/src/main/java/org/apache/commons/collections4/keyvalue/AbstractKeyValue.java +++ b/src/main/java/org/apache/commons/collections4/keyvalue/AbstractKeyValue.java @@ -64,12 +64,24 @@ public V getValue() { return value; } + /** + * Sets the key. + * + * @param key The key. + * @return The previous key. + */ protected K setKey(final K key) { final K old = this.key; this.key = key; return old; } + /** + * Sets the value. + * + * @param value The value. + * @return The previous value. + */ protected V setValue(final V value) { final V old = this.value; this.value = value; diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java index 8e458ad976..1e344c6908 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java @@ -67,9 +67,15 @@ public class AbstractHashedMap extends AbstractMap implements Iterab * @param the type of the values in the map */ protected static class EntrySet extends AbstractSet> { + /** The parent map */ private final AbstractHashedMap parent; + /** + * Constructs a new instance. + * + * @param parent The parent map. + */ protected EntrySet(final AbstractHashedMap parent) { this.parent = parent; } @@ -112,6 +118,7 @@ public int size() { return parent.size(); } } + /** * EntrySet iterator. * @@ -120,6 +127,11 @@ public int size() { */ protected static class EntrySetIterator extends HashIterator implements Iterator> { + /** + * Constructs a new instance. + * + * @param parent The parent map. + */ protected EntrySetIterator(final AbstractHashedMap parent) { super(parent); } @@ -129,6 +141,7 @@ public Map.Entry next() { return super.nextEntry(); } } + /** * HashEntry used to store the data. *

@@ -136,17 +149,22 @@ public Map.Entry next() { * then you will not be able to access the protected fields. * The {@code entryXxx()} methods on {@code AbstractHashedMap} exist * to provide the necessary access. + *

* * @param the type of the keys * @param the type of the values */ protected static class HashEntry implements Map.Entry, KeyValue { + /** The next entry in the hash chain */ protected HashEntry next; + /** The hash code of the key */ protected int hashCode; + /** The key */ protected Object key; + /** The value */ protected Object value; @@ -206,7 +224,7 @@ public String toString() { } } /** - * Base Iterator + * Base Iterator. * * @param the type of the keys in the map * @param the type of the values in the map @@ -215,12 +233,16 @@ protected abstract static class HashIterator { /** The parent map */ private final AbstractHashedMap parent; + /** The current index into the array of buckets */ private int hashIndex; + /** The last returned entry */ private HashEntry last; + /** The next entry */ private HashEntry next; + /** The modification count expected */ private int expectedModCount; @@ -285,6 +307,7 @@ public String toString() { return "Iterator[]"; } } + /** * MapIterator implementation. * @@ -329,6 +352,7 @@ public V setValue(final V value) { return current.setValue(value); } } + /** * KeySet implementation. * @@ -387,6 +411,7 @@ public K next() { return super.nextEntry().getKey(); } } + /** * Values implementation. * @@ -420,6 +445,7 @@ public int size() { return parent.size(); } } + /** * Values iterator. * @@ -438,11 +464,22 @@ public V next() { } } + /** Exception message. */ protected static final String NO_NEXT_ENTRY = "No next() entry in the iteration"; + + /** Exception message. */ protected static final String NO_PREVIOUS_ENTRY = "No previous() entry in the iteration"; + + /** Exception message. */ protected static final String REMOVE_INVALID = "remove() can only be called once after next()"; + + /** Exception message. */ protected static final String GETKEY_INVALID = "getKey() can only be called after next() and before remove()"; + + /** Exception message. */ protected static final String GETVALUE_INVALID = "getValue() can only be called after next() and before remove()"; + + /** Exception message. */ protected static final String SETVALUE_INVALID = "setValue() can only be called after next() and before remove()"; /** The default capacity to use */