Example usage for java.util.stream Collector finisher

List of usage examples for java.util.stream Collector finisher

Introduction

In this page you can find the example usage for java.util.stream Collector finisher.

Prototype

Function<A, R> finisher();

Source Link

Document

Perform the final transformation from the intermediate accumulation type A to the final result type R .

Usage

From source file:org.briljantframework.array.AbstractDoubleArray.java

@Override
public <R, C> R collect(Collector<? super Double, C, R> collector) {
    C accum = collector.supplier().get();
    for (int i = 0; i < size(); i++) {
        collector.accumulator().accept(accum, get(i));
    }// www  .j a v a  2 s  .c  om
    return collector.finisher().apply(accum);
}

From source file:org.briljantframework.data.Collectors.java

public static <T, A, R, F> Collector<T, ?, F> withFinisher(Collector<T, A, R> collector,
        Function<R, F> finisher) {
    Function<A, R> f = collector.finisher();

    Set<Collector.Characteristics> characteristics = collector.characteristics();
    Collector.Characteristics[] empty = new Collector.Characteristics[characteristics.size()];
    return Collector.of(collector.supplier(), collector.accumulator(), collector.combiner(),
            f.andThen(finisher), characteristics.toArray(empty));
}

From source file:org.briljantframework.data.vector.AbstractVector.java

@Override
public <T, R, C> R collect(Class<T> in, Collector<? super T, C, ? extends R> collector) {
    C accumulator = collector.supplier().get();
    for (int i = 0; i < size(); i++) {
        collector.accumulator().accept(accumulator, loc().get(in, i));
    }//from  w w  w. ja  v  a 2 s .c  o  m
    return collector.finisher().apply(accumulator);
}