Example usage for org.apache.commons.functor.core.composite Composite predicate

List of usage examples for org.apache.commons.functor.core.composite Composite predicate

Introduction

In this page you can find the example usage for org.apache.commons.functor.core.composite Composite predicate.

Prototype

public static <A, T> CompositeUnaryPredicate<A> predicate(UnaryPredicate<? super T> predicate,
        UnaryFunction<? super A, ? extends T> function) 

Source Link

Document

Create a composite UnaryPredicate.

Usage

From source file:org.apache.commons.functor.example.kata.four.DataMunger.java

/**
 * Processes each line of the given Reader, returning the <i>selected</i> column for the
 * line where the absolute difference between the integer value of <i>col1</i> and <i>col2</i>
 * is least.  Note that lines that don't begin with an Integer are ignored.
 *//*  w w  w .j a v  a  2s  . c  o m*/
public static final Object process(final Reader file, final int selected, final int col1, final int col2) {
    return NthColumn.instance(selected)
            .evaluate(new FoldLeft<String>(lesserSpread(col1, col2)).evaluate(new FilteredGenerator<String>(
                    Lines.from(file), Composite.predicate(IsInteger.instance(), NthColumn.instance(0)))));
}