net.morimekta.collect.collectors.UnmodifiableSetCollector Maven / Gradle / Ivy
package net.morimekta.collect.collectors;
import net.morimekta.collect.UnmodifiableSet;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;
public class UnmodifiableSetCollector implements Collector, UnmodifiableSet> {
@Override
public Supplier> supplier() {
return UnmodifiableSet::newBuilder;
}
@Override
public BiConsumer, E> accumulator() {
return UnmodifiableSet.Builder::add;
}
@Override
public BinaryOperator> combiner() {
return (b1, b2) -> b1.addAll(b2.build());
}
@Override
public Function, UnmodifiableSet> finisher() {
return UnmodifiableSet.Builder::build;
}
@Override
public Set characteristics() {
return UnmodifiableSet.setOf();
}
}