diff --git a/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java b/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java index 402fda89f..b23d9109a 100644 --- a/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java @@ -64,17 +64,6 @@ public final class AndPredicate extends AbstractPredicate implements Predi iPredicate2 = predicate2; } - /** - * Evaluates the predicate returning true if both predicates return true. - * - * @param object the input object - * @return true if both decorated predicates return true - */ - @Override - public boolean test(final T object) { - return iPredicate1.test(object) && iPredicate2.test(object); - } - /** * Gets the two predicates being decorated as an array. * @@ -87,4 +76,15 @@ public final class AndPredicate extends AbstractPredicate implements Predi return new Predicate[] {iPredicate1, iPredicate2}; } + /** + * Evaluates the predicate returning true if both predicates return true. + * + * @param object the input object + * @return true if both decorated predicates return true + */ + @Override + public boolean test(final T object) { + return iPredicate1.test(object) && iPredicate2.test(object); + } + } diff --git a/src/main/java/org/apache/commons/collections4/functors/EqualPredicate.java b/src/main/java/org/apache/commons/collections4/functors/EqualPredicate.java index 827fde15b..2d1a835bd 100644 --- a/src/main/java/org/apache/commons/collections4/functors/EqualPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/EqualPredicate.java @@ -94,6 +94,16 @@ public final class EqualPredicate extends AbstractPredicate implements Ser this.equator = equator; } + /** + * Gets the value. + * + * @return the value + * @since 3.1 + */ + public Object getValue() { + return iValue; + } + /** * Evaluates the predicate returning true if the input equals the stored value. * @@ -108,14 +118,4 @@ public final class EqualPredicate extends AbstractPredicate implements Ser return iValue.equals(object); } - /** - * Gets the value. - * - * @return the value - * @since 3.1 - */ - public Object getValue() { - return iValue; - } - } diff --git a/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java b/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java index e58ec9af5..e0c4e459b 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java @@ -53,6 +53,15 @@ public final class ExceptionPredicate extends AbstractPredicate implements private ExceptionPredicate() { } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ + private Object readResolve() { + return INSTANCE; + } + /** * Evaluates the predicate always throwing an exception. * @@ -65,13 +74,4 @@ public final class ExceptionPredicate extends AbstractPredicate implements throw new FunctorException("ExceptionPredicate invoked"); } - /** - * Returns the singleton instance. - * - * @return the singleton instance. - */ - private Object readResolve() { - return INSTANCE; - } - } diff --git a/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java b/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java index e5896c73d..8cf0f4b45 100644 --- a/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java @@ -52,6 +52,15 @@ public final class FalsePredicate extends AbstractPredicate implements Ser private FalsePredicate() { } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ + private Object readResolve() { + return INSTANCE; + } + /** * Evaluates the predicate returning false always. * @@ -63,13 +72,4 @@ public final class FalsePredicate extends AbstractPredicate implements Ser return false; } - /** - * Returns the singleton instance. - * - * @return the singleton instance. - */ - private Object readResolve() { - return INSTANCE; - } - } diff --git a/src/main/java/org/apache/commons/collections4/functors/FunctorUtils.java b/src/main/java/org/apache/commons/collections4/functors/FunctorUtils.java index 7f23d5664..b696d010f 100644 --- a/src/main/java/org/apache/commons/collections4/functors/FunctorUtils.java +++ b/src/main/java/org/apache/commons/collections4/functors/FunctorUtils.java @@ -107,20 +107,6 @@ final class FunctorUtils { return transformers.clone(); } - /** - * Validates the consumers to ensure that all is well. - * - * @param consumers the consumers to validate. - */ - static void validate(final Consumer... consumers) { - Objects.requireNonNull(consumers, "closures"); - for (int i = 0; i < consumers.length; i++) { - if (consumers[i] == null) { - throw new NullPointerException("closures[" + i + "]"); - } - } - } - /** * Validate the predicates to ensure that all is well. * @@ -144,15 +130,15 @@ final class FunctorUtils { } /** - * Validate the predicates to ensure that all is well. + * Validates the consumers to ensure that all is well. * - * @param predicates the predicates to validate + * @param consumers the consumers to validate. */ - static void validate(final java.util.function.Predicate... predicates) { - Objects.requireNonNull(predicates, "predicates"); - for (int i = 0; i < predicates.length; i++) { - if (predicates[i] == null) { - throw new NullPointerException("predicates[" + i + "]"); + static void validate(final Consumer... consumers) { + Objects.requireNonNull(consumers, "closures"); + for (int i = 0; i < consumers.length; i++) { + if (consumers[i] == null) { + throw new NullPointerException("closures[" + i + "]"); } } } @@ -171,6 +157,20 @@ final class FunctorUtils { } } + /** + * Validate the predicates to ensure that all is well. + * + * @param predicates the predicates to validate + */ + static void validate(final java.util.function.Predicate... predicates) { + Objects.requireNonNull(predicates, "predicates"); + for (int i = 0; i < predicates.length; i++) { + if (predicates[i] == null) { + throw new NullPointerException("predicates[" + i + "]"); + } + } + } + /** * Restricted constructor. */ diff --git a/src/main/java/org/apache/commons/collections4/functors/IdentityPredicate.java b/src/main/java/org/apache/commons/collections4/functors/IdentityPredicate.java index f58cd65d7..79ffc35bc 100644 --- a/src/main/java/org/apache/commons/collections4/functors/IdentityPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/IdentityPredicate.java @@ -59,6 +59,16 @@ public final class IdentityPredicate extends AbstractPredicate implements iValue = object; } + /** + * Gets the value. + * + * @return the value + * @since 3.1 + */ + public T getValue() { + return iValue; + } + /** * Evaluates the predicate returning true if the input object is identical to * the stored object. @@ -71,14 +81,4 @@ public final class IdentityPredicate extends AbstractPredicate implements return iValue == object; } - /** - * Gets the value. - * - * @return the value - * @since 3.1 - */ - public T getValue() { - return iValue; - } - } diff --git a/src/main/java/org/apache/commons/collections4/functors/InstanceofPredicate.java b/src/main/java/org/apache/commons/collections4/functors/InstanceofPredicate.java index 149d7d4b9..3692ff900 100644 --- a/src/main/java/org/apache/commons/collections4/functors/InstanceofPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/InstanceofPredicate.java @@ -56,6 +56,16 @@ public final class InstanceofPredicate extends AbstractPredicate impleme iType = type; } + /** + * Gets the type to compare to. + * + * @return the type + * @since 3.1 + */ + public Class getType() { + return iType; + } + /** * Evaluates the predicate returning true if the input object is of the correct type. * @@ -67,14 +77,4 @@ public final class InstanceofPredicate extends AbstractPredicate impleme return iType.isInstance(object); } - /** - * Gets the type to compare to. - * - * @return the type - * @since 3.1 - */ - public Class getType() { - return iType; - } - } diff --git a/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java b/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java index d2dc9e2f6..dc9d4e633 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java @@ -52,6 +52,15 @@ public final class NotNullPredicate extends AbstractPredicate implements S private NotNullPredicate() { } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ + private Object readResolve() { + return INSTANCE; + } + /** * Evaluates the predicate returning true if the object does not equal null. * @@ -63,13 +72,4 @@ public final class NotNullPredicate extends AbstractPredicate implements S return object != null; } - /** - * Returns the singleton instance. - * - * @return the singleton instance. - */ - private Object readResolve() { - return INSTANCE; - } - } diff --git a/src/main/java/org/apache/commons/collections4/functors/NotPredicate.java b/src/main/java/org/apache/commons/collections4/functors/NotPredicate.java index 987bbd476..344c4162b 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NotPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NotPredicate.java @@ -57,17 +57,6 @@ public final class NotPredicate extends AbstractPredicate implements Predi iPredicate = predicate; } - /** - * Evaluates the predicate returning the opposite to the stored predicate. - * - * @param object the input object - * @return true if predicate returns false - */ - @Override - public boolean test(final T object) { - return !iPredicate.test(object); - } - /** * Gets the predicate being decorated. * @@ -80,4 +69,15 @@ public final class NotPredicate extends AbstractPredicate implements Predi return new Predicate[] {iPredicate}; } + /** + * Evaluates the predicate returning the opposite to the stored predicate. + * + * @param object the input object + * @return true if predicate returns false + */ + @Override + public boolean test(final T object) { + return !iPredicate.test(object); + } + } diff --git a/src/main/java/org/apache/commons/collections4/functors/NullIsExceptionPredicate.java b/src/main/java/org/apache/commons/collections4/functors/NullIsExceptionPredicate.java index 4b31140bd..84a20ab0c 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NullIsExceptionPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NullIsExceptionPredicate.java @@ -58,6 +58,18 @@ public final class NullIsExceptionPredicate extends AbstractPredicate impl iPredicate = predicate; } + /** + * Gets the predicate being decorated. + * + * @return the predicate as the only element in an array + * @since 3.1 + */ + @Override + @SuppressWarnings("unchecked") + public Predicate[] getPredicates() { + return new Predicate[] { iPredicate }; + } + /** * Evaluates the predicate returning the result of the decorated predicate * once a null check is performed. @@ -74,16 +86,4 @@ public final class NullIsExceptionPredicate extends AbstractPredicate impl return iPredicate.test(object); } - /** - * Gets the predicate being decorated. - * - * @return the predicate as the only element in an array - * @since 3.1 - */ - @Override - @SuppressWarnings("unchecked") - public Predicate[] getPredicates() { - return new Predicate[] { iPredicate }; - } - } diff --git a/src/main/java/org/apache/commons/collections4/functors/NullIsFalsePredicate.java b/src/main/java/org/apache/commons/collections4/functors/NullIsFalsePredicate.java index b70b1b93f..f4b6bf037 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NullIsFalsePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NullIsFalsePredicate.java @@ -57,6 +57,18 @@ public final class NullIsFalsePredicate extends AbstractPredicate implemen iPredicate = predicate; } + /** + * Gets the predicate being decorated. + * + * @return the predicate as the only element in an array + * @since 3.1 + */ + @Override + @SuppressWarnings("unchecked") + public Predicate[] getPredicates() { + return new Predicate[] { iPredicate }; + } + /** * Evaluates the predicate returning the result of the decorated predicate * once a null check is performed. @@ -72,16 +84,4 @@ public final class NullIsFalsePredicate extends AbstractPredicate implemen return iPredicate.test(object); } - /** - * Gets the predicate being decorated. - * - * @return the predicate as the only element in an array - * @since 3.1 - */ - @Override - @SuppressWarnings("unchecked") - public Predicate[] getPredicates() { - return new Predicate[] { iPredicate }; - } - } diff --git a/src/main/java/org/apache/commons/collections4/functors/NullIsTruePredicate.java b/src/main/java/org/apache/commons/collections4/functors/NullIsTruePredicate.java index 2dc0a107f..556d0d6fb 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NullIsTruePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NullIsTruePredicate.java @@ -57,6 +57,18 @@ public final class NullIsTruePredicate extends AbstractPredicate implement iPredicate = predicate; } + /** + * Gets the predicate being decorated. + * + * @return the predicate as the only element in an array + * @since 3.1 + */ + @Override + @SuppressWarnings("unchecked") + public Predicate[] getPredicates() { + return new Predicate[] { iPredicate }; + } + /** * Evaluates the predicate returning the result of the decorated predicate * once a null check is performed. @@ -72,16 +84,4 @@ public final class NullIsTruePredicate extends AbstractPredicate implement return iPredicate.test(object); } - /** - * Gets the predicate being decorated. - * - * @return the predicate as the only element in an array - * @since 3.1 - */ - @Override - @SuppressWarnings("unchecked") - public Predicate[] getPredicates() { - return new Predicate[] { iPredicate }; - } - } diff --git a/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java b/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java index 645fd811b..70f6b529d 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java @@ -52,6 +52,15 @@ public final class NullPredicate extends AbstractPredicate implements Seri private NullPredicate() { } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ + private Object readResolve() { + return INSTANCE; + } + /** * Evaluates the predicate returning true if the input is null. * @@ -63,13 +72,4 @@ public final class NullPredicate extends AbstractPredicate implements Seri return object == null; } - /** - * Returns the singleton instance. - * - * @return the singleton instance. - */ - private Object readResolve() { - return INSTANCE; - } - } diff --git a/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java b/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java index cdd027aac..a6f69c2ce 100644 --- a/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java @@ -64,17 +64,6 @@ public final class OrPredicate extends AbstractPredicate implements Predic iPredicate2 = predicate2; } - /** - * Evaluates the predicate returning true if either predicate returns true. - * - * @param object the input object - * @return true if either decorated predicate returns true - */ - @Override - public boolean test(final T object) { - return iPredicate1.test(object) || iPredicate2.test(object); - } - /** * Gets the two predicates being decorated as an array. * @@ -87,4 +76,15 @@ public final class OrPredicate extends AbstractPredicate implements Predic return new Predicate[] {iPredicate1, iPredicate2}; } + /** + * Evaluates the predicate returning true if either predicate returns true. + * + * @param object the input object + * @return true if either decorated predicate returns true + */ + @Override + public boolean test(final T object) { + return iPredicate1.test(object) || iPredicate2.test(object); + } + } diff --git a/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java b/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java index 7b19ce342..8269da30f 100644 --- a/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java @@ -68,19 +68,6 @@ public final class TransformedPredicate extends AbstractPredicate implemen iPredicate = predicate; } - /** - * Evaluates the predicate returning the result of the decorated predicate - * once the input has been transformed - * - * @param object the input object which will be transformed - * @return true if decorated predicate returns true - */ - @Override - public boolean test(final T object) { - final T result = iTransformer.apply(object); - return iPredicate.test(result); - } - /** * Gets the predicate being decorated. * @@ -102,4 +89,17 @@ public final class TransformedPredicate extends AbstractPredicate implemen return iTransformer; } + /** + * Evaluates the predicate returning the result of the decorated predicate + * once the input has been transformed + * + * @param object the input object which will be transformed + * @return true if decorated predicate returns true + */ + @Override + public boolean test(final T object) { + final T result = iTransformer.apply(object); + return iPredicate.test(result); + } + } diff --git a/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java b/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java index e40b014d7..b34fada5c 100644 --- a/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java @@ -59,6 +59,16 @@ public final class TransformerPredicate extends AbstractPredicate implemen iTransformer = transformer; } + /** + * Gets the transformer. + * + * @return the transformer + * @since 3.1 + */ + public Transformer getTransformer() { + return iTransformer; + } + /** * Evaluates the predicate returning the result of the decorated transformer. * @@ -76,14 +86,4 @@ public final class TransformerPredicate extends AbstractPredicate implemen return result.booleanValue(); } - /** - * Gets the transformer. - * - * @return the transformer - * @since 3.1 - */ - public Transformer getTransformer() { - return iTransformer; - } - } diff --git a/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java b/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java index d2c3cdfa4..b333ea050 100644 --- a/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java @@ -52,6 +52,15 @@ public final class TruePredicate extends AbstractPredicate implements Seri private TruePredicate() { } + /** + * Returns the singleton instance. + * + * @return the singleton instance. + */ + private Object readResolve() { + return INSTANCE; + } + /** * Evaluates the predicate returning true always. * @@ -63,13 +72,4 @@ public final class TruePredicate extends AbstractPredicate implements Seri return true; } - /** - * Returns the singleton instance. - * - * @return the singleton instance. - */ - private Object readResolve() { - return INSTANCE; - } - }