org.tbull.util
Class Grepper.ANDGrepper<E>
Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<Grepper<E>>
org.tbull.util.Grepper.ANDGrepper<E>
- All Implemented Interfaces:
- Serializable, Cloneable, Iterable<Grepper<E>>, Collection<Grepper<E>>, List<Grepper<E>>, RandomAccess, Grepper<E>
- Enclosing interface:
- Grepper<E>
public static class Grepper.ANDGrepper<E>
- extends ArrayList<Grepper<E>>
- implements Grepper<E>
A Grepper
that chains multiple client greppers logical-AND-wise.
Greps elements that are grepped by all client greppers. Rejects elements that are rejected
by at least one of the client greppers.
Since this is a List
, you add client greppers by using the List method List.add(Object)
.
However, do not rely on this class to inherit from a specific List
implementation
(such as ArrayList
), as this may change in the future.
Invokes the client greppers in the order stored in this list. From a performance point of view it is
best to add greppers first that are most likely to reject most of the tested elements.
- See Also:
Grepper.ORGrepper
,
Serialized Form
Method Summary |
boolean |
grep(E element)
Returns false if any of the client greppers returns false . |
Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, set, size, toArray, toArray, trimToSize |
Grepper.ANDGrepper
public Grepper.ANDGrepper()
grep
public boolean grep(E element)
- Returns
false
if any of the client greppers returns false
.
Returns true
if all client greppers return true
.
- Specified by:
grep
in interface Grepper<E>
- Parameters:
element
- The element under test.
- Returns:
true
if the element matches the grep condition, thus should be added to the results,
otherwise false
.