public class PredicateUtils extends java.lang.Object
Constructor and Description |
---|
PredicateUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> java.util.function.Predicate<T> |
alwaysTrue()
Returns a predicate that always returns true.
|
static <T> java.util.function.Predicate<T> |
not(java.util.function.Predicate<T> predicate)
Negates the given predicate (returns false if the given predicate returns
true and vice versa).
|
static <T> java.util.List<T> |
obtainContained(java.util.Collection<T> input,
java.util.function.Predicate<? super T> predicate)
Returns all input elements that are contained in the set described by the
predicate.
|
static <T> java.util.List<T> |
obtainNonContained(java.util.Collection<T> input,
java.util.function.Predicate<? super T> predicate)
Returns all input elements that are not contained in the set described
by the predicate.
|
static <T> Pair<java.util.List<T>,java.util.List<T>> |
splitContainedNonContained(java.util.Collection<T> input,
java.util.function.Predicate<? super T> predicate)
Efficiently splits the list of input elements into two lists.
The first consists of all input elements that are contained in the set described by the predicate. The second consists of all input elements that are not contained in the set described by the predicate. Efficiently in this case means that only one iteration through the list is needed to split into two lists. |
public PredicateUtils()
public static <T> java.util.List<T> obtainContained(java.util.Collection<T> input, java.util.function.Predicate<? super T> predicate)
T
- Type in collection.public static <T> Pair<java.util.List<T>,java.util.List<T>> splitContainedNonContained(java.util.Collection<T> input, java.util.function.Predicate<? super T> predicate)
input
- the list of input elements.predicate
- the Predicate
used to decide containment.public static <T> java.util.List<T> obtainNonContained(java.util.Collection<T> input, java.util.function.Predicate<? super T> predicate)
public static <T> java.util.function.Predicate<T> alwaysTrue()
public static <T> java.util.function.Predicate<T> not(java.util.function.Predicate<T> predicate)