I
- The input type for the transformerO
- The output type for the transformerpublic class IfTransformer<I,O> extends Object implements Transformer<I,O>, Serializable
Constructor and Description |
---|
IfTransformer(Predicate<? super I> predicate,
Transformer<? super I,? extends O> trueTransformer,
Transformer<? super I,? extends O> falseTransformer)
Constructor that performs no validation.
|
Modifier and Type | Method and Description |
---|---|
Transformer<? super I,? extends O> |
getFalseTransformer()
Gets the transformer used when false.
|
Predicate<? super I> |
getPredicate()
Gets the predicate.
|
Transformer<? super I,? extends O> |
getTrueTransformer()
Gets the transformer used when true.
|
static <I,O> Transformer<I,O> |
ifTransformer(Predicate<? super I> predicate,
Transformer<? super I,? extends O> trueTransformer,
Transformer<? super I,? extends O> falseTransformer)
Factory method that performs validation.
|
static <T> Transformer<T,T> |
ifTransformer(Predicate<? super T> predicate,
Transformer<? super T,? extends T> trueTransformer)
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 nulltrueTransformer
- transformer used if true, not nullfalseTransformer
- transformer used if false, not nullpublic 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 transformerO
- output type for the transformerpredicate
- predicate to switch ontrueTransformer
- transformer used if truefalseTransformer
- transformer used if falseif
transformerNullPointerException
- if either argument is nullpublic 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 transformerpredicate
- predicate to switch ontrueTransformer
- transformer used if trueif
transformerNullPointerException
- if either argument is nullpublic O transform(I input)
transform
in interface Transformer<I,O>
input
- the input object to transformpublic Predicate<? super I> getPredicate()
public Transformer<? super I,? extends O> getTrueTransformer()
public Transformer<? super I,? extends O> getFalseTransformer()
Copyright © 2001–2019 The Apache Software Foundation. All rights reserved.