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:
Thomas Neidhart 2015-06-16 20:13:13 +00:00
parent 68b92abce7
commit 9f363c0dae
10 changed files with 139 additions and 171 deletions

View File

@ -533,7 +533,8 @@ public class IterableUtils {
* input iterator supports it.
*
* @param <E> the element type
* @param iterables the array of iterables to interleave, may not be null
* @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
*/
@ -588,7 +589,6 @@ public class IterableUtils {
* 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 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
@ -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

View File

@ -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,11 +132,7 @@ 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
@ -163,9 +146,6 @@ 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
@ -222,9 +202,6 @@ 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 object the single object over which to iterate
@ -252,9 +229,6 @@ 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 array the array over which to iterate
@ -283,9 +257,6 @@ 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 array the array over which to iterate
@ -320,9 +291,6 @@ 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 array the array over which to iterate
@ -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
@ -914,7 +882,8 @@ public class IteratorUtils {
* @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) {
@ -930,7 +899,7 @@ public class IteratorUtils {
* @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,
@ -946,7 +915,7 @@ public class IteratorUtils {
* @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,
@ -961,7 +930,7 @@ public class IteratorUtils {
* @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) {
@ -974,8 +943,9 @@ 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 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) {
@ -989,9 +959,10 @@ public class IteratorUtils {
* 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 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) {
@ -1008,7 +979,7 @@ public class IteratorUtils {
* Gets an enumeration that wraps an iterator.
*
* @param <E> the element type
* @param iterator the iterator to use, not null
* @param iterator the iterator to use, may not be null
* @return a new enumeration
* @throws NullPointerException if iterator is null
*/
@ -1024,7 +995,7 @@ public class IteratorUtils {
* used for a single iteration.
*
* @param <E> the element type
* @param iterator the iterator to use, not null
* @param iterator the iterator to use, may not be null
* @return a new, single use {@link Iterable}
* @throws NullPointerException if iterator is null
*/
@ -1040,7 +1011,7 @@ public class IteratorUtils {
* used for multiple iterations.
*
* @param <E> the element type
* @param iterator the iterator to use, not null
* @param iterator the iterator to use, may not be null
* @return a new, multiple use iterable
* @throws NullPointerException if iterator is null
*/
@ -1058,7 +1029,7 @@ public class IteratorUtils {
* cached, permitting all required operations of ListIterator.
*
* @param <E> the element type
* @param iterator the iterator to use, not null
* @param iterator the iterator to use, may not be null
* @return a new iterator
* @throws NullPointerException if iterator parameter is null
*/
@ -1257,7 +1228,6 @@ public class IteratorUtils {
* 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 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
@ -1406,7 +1376,6 @@ public class IteratorUtils {
* @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) {
@ -1451,7 +1420,7 @@ public class IteratorUtils {
* converted to strings as by {@code String.valueOf(Object)}.
*
* @param <E> the element type
* @param iterator the iterator to convert to a string
* @param iterator the iterator to convert to a string, may be null
* @return a string representation of {@code iterator}
* @since 4.1
*/

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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.
*