Class Predicates<T>
java.lang.Object
org.eclipse.collections.impl.block.factory.Predicates<T>
- All Implemented Interfaces:
Serializable
,Predicate<T>
,Predicate<T>
- Direct Known Subclasses:
Predicates.AllSatisfy
,Predicates.AnySatisfy
,Predicates.NoneSatisfy
public abstract class Predicates<T> extends Object implements Predicate<T>
The Predicates class can be used to build common Predicates to be used by methods such
as detect:, select: and reject: on the Iterate, MapIterate, and ArrayIterate classes. Predicates supports
equals, not equals, less than, greater than, less than or equal to, greater than or equal to, in, not in
and, or, and several other Predicate type operations.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Predicates.AllSatisfy<T>
static class
Predicates.AnySatisfy<T>
static class
Predicates.NoneSatisfy<T>
-
Constructor Summary
Constructors Constructor Description Predicates()
-
Method Summary
Modifier and Type Method Description static <T> Predicates<T>
adapt(Predicate<T> predicate)
static <T> Predicates<Iterable<T>>
allSatisfy(Predicate<? super T> predicate)
static Predicates<Object>
alwaysFalse()
static Predicates<Object>
alwaysTrue()
static <T> Predicates<T>
and(Iterable<? extends Predicate<? super T>> predicates)
Predicates<T>
and(Predicate<? super T> op)
static <T> Predicates<T>
and(Predicate<? super T>... predicates)
static <T> Predicates<T>
and(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
static <T> Predicates<Iterable<T>>
anySatisfy(Predicate<? super T> predicate)
static Predicates<Object>
assignableFrom(Class<?> clazz)
static <T, V> Predicates<T>
attributeAllSatisfy(Function<? super T,? extends Iterable<V>> function, Predicate<? super V> predicate)
static <T, V> Predicates<T>
attributeAnySatisfy(Function<? super T,? extends Iterable<V>> function, Predicate<? super V> predicate)
static <T, V extends Comparable<? super V>>
Predicates<T>attributeBetweenExclusive(Function<? super T,? extends V> function, V from, V to)
static <T, V extends Comparable<? super V>>
Predicates<T>attributeBetweenInclusive(Function<? super T,? extends V> function, V from, V to)
static <T, V extends Comparable<? super V>>
Predicates<T>attributeBetweenInclusiveFrom(Function<? super T,? extends V> function, V from, V to)
static <T, V extends Comparable<? super V>>
Predicates<T>attributeBetweenInclusiveTo(Function<? super T,? extends V> function, V from, V to)
static <T> Predicates<T>
attributeEqual(Function<? super T,?> function, Object object)
static <T, V extends Comparable<? super V>>
Predicates<T>attributeGreaterThan(Function<? super T,? extends V> function, V object)
static <T, V extends Comparable<? super V>>
Predicates<T>attributeGreaterThanOrEqualTo(Function<? super T,? extends V> function, V object)
static <T> Predicates<T>
attributeIn(Function<? super T,?> function, Iterable<?> iterable)
Creates a predicate which returns true if an attribute selected from an object passed to accept method is contained in the iterable.static <T> Predicates<T>
attributeIsNull(Function<? super T,?> function)
static <T, V extends Comparable<? super V>>
Predicates<T>attributeLessThan(Function<? super T,? extends V> function, V object)
static <T, V extends Comparable<? super V>>
Predicates<T>attributeLessThanOrEqualTo(Function<? super T,? extends V> function, V object)
static <T, V> Predicates<T>
attributeNoneSatisfy(Function<? super T,? extends Iterable<V>> function, Predicate<? super V> predicate)
static <T> Predicates<T>
attributeNotEqual(Function<? super T,?> function, Object object)
static <T> Predicates<T>
attributeNotIn(Function<? super T,?> function, Iterable<?> iterable)
Creates a predicate which returns true if an attribute selected from an object passed to accept method is not contained in the iterable.static <T> Predicates<T>
attributeNotNull(Function<? super T,?> function)
static <T, V> Predicates<T>
attributePredicate(Function<? super T,? extends V> function, Predicate<? super V> predicate)
static <T extends Comparable<? super T>>
Predicates<T>betweenExclusive(T from, T to)
Creates a predicate which returns true if an object passed to accept method is within the range, exclusive of the from and to values.static <T extends Comparable<? super T>>
Predicates<T>betweenInclusive(T from, T to)
Creates a predicate which returns true if an object passed to accept method is within the range, inclusive of the from and to values.static <T extends Comparable<? super T>>
Predicates<T>betweenInclusiveFrom(T from, T to)
Creates a predicate which returns true if an object passed to accept method is within the range, inclusive of the from and exclusive from the to value.static <T extends Comparable<? super T>>
Predicates<T>betweenInclusiveTo(T from, T to)
Creates a predicate which returns true if an object passed to accept method is within the range, exclusive of the from and inclusive of the to value.static <P, T> Predicate<T>
bind(Predicate2<? super T,? super P> predicate, P parameter)
static <T> Predicate<T>
cast(Predicate<T> predicate)
Allows a Java 8 lambda or method reference to be used in a method taking a predicate without requiring an actual cast.static Predicates<Object>
equal(Object object)
Tests for equality.static <T extends Comparable<? super T>>
Predicates<T>greaterThan(T object)
static <T extends Comparable<? super T>>
Predicates<T>greaterThanOrEqualTo(T object)
static <T> Predicates<T>
ifFalse(Function<? super T,Boolean> function)
static <T> Predicates<T>
ifTrue(Function<? super T,Boolean> function)
static Predicates<Object>
in(Iterable<?> iterable)
Creates a predicate which returns true if an object passed to accept method is contained in the iterable.static Predicates<Object>
in(Object... array)
static Predicates<Object>
instanceOf(Class<?> clazz)
static Predicates<Object>
isNull()
static <T extends Comparable<? super T>>
Predicates<T>lessThan(T object)
static <T extends Comparable<? super T>>
Predicates<T>lessThanOrEqualTo(T object)
static <T> Predicates<T>
neither(Predicate<? super T> operation1, Predicate<? super T> operation2)
static <T> Predicates<T>
noneOf(Iterable<? extends Predicate<? super T>> operations)
static <T> Predicates<T>
noneOf(Predicate<? super T>... operations)
static <T> Predicates<Iterable<T>>
noneSatisfy(Predicate<? super T> predicate)
Predicates<T>
not()
static <T> Predicates<T>
not(Predicate<T> predicate)
static Predicates<Object>
notEqual(Object object)
static Predicates<Object>
notIn(Iterable<?> iterable)
Creates a predicate which returns true if an object passed to accept method is not contained in the iterable.static Predicates<Object>
notIn(Object... array)
static Predicates<Object>
notInstanceOf(Class<?> clazz)
static Predicates<Object>
notNull()
static Predicates<Object>
notSameAs(Object object)
static <T> Predicates<T>
or(Iterable<? extends Predicate<? super T>> predicates)
Predicates<T>
or(Predicate<? super T> op)
static <T> Predicates<T>
or(Predicate<? super T>... predicates)
static <T> Predicates<T>
or(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
static Predicates<Object>
sameAs(Object object)
static Predicates<Class<?>>
subClass(Class<?> aClass)
static Predicates<Class<?>>
superClass(Class<?> aClass)
static <T> Predicate<T>
synchronizedEach(Predicate<T> predicate)
static <T> Predicate<T>
throwing(ThrowingPredicate<T> throwingPredicate)
Allows a lambda or anonymous inner class that needs to throw a checked exception to be safely wrapped as a Predicate that will throw a RuntimeException, wrapping the checked exception that is the cause.static <T> Predicate<T>
throwing(ThrowingPredicate<T> throwingPredicate, Function2<T,? super Throwable,? extends RuntimeException> rethrow)
Allows a lambda or anonymous inner class that needs to throw a checked exception to be safely wrapped as a Predicate that will throw a user specified RuntimeException based on the provided function.
-
Constructor Details
-
Predicates
public Predicates()
-
-
Method Details
-
adapt
-
cast
Allows a Java 8 lambda or method reference to be used in a method taking a predicate without requiring an actual cast. This method can be used in places where two or more method overloads could apply when used with a lambda or method reference (e.g. removeIf). -
throwing
Allows a lambda or anonymous inner class that needs to throw a checked exception to be safely wrapped as a Predicate that will throw a RuntimeException, wrapping the checked exception that is the cause. -
throwing
public static <T> Predicate<T> throwing(ThrowingPredicate<T> throwingPredicate, Function2<T,? super Throwable,? extends RuntimeException> rethrow)Allows a lambda or anonymous inner class that needs to throw a checked exception to be safely wrapped as a Predicate that will throw a user specified RuntimeException based on the provided function. The function is passed the current element and the checked exception that was thrown as context arguments. -
bind
-
synchronizedEach
-
or
-
or
public static <T> Predicates<T> or(Predicate<? super T> predicate1, Predicate<? super T> predicate2) -
or
-
and
-
and
public static <T> Predicates<T> and(Predicate<? super T> predicate1, Predicate<? super T> predicate2) -
and
-
not
-
not
-
neither
public static <T> Predicates<T> neither(Predicate<? super T> operation1, Predicate<? super T> operation2) -
noneOf
-
noneOf
-
equal
Tests for equality. -
betweenInclusive
Creates a predicate which returns true if an object passed to accept method is within the range, inclusive of the from and to values. -
betweenExclusive
Creates a predicate which returns true if an object passed to accept method is within the range, exclusive of the from and to values. -
betweenInclusiveFrom
Creates a predicate which returns true if an object passed to accept method is within the range, inclusive of the from and exclusive from the to value. -
betweenInclusiveTo
Creates a predicate which returns true if an object passed to accept method is within the range, exclusive of the from and inclusive of the to value. -
in
Creates a predicate which returns true if an object passed to accept method is contained in the iterable. -
in
-
attributeIn
Creates a predicate which returns true if an attribute selected from an object passed to accept method is contained in the iterable. -
attributeBetweenInclusive
public static <T, V extends Comparable<? super V>> Predicates<T> attributeBetweenInclusive(Function<? super T,? extends V> function, V from, V to) -
attributeBetweenExclusive
public static <T, V extends Comparable<? super V>> Predicates<T> attributeBetweenExclusive(Function<? super T,? extends V> function, V from, V to) -
attributeBetweenInclusiveFrom
public static <T, V extends Comparable<? super V>> Predicates<T> attributeBetweenInclusiveFrom(Function<? super T,? extends V> function, V from, V to) -
attributeBetweenInclusiveTo
public static <T, V extends Comparable<? super V>> Predicates<T> attributeBetweenInclusiveTo(Function<? super T,? extends V> function, V from, V to) -
notIn
Creates a predicate which returns true if an object passed to accept method is not contained in the iterable. -
notIn
-
attributeNotIn
public static <T> Predicates<T> attributeNotIn(Function<? super T,?> function, Iterable<?> iterable)Creates a predicate which returns true if an attribute selected from an object passed to accept method is not contained in the iterable. -
lessThan
-
attributeLessThan
public static <T, V extends Comparable<? super V>> Predicates<T> attributeLessThan(Function<? super T,? extends V> function, V object) -
lessThanOrEqualTo
-
attributeLessThanOrEqualTo
public static <T, V extends Comparable<? super V>> Predicates<T> attributeLessThanOrEqualTo(Function<? super T,? extends V> function, V object) -
greaterThan
-
attributeGreaterThan
public static <T, V extends Comparable<? super V>> Predicates<T> attributeGreaterThan(Function<? super T,? extends V> function, V object) -
greaterThanOrEqualTo
-
attributeGreaterThanOrEqualTo
public static <T, V extends Comparable<? super V>> Predicates<T> attributeGreaterThanOrEqualTo(Function<? super T,? extends V> function, V object) -
attributePredicate
public static <T, V> Predicates<T> attributePredicate(Function<? super T,? extends V> function, Predicate<? super V> predicate) -
attributeEqual
-
anySatisfy
-
allSatisfy
-
noneSatisfy
-
attributeAnySatisfy
public static <T, V> Predicates<T> attributeAnySatisfy(Function<? super T,? extends Iterable<V>> function, Predicate<? super V> predicate) -
attributeAllSatisfy
public static <T, V> Predicates<T> attributeAllSatisfy(Function<? super T,? extends Iterable<V>> function, Predicate<? super V> predicate) -
attributeNoneSatisfy
public static <T, V> Predicates<T> attributeNoneSatisfy(Function<? super T,? extends Iterable<V>> function, Predicate<? super V> predicate) -
notEqual
-
ifTrue
-
ifFalse
-
attributeNotEqual
-
isNull
-
attributeIsNull
-
notNull
-
attributeNotNull
-
sameAs
-
notSameAs
-
instanceOf
-
assignableFrom
-
notInstanceOf
-
alwaysTrue
-
alwaysFalse
-
and
-
or
-
subClass
-
superClass
-