Fix checkstyle warnings, cleanup IteratorUtils, fix throws clauses.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1685902 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
68b92abce7
commit
9f363c0dae
|
@ -68,7 +68,7 @@ public class IterableUtils {
|
|||
* <p>
|
||||
* This iterable does not contain any elements.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @return an empty iterable
|
||||
*/
|
||||
@SuppressWarnings("unchecked") // OK, empty collection is compatible with any type
|
||||
|
@ -89,7 +89,7 @@ public class IterableUtils {
|
|||
* The returned iterable's iterator supports {@code remove()} when the corresponding
|
||||
* input iterator supports it.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param a the first iterable, may not be null
|
||||
* @param b the second iterable, may not be null
|
||||
* @return a new iterable, combining the provided iterables
|
||||
|
@ -111,7 +111,7 @@ public class IterableUtils {
|
|||
* The returned iterable's iterator supports {@code remove()} when the corresponding
|
||||
* input iterator supports it.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param a the first iterable, may not be null
|
||||
* @param b the second iterable, may not be null
|
||||
* @param c the third iterable, may not be null
|
||||
|
@ -135,7 +135,7 @@ public class IterableUtils {
|
|||
* The returned iterable's iterator supports {@code remove()} when the corresponding
|
||||
* input iterator supports it.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param a the first iterable, may not be null
|
||||
* @param b the second iterable, may not be null
|
||||
* @param c the third iterable, may not be null
|
||||
|
@ -161,7 +161,7 @@ public class IterableUtils {
|
|||
* The returned iterable's iterator supports {@code remove()} when the corresponding
|
||||
* input iterator supports it.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterables the iterables to combine, may not be null
|
||||
* @return a new iterable, combining the provided iterables
|
||||
* @throws NullPointerException if either of the provided iterables is null
|
||||
|
@ -195,7 +195,7 @@ public class IterableUtils {
|
|||
* The returned iterable's iterator supports {@code remove()} when the
|
||||
* corresponding input iterator supports it.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param a the first iterable, may not be null
|
||||
* @param b the second iterable, may not be null
|
||||
* @return a filtered view on the specified iterable
|
||||
|
@ -220,7 +220,7 @@ public class IterableUtils {
|
|||
* The returned iterable's iterator supports {@code remove()} when the corresponding
|
||||
* input iterator supports it.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param comparator the comparator defining an ordering over the elements,
|
||||
* may be null, in which case natural ordering will be used
|
||||
* @param a the first iterable, may not be null
|
||||
|
@ -249,7 +249,7 @@ public class IterableUtils {
|
|||
* <p>
|
||||
* The returned iterable's iterator does not support {@code remove()}.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to filter, may not be null
|
||||
* @param predicate the predicate used to filter elements, may not be null
|
||||
* @return a filtered view on the specified iterable
|
||||
|
@ -279,7 +279,7 @@ public class IterableUtils {
|
|||
* The returned iterable's iterator supports {@code remove()} when the corresponding
|
||||
* input iterator supports it.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to limit, may not be null
|
||||
* @param maxSize the maximum number of elements, must not be negative
|
||||
* @return a bounded view on the specified iterable
|
||||
|
@ -313,7 +313,7 @@ public class IterableUtils {
|
|||
* iterator's {@code hasNext()} method returns {@code true} until {@code iterable}
|
||||
* is empty.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to loop, may not be null
|
||||
* @return a view of the iterable, providing an infinite loop over its elements
|
||||
* @throws NullPointerException if iterable is null
|
||||
|
@ -350,7 +350,7 @@ public class IterableUtils {
|
|||
* The returned iterable's iterator supports {@code remove()} if the
|
||||
* provided iterable is a {@link List} instance.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to use, may not be null
|
||||
* @return a reversed view of the specified iterable
|
||||
* @throws NullPointerException if iterable is null
|
||||
|
@ -378,7 +378,7 @@ public class IterableUtils {
|
|||
* The returned iterable's iterator supports {@code remove()} when the corresponding
|
||||
* input iterator supports it.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to use, may not be null
|
||||
* @param elementsToSkip the number of elements to skip from the start, must not be negative
|
||||
* @return a view of the specified iterable, skipping the first N elements
|
||||
|
@ -438,7 +438,7 @@ public class IterableUtils {
|
|||
* <p>
|
||||
* The returned iterable's iterator does not support {@code remove()}.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to use, may not be null
|
||||
* @return a unique view of the specified iterable
|
||||
* @throws NullPointerException if iterable is null
|
||||
|
@ -461,7 +461,7 @@ public class IterableUtils {
|
|||
* <p>
|
||||
* The returned iterable's iterator does not support {@code remove()}.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to use, may not be null
|
||||
* @return an unmodifiable view of the specified iterable
|
||||
* @throws NullPointerException if iterable is null
|
||||
|
@ -504,7 +504,7 @@ public class IterableUtils {
|
|||
* The returned iterable's iterator supports {@code remove()} when the corresponding
|
||||
* input iterator supports it.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param a the first iterable, may not be null
|
||||
* @param b the second iterable, may not be null
|
||||
* @return a new iterable, interleaving the provided iterables
|
||||
|
@ -532,8 +532,9 @@ public class IterableUtils {
|
|||
* The returned iterable's iterator supports {@code remove()} when the corresponding
|
||||
* input iterator supports it.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param iterables the array of iterables to interleave, may not be null
|
||||
* @param <E> the element type
|
||||
* @param first the first iterable, may not be null
|
||||
* @param others the array of iterables to interleave, may not be null
|
||||
* @return a new iterable, interleaving the provided iterables
|
||||
* @throws NullPointerException if either of the provided iterables is null
|
||||
*/
|
||||
|
@ -573,7 +574,7 @@ public class IterableUtils {
|
|||
/**
|
||||
* Applies the closure to each element of the provided iterable.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterator to use, may be null
|
||||
* @param closure the closure to apply to each element, may not be null
|
||||
* @throws NullPointerException if closure is null
|
||||
|
@ -587,8 +588,7 @@ public class IterableUtils {
|
|||
* <p>
|
||||
* If the input iterable is null no change is made.
|
||||
*
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param <C> the closure type
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param iterable the iterable to get the input from, may be null
|
||||
* @param closure the closure to perform, may not be null
|
||||
* @return the last element in the iterable, or null if iterable is null or empty
|
||||
|
@ -602,7 +602,7 @@ public class IterableUtils {
|
|||
* <p>
|
||||
* A <code>null</code> or empty iterator returns null.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to search, may be null
|
||||
* @param predicate the predicate to use, may not be null
|
||||
* @return the first element of the iterable which matches the predicate or null if none could be found
|
||||
|
@ -617,7 +617,7 @@ public class IterableUtils {
|
|||
* <p>
|
||||
* A <code>null</code> or empty iterable returns true.
|
||||
*
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param iterable the {@link Iterable} to use, may be null
|
||||
* @param predicate the predicate to use, may not be null
|
||||
* @return true if every element of the collection matches the predicate or if the
|
||||
|
@ -633,7 +633,7 @@ public class IterableUtils {
|
|||
* <p>
|
||||
* A <code>null</code> or empty iterable returns false.
|
||||
*
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param iterable the {@link Iterable} to use, may be null
|
||||
* @param predicate the predicate to use, may not be null
|
||||
* @return true if any element of the collection matches the predicate, false otherwise
|
||||
|
@ -648,7 +648,7 @@ public class IterableUtils {
|
|||
* <p>
|
||||
* A <code>null</code> iterable matches no elements.
|
||||
*
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param input the {@link Iterable} to get the input from, may be null
|
||||
* @param predicate the predicate to use, may not be null
|
||||
* @return the number of matches for the predicate in the collection
|
||||
|
@ -682,7 +682,7 @@ public class IterableUtils {
|
|||
* <p>
|
||||
* A <code>null</code> or empty iterable returns false.
|
||||
*
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param iterable the iterable to check, may be null
|
||||
* @param object the object to check
|
||||
* @return true if the object is contained in the iterable, false otherwise
|
||||
|
@ -705,7 +705,7 @@ public class IterableUtils {
|
|||
* {@link org.apache.commons.collections4.functors.NullPredicate NullPredicate}
|
||||
* will be used.
|
||||
*
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param <E> the type of object the {@link Iterable} contains
|
||||
* @param iterable the iterable to check, may be null
|
||||
* @param object the object to check
|
||||
* @param equator the equator to use to check, may not be null
|
||||
|
@ -723,7 +723,8 @@ public class IterableUtils {
|
|||
/**
|
||||
* Returns the number of occurrences of the provided object in the iterable.
|
||||
*
|
||||
* @param <E> the type of object that the {@link Iterable} may contain
|
||||
* @param <E> the element type that the {@link Iterable} may contain
|
||||
* @param <T> the element type of the object to find
|
||||
* @param iterable the {@link Iterable} to search
|
||||
* @param obj the object to find the cardinality of
|
||||
* @return the the number of occurrences of obj in iterable
|
||||
|
@ -949,7 +950,7 @@ public class IterableUtils {
|
|||
/**
|
||||
* Gets a new list with the contents of the provided iterable.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to use, may be null
|
||||
* @return a list of the iterator contents
|
||||
*/
|
||||
|
@ -965,7 +966,7 @@ public class IterableUtils {
|
|||
* by the characters {@code ", "} (a comma followed by a space). Elements are
|
||||
* converted to strings as by {@code String.valueOf(Object)}.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to convert to a string, may be null
|
||||
* @return a string representation of {@code iterable}
|
||||
*/
|
||||
|
@ -981,7 +982,7 @@ public class IterableUtils {
|
|||
* by the characters {@code ", "} (a comma followed by a space). Elements are
|
||||
* converted to strings as by using the provided {@code transformer}.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to convert to a string, may be null
|
||||
* @param transformer the transformer used to get a string representation of an element
|
||||
* @return a string representation of {@code iterable}
|
||||
|
@ -1003,7 +1004,7 @@ public class IterableUtils {
|
|||
* are separated by the provided {@code delimiter}. Elements are converted to
|
||||
* strings as by using the provided {@code transformer}.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterable the iterable to convert to a string, may be null
|
||||
* @param transformer the transformer used to get a string representation of an element
|
||||
* @param delimiter the string to delimit elements
|
||||
|
|
|
@ -68,13 +68,6 @@ import org.w3c.dom.NodeList;
|
|||
/**
|
||||
* Provides static utility methods and decorators for {@link Iterator}
|
||||
* instances. The implementations are provided in the iterators subpackage.
|
||||
* <p>
|
||||
* WARNING: Due to human error certain binary incompatibilities were introduced
|
||||
* between Commons Collections 2.1 and 3.0. The class remained source and test
|
||||
* compatible, so if you can recompile all your classes and dependencies
|
||||
* everything is OK. Those methods which are binary incompatible are marked as
|
||||
* such, together with alternate solutions that are binary compatible
|
||||
* against versions 2.1.1 and 3.1.
|
||||
*
|
||||
* @since 2.1
|
||||
* @version $Id$
|
||||
|
@ -85,18 +78,12 @@ public class IteratorUtils {
|
|||
|
||||
/**
|
||||
* An iterator over no elements.
|
||||
* <p>
|
||||
* WARNING: This constant is binary incompatible with Commons Collections 2.1 and 2.1.1.
|
||||
* Use <code>EmptyIterator.INSTANCE</code> for compatibility with Commons Collections 2.1.1.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final ResettableIterator EMPTY_ITERATOR = EmptyIterator.RESETTABLE_INSTANCE;
|
||||
|
||||
/**
|
||||
* A list iterator over no elements.
|
||||
* <p>
|
||||
* WARNING: This constant is binary incompatible with Commons Collections 2.1 and 2.1.1.
|
||||
* Use <code>EmptyListIterator.INSTANCE</code> for compatibility with Commons Collections 2.1.1.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final ResettableListIterator EMPTY_LIST_ITERATOR = EmptyListIterator.RESETTABLE_INSTANCE;
|
||||
|
@ -145,14 +132,10 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Gets an empty iterator.
|
||||
* <p>
|
||||
* This iterator is a valid iterator object that will iterate over
|
||||
* nothing.
|
||||
* <p>
|
||||
* WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1.
|
||||
* Use <code>EmptyIterator.INSTANCE</code> for compatibility with Commons Collections 2.1.1.
|
||||
* This iterator is a valid iterator object that will iterate over nothing.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @return an iterator over nothing
|
||||
* @param <E> the element type
|
||||
* @return an iterator over nothing
|
||||
*/
|
||||
public static <E> ResettableIterator<E> emptyIterator() {
|
||||
return EmptyIterator.<E>resettableEmptyIterator();
|
||||
|
@ -163,12 +146,9 @@ public class IteratorUtils {
|
|||
* <p>
|
||||
* This iterator is a valid list iterator object that will iterate
|
||||
* over nothing.
|
||||
* <p>
|
||||
* WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1.
|
||||
* Use <code>EmptyListIterator.INSTANCE</code> for compatibility with Commons Collections 2.1.1.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @return a list iterator over nothing
|
||||
* @param <E> the element type
|
||||
* @return a list iterator over nothing
|
||||
*/
|
||||
public static <E> ResettableListIterator<E> emptyListIterator() {
|
||||
return EmptyListIterator.<E>resettableEmptyListIterator();
|
||||
|
@ -180,8 +160,8 @@ public class IteratorUtils {
|
|||
* This iterator is a valid iterator object that will iterate
|
||||
* over nothing.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @return an ordered iterator over nothing
|
||||
* @param <E> the element type
|
||||
* @return an ordered iterator over nothing
|
||||
*/
|
||||
public static <E> OrderedIterator<E> emptyOrderedIterator() {
|
||||
return EmptyOrderedIterator.<E>emptyOrderedIterator();
|
||||
|
@ -193,9 +173,9 @@ public class IteratorUtils {
|
|||
* This iterator is a valid map iterator object that will iterate
|
||||
* over nothing.
|
||||
*
|
||||
* @param <K> the key type
|
||||
* @param <V> the value type
|
||||
* @return a map iterator over nothing
|
||||
* @param <K> the key type
|
||||
* @param <V> the value type
|
||||
* @return a map iterator over nothing
|
||||
*/
|
||||
public static <K, V> MapIterator<K, V> emptyMapIterator() {
|
||||
return EmptyMapIterator.<K, V>emptyMapIterator();
|
||||
|
@ -207,9 +187,9 @@ public class IteratorUtils {
|
|||
* This iterator is a valid map iterator object that will iterate
|
||||
* over nothing.
|
||||
*
|
||||
* @param <K> the key type
|
||||
* @param <V> the value type
|
||||
* @return a map iterator over nothing
|
||||
* @param <K> the key type
|
||||
* @param <V> the value type
|
||||
* @return a map iterator over nothing
|
||||
*/
|
||||
public static <K, V> OrderedMapIterator<K, V> emptyOrderedMapIterator() {
|
||||
return EmptyOrderedMapIterator.<K, V>emptyOrderedMapIterator();
|
||||
|
@ -222,13 +202,10 @@ public class IteratorUtils {
|
|||
* <p>
|
||||
* This iterator is a valid iterator object that will iterate over
|
||||
* the specified object.
|
||||
* <p>
|
||||
* WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1.
|
||||
* Use <code>new SingletonIterator(object)</code> for compatibility.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param object the single object over which to iterate
|
||||
* @return a singleton iterator over the object
|
||||
* @return a singleton iterator over the object
|
||||
*/
|
||||
public static <E> ResettableIterator<E> singletonIterator(final E object) {
|
||||
return new SingletonIterator<E>(object);
|
||||
|
@ -240,9 +217,9 @@ public class IteratorUtils {
|
|||
* This iterator is a valid list iterator object that will iterate over
|
||||
* the specified object.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param object the single object over which to iterate
|
||||
* @return a singleton list iterator over the object
|
||||
* @return a singleton list iterator over the object
|
||||
*/
|
||||
public static <E> ListIterator<E> singletonListIterator(final E object) {
|
||||
return new SingletonListIterator<E>(object);
|
||||
|
@ -252,13 +229,10 @@ public class IteratorUtils {
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Gets an iterator over an object array.
|
||||
* <p>
|
||||
* WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1.
|
||||
* Use <code>new ArrayIterator(array)</code> for compatibility.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @return an iterator over the array
|
||||
* @return an iterator over the array
|
||||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableIterator<E> arrayIterator(final E... array) {
|
||||
|
@ -271,9 +245,9 @@ public class IteratorUtils {
|
|||
* This method will handle primitive arrays as well as object arrays.
|
||||
* The primitives will be wrapped in the appropriate wrapper class.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @return an iterator over the array
|
||||
* @return an iterator over the array
|
||||
* @throws IllegalArgumentException if the array is not an array
|
||||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
|
@ -283,11 +257,8 @@ public class IteratorUtils {
|
|||
|
||||
/**
|
||||
* Gets an iterator over the end part of an object array.
|
||||
* <p>
|
||||
* WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1.
|
||||
* Use <code>new ArrayIterator(array,start)</code> for compatibility.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @param start the index to start iterating at
|
||||
* @return an iterator over part of the array
|
||||
|
@ -305,7 +276,7 @@ public class IteratorUtils {
|
|||
* This method will handle primitive arrays as well as object arrays.
|
||||
* The primitives will be wrapped in the appropriate wrapper class.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @param start the index to start iterating at
|
||||
* @return an iterator over part of the array
|
||||
|
@ -320,11 +291,8 @@ public class IteratorUtils {
|
|||
|
||||
/**
|
||||
* Gets an iterator over part of an object array.
|
||||
* <p>
|
||||
* WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1.
|
||||
* Use <code>new ArrayIterator(array,start,end)</code> for compatibility.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @param start the index to start iterating at
|
||||
* @param end the index to finish iterating at
|
||||
|
@ -343,7 +311,7 @@ public class IteratorUtils {
|
|||
* This method will handle primitive arrays as well as object arrays.
|
||||
* The primitives will be wrapped in the appropriate wrapper class.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @param start the index to start iterating at
|
||||
* @param end the index to finish iterating at
|
||||
|
@ -360,9 +328,9 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Gets a list iterator over an object array.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @return a list iterator over the array
|
||||
* @return a list iterator over the array
|
||||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableListIterator<E> arrayListIterator(final E... array) {
|
||||
|
@ -375,9 +343,9 @@ public class IteratorUtils {
|
|||
* This method will handle primitive arrays as well as object arrays.
|
||||
* The primitives will be wrapped in the appropriate wrapper class.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @return a list iterator over the array
|
||||
* @return a list iterator over the array
|
||||
* @throws IllegalArgumentException if the array is not an array
|
||||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
|
@ -388,7 +356,7 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Gets a list iterator over the end part of an object array.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @param start the index to start iterating at
|
||||
* @return a list iterator over part of the array
|
||||
|
@ -405,7 +373,7 @@ public class IteratorUtils {
|
|||
* This method will handle primitive arrays as well as object arrays.
|
||||
* The primitives will be wrapped in the appropriate wrapper class.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @param start the index to start iterating at
|
||||
* @return a list iterator over part of the array
|
||||
|
@ -420,7 +388,7 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Gets a list iterator over part of an object array.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @param start the index to start iterating at
|
||||
* @param end the index to finish iterating at
|
||||
|
@ -439,7 +407,7 @@ public class IteratorUtils {
|
|||
* This method will handle primitive arrays as well as object arrays.
|
||||
* The primitives will be wrapped in the appropriate wrapper class.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param array the array over which to iterate
|
||||
* @param start the index to start iterating at
|
||||
* @param end the index to finish iterating at
|
||||
|
@ -458,7 +426,7 @@ public class IteratorUtils {
|
|||
* Decorates the specified iterator to return at most the given number
|
||||
* of elements.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to decorate
|
||||
* @param max the maximum number of elements returned by this iterator
|
||||
* @return a new bounded iterator
|
||||
|
@ -477,7 +445,7 @@ public class IteratorUtils {
|
|||
* The iterator is immediately advanced until it reaches the position at
|
||||
* {@code offset}, incurring O(n) time.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to decorate
|
||||
* @param offset the index of the first element of the decorated iterator to return
|
||||
* @param max the maximum number of elements returned by this iterator
|
||||
|
@ -497,7 +465,7 @@ public class IteratorUtils {
|
|||
* will always throw an {@link UnsupportedOperationException} for
|
||||
* the {@link Iterator#remove} method.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to make immutable
|
||||
* @return an immutable version of the iterator
|
||||
*/
|
||||
|
@ -511,7 +479,7 @@ public class IteratorUtils {
|
|||
* the {@link Iterator#remove}, {@link ListIterator#add} and
|
||||
* {@link ListIterator#set} methods.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param listIterator the iterator to make immutable
|
||||
* @return an immutable version of the iterator
|
||||
*/
|
||||
|
@ -524,8 +492,8 @@ public class IteratorUtils {
|
|||
* will always throw an {@link UnsupportedOperationException} for
|
||||
* the {@link Iterator#remove}, {@link MapIterator#setValue(Object)} methods.
|
||||
*
|
||||
* @param <K> the key type
|
||||
* @param <V> the value type
|
||||
* @param <K> the key type
|
||||
* @param <V> the value type
|
||||
* @param mapIterator the iterator to make immutable
|
||||
* @return an immutable version of the iterator
|
||||
*/
|
||||
|
@ -540,7 +508,7 @@ public class IteratorUtils {
|
|||
* Gets an iterator that iterates through two {@link Iterator}s
|
||||
* one after another.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator1 the first iterator to use, not null
|
||||
* @param iterator2 the second iterator to use, not null
|
||||
* @return a combination iterator over the iterators
|
||||
|
@ -557,7 +525,7 @@ public class IteratorUtils {
|
|||
* Gets an iterator that iterates through an array of {@link Iterator}s
|
||||
* one after another.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterators the iterators to use, not null or empty or contain nulls
|
||||
* @return a combination iterator over the iterators
|
||||
* @throws NullPointerException if iterators array is null or contains a null
|
||||
|
@ -570,7 +538,7 @@ public class IteratorUtils {
|
|||
* Gets an iterator that iterates through a collections of {@link Iterator}s
|
||||
* one after another.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterators the iterators to use, not null or empty or contain nulls
|
||||
* @return a combination iterator over the iterators
|
||||
* @throws NullPointerException if iterators collection is null or contains a null
|
||||
|
@ -592,7 +560,7 @@ public class IteratorUtils {
|
|||
* <p>
|
||||
* The comparator is optional. If null is specified then natural order is used.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param comparator the comparator to use, may be null for natural order
|
||||
* @param iterator1 the first iterators to use, not null
|
||||
* @param iterator2 the first iterators to use, not null
|
||||
|
@ -617,7 +585,7 @@ public class IteratorUtils {
|
|||
* <p>
|
||||
* The comparator is optional. If null is specified then natural order is used.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param comparator the comparator to use, may be null for natural order
|
||||
* @param iterators the iterators to use, not null or empty or contain nulls
|
||||
* @return a combination iterator over the iterators
|
||||
|
@ -640,7 +608,7 @@ public class IteratorUtils {
|
|||
* <p>
|
||||
* The comparator is optional. If null is specified then natural order is used.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param comparator the comparator to use, may be null for natural order
|
||||
* @param iterators the iterators to use, not null or empty or contain nulls
|
||||
* @return a combination iterator over the iterators
|
||||
|
@ -704,7 +672,7 @@ public class IteratorUtils {
|
|||
* Under many circumstances, linking Iterators together in this manner is
|
||||
* more efficient (and convenient) than using nested for loops to extract a list.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param root the root object to start iterating from, null results in an empty iterator
|
||||
* @param transformer the transformer to use, see above, null uses no effect transformer
|
||||
* @return a new object graph iterator
|
||||
|
@ -723,8 +691,8 @@ public class IteratorUtils {
|
|||
* The transformation occurs during the next() method and the underlying
|
||||
* iterator is unaffected by the transformation.
|
||||
*
|
||||
* @param <I> the input type
|
||||
* @param <O> the output type
|
||||
* @param <I> the input type
|
||||
* @param <O> the output type
|
||||
* @param iterator the iterator to use, not null
|
||||
* @param transform the transform to use, not null
|
||||
* @return a new transforming iterator
|
||||
|
@ -750,7 +718,7 @@ public class IteratorUtils {
|
|||
* The returned iterator will only return objects that match the specified
|
||||
* filtering predicate.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, not null
|
||||
* @param predicate the predicate to use as a filter, not null
|
||||
* @return a new filtered iterator
|
||||
|
@ -773,7 +741,7 @@ public class IteratorUtils {
|
|||
* The returned iterator will only return objects that match the specified
|
||||
* filtering predicate.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param listIterator the list iterator to use, not null
|
||||
* @param predicate the predicate to use as a filter, not null
|
||||
* @return a new filtered iterator
|
||||
|
@ -800,7 +768,7 @@ public class IteratorUtils {
|
|||
* enough times to empty the collection, or if the collection is empty
|
||||
* to start with.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param coll the collection to iterate over, not null
|
||||
* @return a new looping iterator
|
||||
* @throws NullPointerException if the collection is null
|
||||
|
@ -818,7 +786,7 @@ public class IteratorUtils {
|
|||
* The iterator will only stop looping if the remove method is called
|
||||
* enough times to empty the list, or if the list is empty to start with.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param list the list to iterate over, not null
|
||||
* @return a new looping iterator
|
||||
* @throws NullPointerException if the list is null
|
||||
|
@ -837,7 +805,7 @@ public class IteratorUtils {
|
|||
* Gets an {@link Iterator} that wraps the specified {@link NodeList}.
|
||||
* The returned {@link Iterator} can be used for a single iteration.
|
||||
*
|
||||
* @param nodeList the node list to use, not null
|
||||
* @param nodeList the node list to use, may not be null
|
||||
* @return a new, single use {@link Iterator}
|
||||
* @throws NullPointerException if nodeList is null
|
||||
* @since 4.0
|
||||
|
@ -861,7 +829,7 @@ public class IteratorUtils {
|
|||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param node the node to use, not null
|
||||
* @param node the node to use, may not be null
|
||||
* @return a new, single use {@link Iterator}
|
||||
* @throws NullPointerException if node is null
|
||||
* @since 4.0
|
||||
|
@ -879,7 +847,7 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Gets an iterator that supports one-element lookahead.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to decorate, not null
|
||||
* @return a peeking iterator
|
||||
* @throws NullPointerException if the iterator is null
|
||||
|
@ -895,7 +863,7 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Gets an iterator that supports pushback of elements.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to decorate, not null
|
||||
* @return a pushback iterator
|
||||
* @throws NullPointerException if the iterator is null
|
||||
|
@ -910,11 +878,12 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Decorates the specified iterator to skip the first N elements.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to decorate
|
||||
* @param offset the first number of elements to skip
|
||||
* @return a new skipping iterator
|
||||
* @throws IllegalArgumentException if the iterator is null or offset is negative
|
||||
* @throws NullPointerException if the iterator is null
|
||||
* @throws IllegalArgumentException if offset is negative
|
||||
* @since 4.1
|
||||
*/
|
||||
public static <E> SkippingIterator<E> skippingIterator(final Iterator<E> iterator, long offset) {
|
||||
|
@ -926,11 +895,11 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Returns an iterator that interleaves elements from the decorated iterators.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param a the first iterator to interleave
|
||||
* @param b the second iterator to interleave
|
||||
* @return an iterator, interleaving the decorated iterators
|
||||
* @throws IllegalArgumentException if any iterator is null
|
||||
* @throws NullPointerException if any iterator is null
|
||||
* @since 4.1
|
||||
*/
|
||||
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E> a,
|
||||
|
@ -941,12 +910,12 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Returns an iterator that interleaves elements from the decorated iterators.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param a the first iterator to interleave
|
||||
* @param b the second iterator to interleave
|
||||
* @param c the third iterator to interleave
|
||||
* @return an iterator, interleaving the decorated iterators
|
||||
* @throws IllegalArgumentException if any iterator is null
|
||||
* @throws NullPointerException if any iterator is null
|
||||
* @since 4.1
|
||||
*/
|
||||
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E> a,
|
||||
|
@ -958,10 +927,10 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Returns an iterator that interleaves elements from the decorated iterators.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterators the array of iterators to interleave
|
||||
* @return an iterator, interleaving the decorated iterators
|
||||
* @throws IllegalArgumentException if any iterator is null
|
||||
* @throws NullPointerException if any iterator is null
|
||||
* @since 4.1
|
||||
*/
|
||||
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E>... iterators) {
|
||||
|
@ -973,9 +942,10 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Gets an iterator that provides an iterator view of the given enumeration.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param enumeration the enumeration to use
|
||||
* @param <E> the element type
|
||||
* @param enumeration the enumeration to use, may not be null
|
||||
* @return a new iterator
|
||||
* @throws NullPointerException if enumeration is null
|
||||
*/
|
||||
public static <E> Iterator<E> asIterator(final Enumeration<? extends E> enumeration) {
|
||||
if (enumeration == null) {
|
||||
|
@ -988,10 +958,11 @@ public class IteratorUtils {
|
|||
* Gets an iterator that provides an iterator view of the given enumeration
|
||||
* that will remove elements from the specified collection.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param enumeration the enumeration to use
|
||||
* @param removeCollection the collection to remove elements from
|
||||
* @param <E> the element type
|
||||
* @param enumeration the enumeration to use, may not be null
|
||||
* @param removeCollection the collection to remove elements from, may not be null
|
||||
* @return a new iterator
|
||||
* @throws NullPointerException if enumeration or removeCollection is null
|
||||
*/
|
||||
public static <E> Iterator<E> asIterator(final Enumeration<? extends E> enumeration,
|
||||
final Collection<? super E> removeCollection) {
|
||||
|
@ -1007,8 +978,8 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Gets an enumeration that wraps an iterator.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, not null
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, may not be null
|
||||
* @return a new enumeration
|
||||
* @throws NullPointerException if iterator is null
|
||||
*/
|
||||
|
@ -1023,8 +994,8 @@ public class IteratorUtils {
|
|||
* Gets an {@link Iterable} that wraps an iterator. The returned {@link Iterable} can be
|
||||
* used for a single iteration.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, not null
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, may not be null
|
||||
* @return a new, single use {@link Iterable}
|
||||
* @throws NullPointerException if iterator is null
|
||||
*/
|
||||
|
@ -1039,8 +1010,8 @@ public class IteratorUtils {
|
|||
* Gets an iterable that wraps an iterator. The returned iterable can be
|
||||
* used for multiple iterations.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, not null
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, may not be null
|
||||
* @return a new, multiple use iterable
|
||||
* @throws NullPointerException if iterator is null
|
||||
*/
|
||||
|
@ -1057,8 +1028,8 @@ public class IteratorUtils {
|
|||
* As the wrapped Iterator is traversed, a LinkedList of its values is
|
||||
* cached, permitting all required operations of ListIterator.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, not null
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, may not be null
|
||||
* @return a new iterator
|
||||
* @throws NullPointerException if iterator parameter is null
|
||||
*/
|
||||
|
@ -1093,7 +1064,7 @@ public class IteratorUtils {
|
|||
* As the wrapped Iterator is traversed, an ArrayList of its values is
|
||||
* created. At the end, this is converted to an array.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, not null
|
||||
* @param arrayClass the class of array to create
|
||||
* @return an array of the iterator contents
|
||||
|
@ -1119,7 +1090,7 @@ public class IteratorUtils {
|
|||
* As the wrapped Iterator is traversed, an ArrayList of its values is
|
||||
* created. At the end, the list is returned.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, not null
|
||||
* @return a list of the iterator contents
|
||||
* @throws NullPointerException if iterator parameter is null
|
||||
|
@ -1134,7 +1105,7 @@ public class IteratorUtils {
|
|||
* As the wrapped Iterator is traversed, an ArrayList of its values is
|
||||
* created. At the end, the list is returned.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, not null
|
||||
* @param estimatedSize the initial size of the ArrayList
|
||||
* @return a list of the iterator contents
|
||||
|
@ -1232,7 +1203,7 @@ public class IteratorUtils {
|
|||
/**
|
||||
* Applies the closure to each element of the provided iterator.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to use, may be null
|
||||
* @param closure the closure to apply to each element, may not be null
|
||||
* @throws NullPointerException if closure is null
|
||||
|
@ -1256,8 +1227,7 @@ public class IteratorUtils {
|
|||
* <p>
|
||||
* If the input iterator is null no change is made.
|
||||
*
|
||||
* @param <E> the type of object the {@link Iterator} contains
|
||||
* @param <C> the closure type
|
||||
* @param <E> the type of object the {@link Iterator} contains
|
||||
* @param iterator the iterator to get the input from, may be null
|
||||
* @param closure the closure to perform, may not be null
|
||||
* @return the last element in the iterator, or null if iterator is null or empty
|
||||
|
@ -1286,7 +1256,7 @@ public class IteratorUtils {
|
|||
* <p>
|
||||
* A <code>null</code> or empty iterator returns null.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to search, may be null
|
||||
* @param predicate the predicate to use, may not be null
|
||||
* @return the first element of the iterator which matches the predicate or null if none could be found
|
||||
|
@ -1314,7 +1284,7 @@ public class IteratorUtils {
|
|||
* <p>
|
||||
* A <code>null</code> or empty iterator returns false.
|
||||
*
|
||||
* @param <E> the type of object the {@link Iterator} contains
|
||||
* @param <E> the type of object the {@link Iterator} contains
|
||||
* @param iterator the {@link Iterator} to use, may be null
|
||||
* @param predicate the predicate to use, may not be null
|
||||
* @return true if any element of the collection matches the predicate, false otherwise
|
||||
|
@ -1342,7 +1312,7 @@ public class IteratorUtils {
|
|||
* <p>
|
||||
* A <code>null</code> or empty iterator returns true.
|
||||
*
|
||||
* @param <E> the type of object the {@link Iterator} contains
|
||||
* @param <E> the type of object the {@link Iterator} contains
|
||||
* @param iterator the {@link Iterator} to use, may be null
|
||||
* @param predicate the predicate to use, may not be null
|
||||
* @return true if every element of the collection matches the predicate or if the
|
||||
|
@ -1384,7 +1354,7 @@ public class IteratorUtils {
|
|||
* <p>
|
||||
* A <code>null</code> or empty iterator returns false.
|
||||
*
|
||||
* @param <E> the type of object the {@link Iterator} contains
|
||||
* @param <E> the type of object the {@link Iterator} contains
|
||||
* @param iterator the iterator to check, may be null
|
||||
* @param object the object to check
|
||||
* @return true if the object is contained in the iterator, false otherwise
|
||||
|
@ -1401,12 +1371,11 @@ public class IteratorUtils {
|
|||
* The Iterator is advanced to <code>index</code> (or to the end, if
|
||||
* <code>index</code> exceeds the number of entries) as a side effect of this method.
|
||||
*
|
||||
* @param <E> the type of object in the {@link Iterator}
|
||||
* @param <E> the type of object in the {@link Iterator}
|
||||
* @param iterator the iterator to get a value from
|
||||
* @param index the index to get
|
||||
* @return the object at the specified index
|
||||
* @throws IndexOutOfBoundsException if the index is invalid
|
||||
* @throws IllegalArgumentException if the object type is invalid
|
||||
* @since 4.1
|
||||
*/
|
||||
public static <E> E get(final Iterator<E> iterator, final int index) {
|
||||
|
@ -1450,8 +1419,8 @@ public class IteratorUtils {
|
|||
* by the characters {@code ", "} (a comma followed by a space). Elements are
|
||||
* converted to strings as by {@code String.valueOf(Object)}.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to convert to a string
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to convert to a string, may be null
|
||||
* @return a string representation of {@code iterator}
|
||||
* @since 4.1
|
||||
*/
|
||||
|
@ -1469,7 +1438,7 @@ public class IteratorUtils {
|
|||
* by the characters {@code ", "} (a comma followed by a space). Elements are
|
||||
* converted to strings as by using the provided {@code transformer}.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to convert to a string, may be null
|
||||
* @param transformer the transformer used to get a string representation of an element
|
||||
* @return a string representation of {@code iterator}
|
||||
|
@ -1490,7 +1459,7 @@ public class IteratorUtils {
|
|||
* are separated by the provided {@code delimiter}. Elements are converted to
|
||||
* strings as by using the provided {@code transformer}.
|
||||
*
|
||||
* @param <E> the element type
|
||||
* @param <E> the element type
|
||||
* @param iterator the iterator to convert to a string, may be null
|
||||
* @param transformer the transformer used to get a string representation of an element
|
||||
* @param delimiter the string to delimit elements
|
||||
|
|
|
@ -50,7 +50,7 @@ public interface MultiSet<E> extends Collection<E> {
|
|||
* <p>
|
||||
* If the provided count is zero, the object will be removed from the
|
||||
* {@link #uniqueSet()}.
|
||||
*
|
||||
*
|
||||
* @param object the object to update
|
||||
* @param count the number of occurrences of the object
|
||||
* @return the number of occurrences of the object before this operation, zero
|
||||
|
|
|
@ -161,6 +161,7 @@ public interface MultiValuedMap<K, V> {
|
|||
* while the operation is in progress.
|
||||
*
|
||||
* @param map mappings to be stored in this map, may not be null
|
||||
* @return true if the map changed as a result of this operation
|
||||
* @throws UnsupportedOperationException if the {@code putAll} operation is
|
||||
* not supported by this map
|
||||
* @throws NullPointerException if the specified map is null, or if this map
|
||||
|
@ -183,6 +184,7 @@ public interface MultiValuedMap<K, V> {
|
|||
* while the operation is in progress.
|
||||
*
|
||||
* @param map mappings to be stored in this map, may not be null
|
||||
* @return true if the map changed as a result of this operation
|
||||
* @throws UnsupportedOperationException if the {@code putAll} operation is
|
||||
* not supported by this map
|
||||
* @throws NullPointerException if the specified map is null, or if this map
|
||||
|
|
|
@ -23,13 +23,11 @@ import java.io.Serializable;
|
|||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.commons.collections4.Bag;
|
||||
|
||||
/**
|
||||
* Implements {@link Bag}, using a {@link HashMap} to provide the
|
||||
* Implements {@code Bag}, using a {@link HashMap} to provide the
|
||||
* data storage. This is the standard implementation of a bag.
|
||||
* <p>
|
||||
* A {@link Bag} stores each object in the collection together with a
|
||||
* A {@code Bag} stores each object in the collection together with a
|
||||
* count of occurrences. Extra methods on the interface allow multiple copies
|
||||
* of an object to be added or removed at once. It is important to read the
|
||||
* interface javadoc carefully as several methods violate the
|
||||
|
|
|
@ -44,7 +44,8 @@ public class SkippingIterator<E> extends AbstractIteratorDecorator<E> {
|
|||
*
|
||||
* @param iterator the iterator to be decorated
|
||||
* @param offset the index of the first element of the decorated iterator to return
|
||||
* @throws IllegalArgumentException if iterator is null, or offset is negative
|
||||
* @throws NullPointerException if iterator is null
|
||||
* @throws IllegalArgumentException if offset is negative
|
||||
*/
|
||||
public SkippingIterator(final Iterator<E> iterator, final long offset) {
|
||||
super(iterator);
|
||||
|
|
|
@ -343,7 +343,7 @@ public abstract class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K,
|
|||
|
||||
if (values instanceof Collection<?>) {
|
||||
Collection<? extends V> valueCollection = (Collection<? extends V>) values;
|
||||
return !valueCollection.isEmpty() && get(key).addAll(valueCollection);
|
||||
return !valueCollection.isEmpty() && get(key).addAll(valueCollection);
|
||||
} else {
|
||||
Iterator<? extends V> it = values.iterator();
|
||||
return it.hasNext() && CollectionUtils.addAll(get(key), it);
|
||||
|
|
|
@ -660,8 +660,7 @@ public abstract class AbstractMapMultiSet<E> extends AbstractCollection<E> imple
|
|||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param entry the entry to decorate
|
||||
* @param parent the parent map
|
||||
* @param parentEntry the entry to decorate
|
||||
*/
|
||||
protected MultiSetEntry(final Map.Entry<E, MutableInteger> parentEntry) {
|
||||
this.parentEntry = parentEntry;
|
||||
|
@ -681,7 +680,7 @@ public abstract class AbstractMapMultiSet<E> extends AbstractCollection<E> imple
|
|||
public String toString() {
|
||||
return String.format("%s:%d", getElement(), getCount());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -103,5 +103,5 @@ public abstract class AbstractMultiSetDecorator<E>
|
|||
public Set<Entry<E>> entrySet() {
|
||||
return decorated().entrySet();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,13 +23,11 @@ import java.io.Serializable;
|
|||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.commons.collections4.MultiSet;
|
||||
|
||||
/**
|
||||
* Implements {@link MultiSet}, using a {@link HashMap} to provide the
|
||||
* Implements {@code MultiSet}, using a {@link HashMap} to provide the
|
||||
* data storage. This is the standard implementation of a multiset.
|
||||
* <p>
|
||||
* A {@link MultiSet} stores each object in the collection together with a
|
||||
* A {@code MultiSet} stores each object in the collection together with a
|
||||
* count of occurrences. Extra methods on the interface allow multiple copies
|
||||
* of an object to be added or removed at once.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue