Class Predicates<T>
- Type Parameters:
T- type being put to the test
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Predicate<T>>,Collection<Predicate<T>>,Predicate<T>,List<Predicate<T>>,RandomAccess,SequencedCollection<Predicate<T>>
A list of Predicate instances, matched as a group. This class
is an alternative to chaining multiple Predicate.and(Predicate) or
Predicate.or(Predicate).
By default predicates are tested in order and testing stops after the first
one that returned false. Only if all predicates return
true that this predicate list will return true.
The behavior is the opposite if the "any" constructor argument is
true. That is, all predicates are tested in order and
stop after the first one returning true. Only if all
predicates return false that this predicate list will return
false.
Any null predicates are simply ignored.
- Since:
- 2.0.0
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionPredicates(boolean any) Predicates(int initialCapacity) Predicates(int initialCapacity, boolean any) Predicates(Collection<Predicate<T>> predicates) Predicates(Collection<Predicate<T>> predicates, boolean any) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Predicates<T> Group of predicate that returnstrueif all of them returnstrue.static <T> Predicates<T> Group of predicate that returnstrueif any of them returnstrue.protected booleanbooleaninthashCode()booleanisAny()booleantoString()Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, forEach, get, getFirst, getLast, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAllMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll, reversed
-
Constructor Details
-
Predicates
public Predicates() -
Predicates
public Predicates(boolean any) -
Predicates
public Predicates(int initialCapacity) -
Predicates
public Predicates(int initialCapacity, boolean any) -
Predicates
-
Predicates
-
-
Method Details
-
isAny
public boolean isAny() -
test
-
anyOf
Group of predicate that returnstrueif any of them returnstrue.- Type Parameters:
T- the type of object tested- Parameters:
predicates- a group of predicates- Returns:
- a group of predicates
- Since:
- 3.0.0
-
allOf
Group of predicate that returnstrueif all of them returnstrue.- Type Parameters:
T- the type of object tested- Parameters:
predicates- a group of predicates- Returns:
- a group of predicates
- Since:
- 3.0.0
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
- Overrides:
toStringin classAbstractCollection<Predicate<T>>
-