This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-collections.git
commit f46a46b535fa6e24687fc902c31034a6b51fd7aa Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu Jul 11 14:37:14 2024 -0400 Sort members --- .../collections4/functors/AndPredicate.java | 22 ++++++------ .../collections4/functors/EqualPredicate.java | 20 +++++------ .../collections4/functors/ExceptionPredicate.java | 18 +++++----- .../collections4/functors/FalsePredicate.java | 18 +++++----- .../collections4/functors/FunctorUtils.java | 42 +++++++++++----------- .../collections4/functors/IdentityPredicate.java | 20 +++++------ .../collections4/functors/InstanceofPredicate.java | 20 +++++------ .../collections4/functors/NotNullPredicate.java | 18 +++++----- .../collections4/functors/NotPredicate.java | 22 ++++++------ .../functors/NullIsExceptionPredicate.java | 24 ++++++------- .../functors/NullIsFalsePredicate.java | 24 ++++++------- .../collections4/functors/NullIsTruePredicate.java | 24 ++++++------- .../collections4/functors/NullPredicate.java | 18 +++++----- .../commons/collections4/functors/OrPredicate.java | 22 ++++++------ .../functors/TransformedPredicate.java | 26 +++++++------- .../functors/TransformerPredicate.java | 20 +++++------ .../collections4/functors/TruePredicate.java | 18 +++++----- 17 files changed, 188 insertions(+), 188 deletions(-) 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<Object> 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<Object> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<? super T>[] 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<T> extends AbstractPredicate<T> 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<? super T>[] 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<T> extends AbstractPredicate<T> 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<? super T>[] 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<T> extends AbstractPredicate<T> 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<? super T>[] 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<T> extends AbstractPredicate<T> 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<? super T>[] 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<T> extends AbstractPredicate<T> 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<? super T>[] 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> implemen iTransformer = transformer; } + /** + * Gets the transformer. + * + * @return the transformer + * @since 3.1 + */ + public Transformer<? super T, Boolean> getTransformer() { + return iTransformer; + } + /** * Evaluates the predicate returning the result of the decorated transformer. * @@ -76,14 +86,4 @@ public final class TransformerPredicate<T> extends AbstractPredicate<T> implemen return result.booleanValue(); } - /** - * Gets the transformer. - * - * @return the transformer - * @since 3.1 - */ - public Transformer<? super T, Boolean> 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<T> extends AbstractPredicate<T> 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<T> extends AbstractPredicate<T> implements Seri return true; } - /** - * Returns the singleton instance. - * - * @return the singleton instance. - */ - private Object readResolve() { - return INSTANCE; - } - }