Class Predicates<T>
- java.lang.Object
-
- org.eclipse.collections.impl.block.factory.Predicates<T>
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.function.Predicate<T>
,Predicate<T>
- Direct Known Subclasses:
IntegerPredicates.IntegerIsEven
,IntegerPredicates.IntegerIsNegative
,IntegerPredicates.IntegerIsOdd
,IntegerPredicates.IntegerIsPositive
,IntegerPredicates.IntegerIsZero
,LongPredicates.LongIsEven
,LongPredicates.LongIsNegative
,LongPredicates.LongIsOdd
,LongPredicates.LongIsPositive
,LongPredicates.LongIsZero
,Predicates.AbstractIterablePredicate
,Predicates.AllSatisfy
,Predicates.AlwaysFalse
,Predicates.AlwaysTrue
,Predicates.AndPredicate
,Predicates.AnySatisfy
,Predicates.AssignableFromPredicate
,Predicates.AttributePredicate
,Predicates.CompareToPredicate
,Predicates.EqualPredicate
,Predicates.IdentityPredicate
,Predicates.InCollectionPredicate
,Predicates.InSetIterablePredicate
,Predicates.InSetPredicate
,Predicates.InstanceOfPredicate
,Predicates.IsNull
,Predicates.NeitherPredicate
,Predicates.NoneSatisfy
,Predicates.NotEqualPredicate
,Predicates.NotIdentityPredicate
,Predicates.NotInCollectionPredicate
,Predicates.NotInSetIterablePredicate
,Predicates.NotInSetPredicate
,Predicates.NotInstanceOfPredicate
,Predicates.NotNull
,Predicates.NotPredicate
,Predicates.OrPredicate
,Predicates.PredicateAdapter
,Predicates.SubclassPredicate
,Predicates.SuperclassPredicate
,StringPredicates.ContainsCharacter
,StringPredicates.ContainsString
,StringPredicates.Empty
,StringPredicates.EndsWith
,StringPredicates.EqualsIgnoreCase
,StringPredicates.GreaterThan
,StringPredicates.GreaterThanOrEqualTo
,StringPredicates.HasDigits
,StringPredicates.HasLetters
,StringPredicates.HasLettersAndDigits
,StringPredicates.HasLettersOrDigits
,StringPredicates.HasLowercase
,StringPredicates.HasSpaces
,StringPredicates.HasUndefined
,StringPredicates.HasUppercase
,StringPredicates.IsAlpha
,StringPredicates.IsAlphanumeric
,StringPredicates.IsBlank
,StringPredicates.IsNumeric
,StringPredicates.LessThan
,StringPredicates.LessThanOrEqualTo
,StringPredicates.MatchesRegex
,StringPredicates.NotBlank
,StringPredicates.NotContainsString
,StringPredicates.NotEmpty
,StringPredicates.Size
,StringPredicates.StartsWith
public abstract class Predicates<T> extends java.lang.Object implements Predicate<T>
The Predicates class can be used to build common Predicates for use in methods such as detect, select and reject which are found on 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 private static class
Predicates.AbstractIterablePredicate<T>
static class
Predicates.AllSatisfy<T>
private static class
Predicates.AlwaysFalse
private static class
Predicates.AlwaysTrue
private static class
Predicates.AndIterablePredicate<T>
private static class
Predicates.AndPredicate<T>
static class
Predicates.AnySatisfy<T>
private static class
Predicates.AssignableFromPredicate
private static class
Predicates.AttributeFalse<T>
protected static class
Predicates.AttributePredicate<T,V>
private static class
Predicates.AttributeTrue<T>
private static class
Predicates.BetweenExclusive<T extends java.lang.Comparable<? super T>>
private static class
Predicates.BetweenInclusive<T extends java.lang.Comparable<? super T>>
private static class
Predicates.BetweenInclusiveFrom<T extends java.lang.Comparable<? super T>>
private static class
Predicates.BetweenInclusiveTo<T extends java.lang.Comparable<? super T>>
private static class
Predicates.BindPredicate2<T,P>
private static class
Predicates.CompareToPredicate<T extends java.lang.Comparable<? super T>>
private static class
Predicates.EqualPredicate
private static class
Predicates.FalseEquals
protected static class
Predicates.GreaterThanOrEqualPredicate<T extends java.lang.Comparable<? super T>>
protected static class
Predicates.GreaterThanPredicate<T extends java.lang.Comparable<? super T>>
private static class
Predicates.IdentityPredicate
private static class
Predicates.InCollectionPredicate
private static class
Predicates.InSetIterablePredicate
private static class
Predicates.InSetPredicate
private static class
Predicates.InstanceOfPredicate
private static class
Predicates.IsNull
protected static class
Predicates.LessThanOrEqualPredicate<T extends java.lang.Comparable<? super T>>
protected static class
Predicates.LessThanPredicate<T extends java.lang.Comparable<? super T>>
private static class
Predicates.NeitherPredicate<T>
private static class
Predicates.NoneOfIterablePredicate<T>
static class
Predicates.NoneSatisfy<T>
private static class
Predicates.NotEqualPredicate
private static class
Predicates.NotIdentityPredicate
private static class
Predicates.NotInCollectionPredicate
private static class
Predicates.NotInSetIterablePredicate
private static class
Predicates.NotInSetPredicate
private static class
Predicates.NotInstanceOfPredicate
private static class
Predicates.NotNull
private static class
Predicates.NotPredicate<T>
private static class
Predicates.OrIterablePredicate<T>
private static class
Predicates.OrPredicate<T>
private static class
Predicates.PredicateAdapter<T>
protected static class
Predicates.RangePredicate<T extends java.lang.Comparable<? super T>>
private static class
Predicates.SubclassPredicate
private static class
Predicates.SuperclassPredicate
private static class
Predicates.SynchronizedPredicate<T>
private static class
Predicates.ThrowingPredicateAdapter<T>
private static class
Predicates.TrueEquals
-
Field Summary
Fields Modifier and Type Field Description private static Predicates<java.lang.Object>
ALWAYS_FALSE
private static Predicates<java.lang.Object>
ALWAYS_TRUE
private static Predicates<java.lang.Object>
IS_NULL
private static Predicates<java.lang.Object>
NOT_NULL
private static long
serialVersionUID
private static int
SMALL_COLLECTION_THRESHOLD
-
Constructor Summary
Constructors Constructor Description Predicates()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Predicates<T>
adapt(Predicate<T> predicate)
static <T> Predicates<java.lang.Iterable<T>>
allSatisfy(Predicate<? super T> predicate)
static Predicates<java.lang.Object>
alwaysFalse()
static Predicates<java.lang.Object>
alwaysTrue()
static <T> Predicates<T>
and(java.lang.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<java.lang.Iterable<T>>
anySatisfy(Predicate<? super T> predicate)
static Predicates<java.lang.Object>
assignableFrom(java.lang.Class<?> clazz)
static <T,V>
Predicates<T>attributeAllSatisfy(Function<? super T,? extends java.lang.Iterable<V>> function, Predicate<? super V> predicate)
static <T,V>
Predicates<T>attributeAnySatisfy(Function<? super T,? extends java.lang.Iterable<V>> function, Predicate<? super V> predicate)
static <T,V extends java.lang.Comparable<? super V>>
Predicates<T>attributeBetweenExclusive(Function<? super T,? extends V> function, V from, V to)
static <T,V extends java.lang.Comparable<? super V>>
Predicates<T>attributeBetweenInclusive(Function<? super T,? extends V> function, V from, V to)
static <T,V extends java.lang.Comparable<? super V>>
Predicates<T>attributeBetweenInclusiveFrom(Function<? super T,? extends V> function, V from, V to)
static <T,V extends java.lang.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, java.lang.Object object)
static <T,V extends java.lang.Comparable<? super V>>
Predicates<T>attributeGreaterThan(Function<? super T,? extends V> function, V object)
static <T,V extends java.lang.Comparable<? super V>>
Predicates<T>attributeGreaterThanOrEqualTo(Function<? super T,? extends V> function, V object)
static <T> Predicates<T>
attributeIn(Function<? super T,?> function, java.lang.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 java.lang.Comparable<? super V>>
Predicates<T>attributeLessThan(Function<? super T,? extends V> function, V object)
static <T,V extends java.lang.Comparable<? super V>>
Predicates<T>attributeLessThanOrEqualTo(Function<? super T,? extends V> function, V object)
static <T,V>
Predicates<T>attributeNoneSatisfy(Function<? super T,? extends java.lang.Iterable<V>> function, Predicate<? super V> predicate)
static <T> Predicates<T>
attributeNotEqual(Function<? super T,?> function, java.lang.Object object)
static <T> Predicates<T>
attributeNotIn(Function<? super T,?> function, java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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<java.lang.Object>
equal(java.lang.Object object)
Tests for equality.private static void
failIfDifferentTypes(java.lang.Object from, java.lang.Object to)
static <T extends java.lang.Comparable<? super T>>
Predicates<T>greaterThan(T object)
static <T extends java.lang.Comparable<? super T>>
Predicates<T>greaterThanOrEqualTo(T object)
static <T> Predicates<T>
ifFalse(Function<? super T,java.lang.Boolean> function)
static <T> Predicates<T>
ifTrue(Function<? super T,java.lang.Boolean> function)
static Predicates<java.lang.Object>
in(java.lang.Iterable<?> iterable)
Creates a predicate which returns true if an object passed to accept method is contained in the iterable.static Predicates<java.lang.Object>
in(java.lang.Object... array)
static Predicates<java.lang.Object>
instanceOf(java.lang.Class<?> clazz)
static Predicates<java.lang.Object>
isNull()
static <T extends java.lang.Comparable<? super T>>
Predicates<T>lessThan(T object)
static <T extends java.lang.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(java.lang.Iterable<? extends Predicate<? super T>> operations)
static <T> Predicates<T>
noneOf(Predicate<? super T>... operations)
static <T> Predicates<java.lang.Iterable<T>>
noneSatisfy(Predicate<? super T> predicate)
Predicates<T>
not()
static <T> Predicates<T>
not(Predicate<T> predicate)
static Predicates<java.lang.Object>
notEqual(java.lang.Object object)
static Predicates<java.lang.Object>
notIn(java.lang.Iterable<?> iterable)
Creates a predicate which returns true if an object passed to accept method is not contained in the iterable.static Predicates<java.lang.Object>
notIn(java.lang.Object... array)
static Predicates<java.lang.Object>
notInstanceOf(java.lang.Class<?> clazz)
static Predicates<java.lang.Object>
notNull()
static Predicates<java.lang.Object>
notSameAs(java.lang.Object object)
static <T> Predicates<T>
or(java.lang.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<java.lang.Object>
sameAs(java.lang.Object object)
static Predicates<java.lang.Class<?>>
subClass(java.lang.Class<?> aClass)
static Predicates<java.lang.Class<?>>
superClass(java.lang.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 java.lang.Throwable,? extends java.lang.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.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
ALWAYS_TRUE
private static final Predicates<java.lang.Object> ALWAYS_TRUE
-
ALWAYS_FALSE
private static final Predicates<java.lang.Object> ALWAYS_FALSE
-
IS_NULL
private static final Predicates<java.lang.Object> IS_NULL
-
NOT_NULL
private static final Predicates<java.lang.Object> NOT_NULL
-
SMALL_COLLECTION_THRESHOLD
private static final int SMALL_COLLECTION_THRESHOLD
- See Also:
- Constant Field Values
-
-
Method Detail
-
adapt
public static <T> Predicates<T> adapt(Predicate<T> predicate)
-
cast
public 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. 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
public 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.
-
throwing
public static <T> Predicate<T> throwing(ThrowingPredicate<T> throwingPredicate, Function2<T,? super java.lang.Throwable,? extends java.lang.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
public static <P,T> Predicate<T> bind(Predicate2<? super T,? super P> predicate, P parameter)
-
or
public static <T> Predicates<T> or(java.lang.Iterable<? extends Predicate<? super T>> predicates)
-
or
public static <T> Predicates<T> or(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
-
or
public static <T> Predicates<T> or(Predicate<? super T>... predicates)
-
and
public static <T> Predicates<T> and(java.lang.Iterable<? extends Predicate<? super T>> predicates)
-
and
public static <T> Predicates<T> and(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
-
and
public static <T> Predicates<T> and(Predicate<? super T>... predicates)
-
not
public static <T> Predicates<T> not(Predicate<T> predicate)
-
not
public Predicates<T> not()
-
neither
public static <T> Predicates<T> neither(Predicate<? super T> operation1, Predicate<? super T> operation2)
-
noneOf
public static <T> Predicates<T> noneOf(Predicate<? super T>... operations)
-
noneOf
public static <T> Predicates<T> noneOf(java.lang.Iterable<? extends Predicate<? super T>> operations)
-
equal
public static Predicates<java.lang.Object> equal(java.lang.Object object)
Tests for equality.
-
betweenInclusive
public static <T extends java.lang.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.
-
failIfDifferentTypes
private static void failIfDifferentTypes(java.lang.Object from, java.lang.Object to)
-
betweenExclusive
public static <T extends java.lang.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.
-
betweenInclusiveFrom
public static <T extends java.lang.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.
-
betweenInclusiveTo
public static <T extends java.lang.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.
-
in
public static Predicates<java.lang.Object> in(java.lang.Iterable<?> iterable)
Creates a predicate which returns true if an object passed to accept method is contained in the iterable.
-
in
public static Predicates<java.lang.Object> in(java.lang.Object... array)
-
attributeIn
public static <T> Predicates<T> attributeIn(Function<? super T,?> function, java.lang.Iterable<?> iterable)
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 java.lang.Comparable<? super V>> Predicates<T> attributeBetweenInclusive(Function<? super T,? extends V> function, V from, V to)
-
attributeBetweenExclusive
public static <T,V extends java.lang.Comparable<? super V>> Predicates<T> attributeBetweenExclusive(Function<? super T,? extends V> function, V from, V to)
-
attributeBetweenInclusiveFrom
public static <T,V extends java.lang.Comparable<? super V>> Predicates<T> attributeBetweenInclusiveFrom(Function<? super T,? extends V> function, V from, V to)
-
attributeBetweenInclusiveTo
public static <T,V extends java.lang.Comparable<? super V>> Predicates<T> attributeBetweenInclusiveTo(Function<? super T,? extends V> function, V from, V to)
-
notIn
public static Predicates<java.lang.Object> notIn(java.lang.Iterable<?> iterable)
Creates a predicate which returns true if an object passed to accept method is not contained in the iterable.
-
notIn
public static Predicates<java.lang.Object> notIn(java.lang.Object... array)
-
attributeNotIn
public static <T> Predicates<T> attributeNotIn(Function<? super T,?> function, java.lang.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
public static <T extends java.lang.Comparable<? super T>> Predicates<T> lessThan(T object)
-
attributeLessThan
public static <T,V extends java.lang.Comparable<? super V>> Predicates<T> attributeLessThan(Function<? super T,? extends V> function, V object)
-
lessThanOrEqualTo
public static <T extends java.lang.Comparable<? super T>> Predicates<T> lessThanOrEqualTo(T object)
-
attributeLessThanOrEqualTo
public static <T,V extends java.lang.Comparable<? super V>> Predicates<T> attributeLessThanOrEqualTo(Function<? super T,? extends V> function, V object)
-
greaterThan
public static <T extends java.lang.Comparable<? super T>> Predicates<T> greaterThan(T object)
-
attributeGreaterThan
public static <T,V extends java.lang.Comparable<? super V>> Predicates<T> attributeGreaterThan(Function<? super T,? extends V> function, V object)
-
greaterThanOrEqualTo
public static <T extends java.lang.Comparable<? super T>> Predicates<T> greaterThanOrEqualTo(T object)
-
attributeGreaterThanOrEqualTo
public static <T,V extends java.lang.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
public static <T> Predicates<T> attributeEqual(Function<? super T,?> function, java.lang.Object object)
-
anySatisfy
public static <T> Predicates<java.lang.Iterable<T>> anySatisfy(Predicate<? super T> predicate)
-
allSatisfy
public static <T> Predicates<java.lang.Iterable<T>> allSatisfy(Predicate<? super T> predicate)
-
noneSatisfy
public static <T> Predicates<java.lang.Iterable<T>> noneSatisfy(Predicate<? super T> predicate)
-
attributeAnySatisfy
public static <T,V> Predicates<T> attributeAnySatisfy(Function<? super T,? extends java.lang.Iterable<V>> function, Predicate<? super V> predicate)
-
attributeAllSatisfy
public static <T,V> Predicates<T> attributeAllSatisfy(Function<? super T,? extends java.lang.Iterable<V>> function, Predicate<? super V> predicate)
-
attributeNoneSatisfy
public static <T,V> Predicates<T> attributeNoneSatisfy(Function<? super T,? extends java.lang.Iterable<V>> function, Predicate<? super V> predicate)
-
notEqual
public static Predicates<java.lang.Object> notEqual(java.lang.Object object)
-
ifTrue
public static <T> Predicates<T> ifTrue(Function<? super T,java.lang.Boolean> function)
-
ifFalse
public static <T> Predicates<T> ifFalse(Function<? super T,java.lang.Boolean> function)
-
attributeNotEqual
public static <T> Predicates<T> attributeNotEqual(Function<? super T,?> function, java.lang.Object object)
-
isNull
public static Predicates<java.lang.Object> isNull()
-
attributeIsNull
public static <T> Predicates<T> attributeIsNull(Function<? super T,?> function)
-
notNull
public static Predicates<java.lang.Object> notNull()
-
attributeNotNull
public static <T> Predicates<T> attributeNotNull(Function<? super T,?> function)
-
sameAs
public static Predicates<java.lang.Object> sameAs(java.lang.Object object)
-
notSameAs
public static Predicates<java.lang.Object> notSameAs(java.lang.Object object)
-
instanceOf
public static Predicates<java.lang.Object> instanceOf(java.lang.Class<?> clazz)
-
assignableFrom
public static Predicates<java.lang.Object> assignableFrom(java.lang.Class<?> clazz)
-
notInstanceOf
public static Predicates<java.lang.Object> notInstanceOf(java.lang.Class<?> clazz)
-
alwaysTrue
public static Predicates<java.lang.Object> alwaysTrue()
-
alwaysFalse
public static Predicates<java.lang.Object> alwaysFalse()
-
and
public Predicates<T> and(Predicate<? super T> op)
-
or
public Predicates<T> or(Predicate<? super T> op)
-
subClass
public static Predicates<java.lang.Class<?>> subClass(java.lang.Class<?> aClass)
-
superClass
public static Predicates<java.lang.Class<?>> superClass(java.lang.Class<?> aClass)
-
-