monniasza.collects.ListModelCollector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multimachinebuilder Show documentation
Show all versions of multimachinebuilder Show documentation
Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world.
THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<
The newest version!
/**
*
*/
package monniasza.collects;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
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;
import javax.swing.DefaultListModel;
import mmb.NN;
/**
* Collects a stream to a list
* @author oskar
* @param type of values
*/
public class ListModelCollector implements Collector, DefaultListModel> {
/** @return a list model collector */
@SuppressWarnings("unchecked")
/**
* @param type of values
* @return a stream collector for list models
*/
@NN public static ListModelCollector create(){return (ListModelCollector) collector;}
@NN private static final ListModelCollector> collector = new ListModelCollector<>();
private ListModelCollector(){}
@Override
public Supplier> supplier() {
return ArrayList::new;
}
@Override
public BiConsumer, T> accumulator() {
return List::add;
}
@SuppressWarnings("null")
@Override
public BinaryOperator> combiner() {
return Collects::inplaceAddLists;
}
@SuppressWarnings("null")
@Override
public Function, DefaultListModel> finisher() {
return Collects::newListModel;
}
@Override
public Set characteristics() {
return Collections.emptySet();
}
}