List of usage examples for org.apache.commons.functor.core.composite Composite predicate
public static <L, R, G, H> UnaryCompositeBinaryPredicate<L, R> predicate( BinaryPredicate<? super G, ? super H> p, UnaryFunction<? super L, ? extends G> g, UnaryFunction<? super R, ? extends H> h)
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.// w w w . j av a 2 s . co m */ 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 )); }