Sort members
This commit is contained in:
parent
30e627659a
commit
f46a46b535
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue