Class IfTransformer<T,R> 
java.lang.Object
org.apache.commons.collections4.functors.IfTransformer<T,R> 
- Type Parameters:
- T- the type of the input to the function.
- R- the type of the result of the function.
- All Implemented Interfaces:
- Serializable,- Function<T,,- R> - Transformer<T,- R> 
Transformer implementation that will call one of two closures based on whether a predicate evaluates
 as true or false.
- Since:
- 4.1
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionIfTransformer(Predicate<? super T> predicate, Transformer<? super T, ? extends R> trueTransformer, Transformer<? super T, ? extends R> falseTransformer) Constructor that performs no validation.
- 
Method SummaryModifier and TypeMethodDescriptionTransformer<? super T, ? extends R> Gets the transformer used when false.Gets the predicate.Transformer<? super T, ? extends R> 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.Transforms the input using the true or false transformer based to the result of the predicate.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.collections4.Transformerapply
- 
Constructor Details- 
IfTransformerpublic IfTransformer(Predicate<? super T> predicate, Transformer<? super T, ? extends R> trueTransformer, Transformer<? super T, ? extends R> falseTransformer) Constructor that performs no validation. Use the static factory methodifTransformerif you want that.- Parameters:
- predicate- predicate to switch on, not null
- trueTransformer- transformer used if true, not null
- falseTransformer- transformer used if false, not null
 
 
- 
- 
Method Details- 
ifTransformerpublic 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.- Type Parameters:
- I- input type for the transformer
- O- output type for the transformer
- Parameters:
- predicate- predicate to switch on
- trueTransformer- transformer used if true
- falseTransformer- transformer used if false
- Returns:
- the iftransformer
- Throws:
- NullPointerException- if either argument is null
 
- 
ifTransformerpublic static <T> Transformer<T,T> ifTransformer(Predicate<? super T> predicate, Transformer<? super T, ? extends T> trueTransformer) Factory method that performs validation.This factory creates a transformer that just returns the input object when the predicate is false. - Type Parameters:
- T- input and output type for the transformer
- Parameters:
- predicate- predicate to switch on
- trueTransformer- transformer used if true
- Returns:
- the iftransformer
- Throws:
- NullPointerException- if either argument is null
 
- 
getFalseTransformerGets the transformer used when false.- Returns:
- the transformer
 
- 
getPredicate
- 
getTrueTransformerGets the transformer used when true.- Returns:
- the transformer
 
- 
transform
 
-