Skip to content

Commit 3344bf3

Browse files
committed
Internale refactoring
1 parent 293fcb1 commit 3344bf3

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/main/java/org/apache/commons/collections4/functors/FunctorUtils.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
*/
3131
final class FunctorUtils {
3232

33+
private static <T> T[] clone(final T... array) {
34+
return array != null ? array.clone() : null;
35+
}
36+
3337
/**
3438
* A very simple method that coerces Predicate<? super T> to Predicate<T>.
3539
* Due to the {@link Predicate#test(T)} method, Predicate<? super T> is
@@ -75,10 +79,7 @@ static <R extends java.util.function.Predicate<T>, P extends java.util.function.
7579
*/
7680
@SuppressWarnings("unchecked")
7781
static <T extends Consumer<?>> T[] copy(final T... consumers) {
78-
if (consumers == null) {
79-
return null;
80-
}
81-
return consumers.clone();
82+
return clone(consumers);
8283
}
8384

8485
/**
@@ -91,10 +92,7 @@ static <T extends Consumer<?>> T[] copy(final T... consumers) {
9192
*/
9293
@SuppressWarnings("unchecked")
9394
static <T extends java.util.function.Predicate<?>> T[] copy(final T... predicates) {
94-
if (predicates == null) {
95-
return null;
96-
}
97-
return predicates.clone();
95+
return clone(predicates);
9896
}
9997

10098
/**
@@ -105,10 +103,7 @@ static <T extends java.util.function.Predicate<?>> T[] copy(final T... predicate
105103
*/
106104
@SuppressWarnings("unchecked")
107105
static <T extends Function<?, ?>> T[] copy(final T... transformers) {
108-
if (transformers == null) {
109-
return null;
110-
}
111-
return transformers.clone();
106+
return clone(transformers);
112107
}
113108

114109
/**

0 commit comments

Comments
 (0)