I - The input type for the transformer
O - The output type for the transformer
public class IfTransformer<I,O> extends Objectimplements Transformer <I ,O>, Serializable
| Constructor and Description |
|---|
IfTransformer(Predicate
Constructor that performs no validation.
|
| Modifier and Type | Method and Description |
|---|---|
Transformer |
getFalseTransformer()
Gets the transformer used when false.
|
Predicate |
getPredicate()
Gets the predicate.
|
Transformer |
getTrueTransformer()
Gets the transformer used when true.
|
static <I |
ifTransformer(Predicate
Factory method that performs validation.
|
static <T> Transformer |
ifTransformer(Predicate
Factory method that performs validation.
|
O |
transform(I input)
Transforms the input using the true or false transformer based to the result of the predicate.
|
public IfTransformer(Predicate<? super I> predicate, Transformer <? super I ,? extends O> trueTransformer, Transformer <? super I ,? extends O> falseTransformer)
ifTransformer if you want that.
predicate - predicate to switch on, not null
trueTransformer - transformer used if true, not null
falseTransformer - transformer used if false, not null
public static <I,O> Transformer <I ,O> ifTransformer(Predicate <? super I> predicate, Transformer <? super I ,? extends O> trueTransformer, Transformer <? super I ,? extends O> falseTransformer)
I - input type for the transformer
O - output type for the transformer
predicate - predicate to switch on
trueTransformer - transformer used if true
falseTransformer - transformer used if false
if transformer
NullPointerException - if either argument is null
public static <T> Transformer<T ,T> ifTransformer(Predicate <? super T> predicate, Transformer <? super T ,? extends T> trueTransformer)
This factory creates a transformer that just returns the input object when the predicate is false.
T - input and output type for the transformer
predicate - predicate to switch on
trueTransformer - transformer used if true
if transformer
NullPointerException - if either argument is null
public O transform(I input)
transform in interface
Transformer<I,O>
input - the input object to transform
public Transformer<? super I ,? extends O> getTrueTransformer()
public Transformer<? super I ,? extends O> getFalseTransformer()