Class PredicatedConsumer<T>
- java.lang.Object
-
- com.norconex.commons.lang.function.PredicatedConsumer<T>
-
- Type Parameters:
T- type being predicated and consumed
- All Implemented Interfaces:
Consumer<T>
public class PredicatedConsumer<T> extends Object implements Consumer<T>
A
Consumerthat only gets triggered if a given predicate istrue.A
nullpredicate evaluates totrueand is the same as using a regularConsumer.A
nullconsumer has no effect and renders this class useless.Setting the "negate" constructor argument to
truewill perform the same predicate evaluation, but will only trigger the consumers if it returnsfalse.- Since:
- 2.0.0
- Author:
- Pascal Essiembre
-
-
Constructor Summary
Constructors Constructor Description PredicatedConsumer(Predicate<T> predicate, Consumer<T> consumer)PredicatedConsumer(Predicate<T> predicate, Consumer<T> consumer, boolean negate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(T t)booleanequals(Object other)Consumer<T>getConsumer()Predicate<T>getPredicate()inthashCode()StringtoString()
-