List of usage examples for org.apache.commons.functor.core.composite Conditional function
public static <L, R, T> BinaryFunction<L, R, T> function(BinaryPredicate<? super L, ? super R> q, BinaryFunction<? super L, ? super R, ? extends T> r, BinaryFunction<? super L, ? super R, ? extends T> s)
From source file:org.apache.commons.functor.example.kata.four.DataMunger.java
/** * A BinaryFunction that will calculate the absolute * difference between col1 and col2 in the given * String arguments, and return the argument * whose difference is smallest./*www. java2s .com*/ */ private static final BinaryFunction<String, String, String> lesserSpread(final int col1, final int col2) { return new ConditionalBinaryFunction<String, String, String>(IsNull.<String>left(), // if left is null RightIdentity.<String, String>function(), // return right Conditional.function( // else return the parameter with the least spread Composite.predicate( // if left is less than right IsLessThan.instance(), absSpread(col1, col2), absSpread(col1, col2)), LeftIdentity.<String, String>function(), // return left RightIdentity.<String, String>function() // else return right )); }