Use varargs instead of arrays as input argument where applicable.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1479347 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9687cf07f3
commit
94cfd56bd9
|
@ -64,24 +64,6 @@ public class ComparatorUtils {
|
|||
return NATURAL_COMPARATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a comparator that compares using two {@link Comparator}s.
|
||||
* <p>
|
||||
* The second comparator is used if the first comparator returns equal.
|
||||
*
|
||||
* @param <E> the object type to compare
|
||||
* @param comparator1 the first comparator to use, not null
|
||||
* @param comparator2 the first comparator to use, not null
|
||||
* @return a {@link ComparatorChain} formed from the two comparators
|
||||
* @throws NullPointerException if either comparator is null
|
||||
* @see ComparatorChain
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E extends Comparable<? super E>> Comparator<E> chainedComparator(final Comparator<E> comparator1,
|
||||
final Comparator<E> comparator2) {
|
||||
return chainedComparator(new Comparator[] {comparator1, comparator2});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a comparator that compares using an array of {@link Comparator}s, applied
|
||||
* in sequence until one returns not equal or the array is exhausted.
|
||||
|
@ -93,7 +75,7 @@ public class ComparatorUtils {
|
|||
* @see ComparatorChain
|
||||
*/
|
||||
public static <E extends Comparable<? super E>> Comparator<E> chainedComparator(
|
||||
final Comparator<E>[] comparators) {
|
||||
final Comparator<E>... comparators) {
|
||||
|
||||
final ComparatorChain<E> chain = new ComparatorChain<E>();
|
||||
for (final Comparator<E> comparator : comparators) {
|
||||
|
|
|
@ -235,7 +235,7 @@ public class IteratorUtils {
|
|||
* @return an iterator over the array
|
||||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableIterator<E> arrayIterator(final E[] array) {
|
||||
public static <E> ResettableIterator<E> arrayIterator(final E... array) {
|
||||
return new ObjectArrayIterator<E>(array);
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ public class IteratorUtils {
|
|||
* @return a list iterator over the array
|
||||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableListIterator<E> arrayListIterator(final E[] array) {
|
||||
public static <E> ResettableListIterator<E> arrayListIterator(final E... array) {
|
||||
return new ObjectArrayListIterator<E>(array);
|
||||
}
|
||||
|
||||
|
@ -471,21 +471,6 @@ public class IteratorUtils {
|
|||
|
||||
// Chained
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Gets an iterator that iterates through two {@link Iterator}s
|
||||
* one after another.
|
||||
*
|
||||
* @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
|
||||
* @throws NullPointerException if either iterator is null
|
||||
*/
|
||||
public static <E> Iterator<E> chainedIterator(final Iterator<? extends E> iterator1,
|
||||
final Iterator<? extends E> iterator2) {
|
||||
return new IteratorChain<E>(iterator1, iterator2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an iterator that iterates through an array of {@link Iterator}s
|
||||
* one after another.
|
||||
|
@ -495,7 +480,7 @@ public class IteratorUtils {
|
|||
* @return a combination iterator over the iterators
|
||||
* @throws NullPointerException if iterators array is null or contains a null
|
||||
*/
|
||||
public static <E> Iterator<E> chainedIterator(final Iterator<? extends E>[] iterators) {
|
||||
public static <E> Iterator<E> chainedIterator(final Iterator<? extends E>... iterators) {
|
||||
return new IteratorChain<E>(iterators);
|
||||
}
|
||||
|
||||
|
@ -555,7 +540,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if iterators array is null or contains a null value
|
||||
*/
|
||||
public static <E> Iterator<E> collatedIterator(final Comparator<? super E> comparator,
|
||||
final Iterator<? extends E>[] iterators) {
|
||||
final Iterator<? extends E>... iterators) {
|
||||
return new CollatingIterator<E>(comparator, iterators);
|
||||
}
|
||||
|
||||
|
|
|
@ -1140,7 +1140,7 @@ public class MapUtils {
|
|||
* @since 3.2
|
||||
*/
|
||||
@SuppressWarnings("unchecked") // As per Javadoc throws CCE for invalid array contents
|
||||
public static <K, V> Map<K, V> putAll(final Map<K, V> map, final Object[] array) {
|
||||
public static <K, V> Map<K, V> putAll(final Map<K, V> map, final Object... array) {
|
||||
map.size(); // force NPE
|
||||
if (array == null || array.length == 0) {
|
||||
return map;
|
||||
|
|
|
@ -179,24 +179,6 @@ public class TransformerUtils {
|
|||
return FactoryTransformer.factoryTransformer(factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Transformer that calls two transformers, passing the result of
|
||||
* the first into the second.
|
||||
*
|
||||
* @param <T> the input/output type
|
||||
* @param transformer1 the first transformer
|
||||
* @param transformer2 the second transformer
|
||||
* @return the transformer
|
||||
* @throws IllegalArgumentException if either transformer is null
|
||||
* @see org.apache.commons.collections4.functors.ChainedTransformer
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Transformer<T, T> chainedTransformer(
|
||||
final Transformer<? super T, ? extends T> transformer1,
|
||||
final Transformer<? super T, ? extends T> transformer2) {
|
||||
return ChainedTransformer.<T> chainedTransformer(transformer1, transformer2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Transformer that calls each transformer in turn, passing the
|
||||
* result into the next transformer.
|
||||
|
@ -207,7 +189,8 @@ public class TransformerUtils {
|
|||
* @throws IllegalArgumentException if the transformers array or any of the transformers is null
|
||||
* @see org.apache.commons.collections4.functors.ChainedTransformer
|
||||
*/
|
||||
public static <T> Transformer<T, T> chainedTransformer(final Transformer<? super T, ? extends T>[] transformers) {
|
||||
public static <T> Transformer<T, T> chainedTransformer(
|
||||
final Transformer<? super T, ? extends T>... transformers) {
|
||||
return ChainedTransformer.chainedTransformer(transformers);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue