fj.data.Collectors Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionaljava-java8 Show documentation
Show all versions of functionaljava-java8 Show documentation
Functional Java is an open source library that supports closures for the Java programming language
The newest version!
package fj.data;
import java.util.stream.Collector;
public final class Collectors {
private Collectors() {
}
public static Collector, List> toList() {
return Collector.of(
List.Buffer::new,
List.Buffer::snoc,
(acc1, acc2) -> acc1.append(acc2.toList()),
List.Buffer::toList
);
}
public static Collector, Array> toArray() {
return Collector.of(
List.Buffer::new,
List.Buffer::snoc,
(acc1, acc2) -> acc1.append(acc2.toList()),
(buf) -> buf.toList().toArray()
);
}
public static Collector, Stream> toStream() {
return Collector.of(
List.Buffer::new,
List.Buffer::snoc,
(acc1, acc2) -> acc1.append(acc2.toList()),
(buf) -> buf.toList().toStream()
);
}
}