functionalj.list.FuncListBuilder Maven / Gradle / Ivy
package functionalj.list;
import java.util.ArrayList;
import java.util.List;
public class FuncListBuilder {
private final List entries;
private final int count;
public FuncListBuilder() {
this.entries = new ArrayList();
this.count = 0;
}
private FuncListBuilder(List entries) {
this.entries = entries;
this.count = this.entries.size();
}
public FuncListBuilder with(DATA value) {
this.entries.add(value);
return new FuncListBuilder<>(this.entries);
}
public ImmutableList build() {
return ImmutableList.from(this.entries.stream().limit(count));
}
}