Example usage for org.apache.commons.functor.generator FilteredGenerator FilteredGenerator

List of usage examples for org.apache.commons.functor.generator FilteredGenerator FilteredGenerator

Introduction

In this page you can find the example usage for org.apache.commons.functor.generator FilteredGenerator FilteredGenerator.

Prototype

public FilteredGenerator(Generator<? extends E> wrapped, UnaryPredicate<? super E> pred) 

Source Link

Document

Create a new FilteredGenerator.

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.
 *///from ww w .ja v a 2 s  .  com
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)))));
}