ansitable.Collectors Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ansitable Show documentation
Show all versions of ansitable Show documentation
tools for displaying tabular data in a terminal
The newest version!
package ansitable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
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 final class Collectors {
private Collectors() {}
private static final class ImmutableListCollector implements Collector, ImmutableList> {
@Override
public Supplier> supplier() {
return ImmutableList::builder;
}
@Override
public BiConsumer, T> accumulator() {
return (builder, elem) -> builder.add(elem);
}
@Override
public BinaryOperator> combiner() {
return (left, right) -> left.addAll(right.build());
}
@Override
public Function, ImmutableList> finisher() {
return ImmutableList.Builder::build;
}
@Override
public Set characteristics() {
return ImmutableSet.of();
}
}
public static Collector, ImmutableList> toImmutableList() {
return new ImmutableListCollector<>();
}
}