T
- type being predicated and consumedpublic class PredicatedConsumer<T> extends Object implements Consumer<T>
A Consumer
that only gets triggered if a given predicate is
true
.
A null
predicate evaluates to true
and is the
same as using a regular Consumer
.
A null
consumer has no effect and renders this class useless.
Setting the "negate" constructor argument to true
will
perform the same predicate evaluation, but will only trigger the
consumers if it returns false
.
Constructor and Description |
---|
PredicatedConsumer(Predicate<T> predicate,
Consumer<T> consumer) |
PredicatedConsumer(Predicate<T> predicate,
Consumer<T> consumer,
boolean negate) |
Modifier and Type | Method and Description |
---|---|
void |
accept(T t) |
boolean |
equals(Object other) |
Consumer<T> |
getConsumer() |
Predicate<T> |
getPredicate() |
int |
hashCode() |
String |
toString() |
Copyright © 2008–2023 Norconex Inc.. All rights reserved.