All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jp.skypencil.guava.stream.MultisetCollector Maven / Gradle / Ivy

The newest version!
package jp.skypencil.guava.stream;

import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Supplier;
import java.util.stream.Collector;

import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset;

abstract class MultisetCollector>
        implements Collector, R> {

    @Override
    public Supplier> supplier() {
        return HashMultiset::create;
    }

    @Override
    public BiConsumer, T> accumulator() {
        return Multiset::add;
    }

    @Override
    public BinaryOperator> combiner() {
        return (set, another) -> {
            set.addAll(another);
            return set;
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy