functionalj.list.FuncListBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionalj-core Show documentation
Show all versions of functionalj-core Show documentation
The module for FunctionalJ Core.
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));
}
}