Example usage for org.apache.commons.functor.aggregator AbstractNoStoreAggregator AbstractNoStoreAggregator

List of usage examples for org.apache.commons.functor.aggregator AbstractNoStoreAggregator AbstractNoStoreAggregator

Introduction

In this page you can find the example usage for org.apache.commons.functor.aggregator AbstractNoStoreAggregator AbstractNoStoreAggregator.

Prototype

public AbstractNoStoreAggregator(BinaryFunction<T, T, T> aggregationFunction) 

Source Link

Document

Similar to #AbstractNoStoreAggregator(BinaryFunction,long) AbstractNoStoreAggregator(aggregationFunction,0L) .

Usage

From source file:org.apache.commons.functor.example.aggregator.nostore.AggregatedFunctionSample.java

/**
 * Uses a custom function together with a nostore aggregator to provide a
 * continuous logical OR in between all the values added to the aggregator.
 *//* ww w  .  j a  v  a  2s.  c  o  m*/
public void useOwnFunction() throws Exception {
    AbstractNoStoreAggregator<Boolean> or = new AbstractNoStoreAggregator<Boolean>(new OwnBinaryFunction()) {
        @Override
        protected Boolean initialValue() {
            return false;
        }
    };
    or.add(false);
    System.out.println("OR : " + or.evaluate());
    or.add(true);
    System.out.println("OR : " + or.evaluate());
    or.add(false);
    System.out.println("OR : " + or.evaluate());
}