Example usage for java.util.stream Collector supplier

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

Introduction

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

Prototype

Supplier<A> supplier();

Source Link

Document

A function that creates and returns a new mutable result container.

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));
    }//w w  w  . j a va2 s  .c o m
    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 www . ja v a 2 s.  co  m
    return collector.finisher().apply(accumulator);
}