org.tbull.util
Class Grepper.InverseGrepper<E>
Object
org.tbull.util.Grepper.InverseGrepper<E>
- All Implemented Interfaces:
- Grepper<E>
- Enclosing interface:
- Grepper<E>
public static class Grepper.InverseGrepper<E>
- extends Object
- implements Grepper<E>
A Grepper
that inverts the results of another grepper.
If you have a Grepper
and you need exactly the inverse results (i.e. you want to grep the elements
your grepper rejects and want to reject the elements your grepper accepts), then wrap this one around
the original grepper.
Grepper<X> your_grepper;
results = grep(new InverseGrepper<X>(your_grepper), input...);
Method Summary |
boolean |
grep(E element)
Returns true if the wrapped grepper returns false , and vice versa. |
Grepper.InverseGrepper
public Grepper.InverseGrepper(Grepper<E> grepper)
grep
public boolean grep(E element)
- Returns
true
if the wrapped grepper returns false
, and vice versa.
- 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
.