diff --git a/src/main/java/org/apache/commons/collections4/FluentIterable.java b/src/main/java/org/apache/commons/collections4/FluentIterable.java index d3b07b88a..c985d7e57 100644 --- a/src/main/java/org/apache/commons/collections4/FluentIterable.java +++ b/src/main/java/org/apache/commons/collections4/FluentIterable.java @@ -91,7 +91,7 @@ public class FluentIterable implements Iterable { * @throws NullPointerException if iterable is null */ public static FluentIterable of(final Iterable iterable) { - IterableUtils.checkNotNull(iterable); + Objects.requireNonNull(iterable, "iterable"); if (iterable instanceof FluentIterable) { return (FluentIterable) iterable; } diff --git a/src/main/java/org/apache/commons/collections4/IterableUtils.java b/src/main/java/org/apache/commons/collections4/IterableUtils.java index 4b3adadca..7066028ff 100644 --- a/src/main/java/org/apache/commons/collections4/IterableUtils.java +++ b/src/main/java/org/apache/commons/collections4/IterableUtils.java @@ -93,7 +93,7 @@ public class IterableUtils { * @throws NullPointerException if iterable is null */ public static Iterable boundedIterable(final Iterable iterable, final long maxSize) { - checkNotNull(iterable); + Objects.requireNonNull(iterable, "iterable"); if (maxSize < 0) { throw new IllegalArgumentException("MaxSize parameter must not be negative."); } @@ -219,16 +219,6 @@ public class IterableUtils { return chainedIterable(new Iterable[] {a, b, c, d}); } - /** - * Fail-fast check for null arguments. - * - * @param iterable the iterable to check - * @throws NullPointerException if iterable is null - */ - static void checkNotNull(final Iterable iterable) { - Objects.requireNonNull(iterable, "iterable"); - } - /** * Fail-fast check for null arguments. * @@ -238,7 +228,7 @@ public class IterableUtils { static void checkNotNull(final Iterable... iterables) { Objects.requireNonNull(iterables, "iterables"); for (final Iterable iterable : iterables) { - checkNotNull(iterable); + Objects.requireNonNull(iterable, "iterable"); } } @@ -409,7 +399,7 @@ public class IterableUtils { */ public static Iterable filteredIterable(final Iterable iterable, final Predicate predicate) { - checkNotNull(iterable); + Objects.requireNonNull(iterable, "iterable"); Objects.requireNonNull(predicate, "predicate"); return new FluentIterable() { @Override @@ -572,7 +562,7 @@ public class IterableUtils { * @throws NullPointerException if iterable is null */ public static Iterable loopingIterable(final Iterable iterable) { - checkNotNull(iterable); + Objects.requireNonNull(iterable, "iterable"); return new FluentIterable() { @Override public Iterator iterator() { @@ -818,7 +808,7 @@ public class IterableUtils { * @see ReverseListIterator */ public static Iterable reversedIterable(final Iterable iterable) { - checkNotNull(iterable); + Objects.requireNonNull(iterable, "iterable"); return new FluentIterable() { @Override public Iterator iterator() { @@ -864,7 +854,7 @@ public class IterableUtils { * @throws NullPointerException if iterable is null */ public static Iterable skippingIterable(final Iterable iterable, final long elementsToSkip) { - checkNotNull(iterable); + Objects.requireNonNull(iterable, "iterable"); if (elementsToSkip < 0) { throw new IllegalArgumentException("ElementsToSkip parameter must not be negative."); } @@ -970,7 +960,7 @@ public class IterableUtils { */ public static Iterable transformedIterable(final Iterable iterable, final Transformer transformer) { - checkNotNull(iterable); + Objects.requireNonNull(iterable, "iterable"); Objects.requireNonNull(transformer, "transformer"); return new FluentIterable() { @Override @@ -994,7 +984,7 @@ public class IterableUtils { * @throws NullPointerException if iterable is null */ public static Iterable uniqueIterable(final Iterable iterable) { - checkNotNull(iterable); + Objects.requireNonNull(iterable, "iterable"); return new FluentIterable() { @Override public Iterator iterator() { @@ -1015,7 +1005,7 @@ public class IterableUtils { * @throws NullPointerException if iterable is null */ public static Iterable unmodifiableIterable(final Iterable iterable) { - checkNotNull(iterable); + Objects.requireNonNull(iterable, "iterable"); if (iterable instanceof UnmodifiableIterable) { return iterable; } @@ -1042,8 +1032,8 @@ public class IterableUtils { */ public static Iterable zippingIterable(final Iterable a, final Iterable b) { - checkNotNull(a); - checkNotNull(b); + Objects.requireNonNull(a, "iterable"); + Objects.requireNonNull(b, "iterable"); return new FluentIterable() { @Override public Iterator iterator() { @@ -1069,7 +1059,7 @@ public class IterableUtils { * @throws NullPointerException if either of the provided iterables is null */ public static Iterable zippingIterable(final Iterable first, final Iterable... others) { - checkNotNull(first); + Objects.requireNonNull(first, "iterable"); checkNotNull(others); return new FluentIterable() { @Override