MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / Collectors

Class Collectors

vm/JavaAPI/src/java/util/stream/Collectors.java:10–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8import java.util.function.Supplier;
9
10public final class Collectors {
11 private Collectors() {
12 }
13
14 public static <T> Collector<T, List<T>, List<T>> toList() {
15 return new Collector<T, List<T>, List<T>>() {
16 public Supplier<List<T>> supplier() {
17 return new Supplier<List<T>>() {
18 public List<T> get() {
19 return new ArrayList<T>();
20 }
21 };
22 }
23
24 public BiConsumer<List<T>, T> accumulator() {
25 return new BiConsumer<List<T>, T>() {
26 public void accept(List<T> target, T value) {
27 target.add(value);
28 }
29 };
30 }
31
32 public BinaryOperator<List<T>> combiner() {
33 return new BinaryOperator<List<T>>() {
34 public List<T> apply(List<T> left, List<T> right) {
35 left.addAll(right);
36 return left;
37 }
38 };
39 }
40
41 public Function<List<T>, List<T>> finisher() {
42 return new Function<List<T>, List<T>>() {
43 public List<T> apply(List<T> value) {
44 return value;
45 }
46 };
47 }
48 };
49 }
50
51 public static Collector<CharSequence, StringBuilder, String> joining() {
52 return new Collector<CharSequence, StringBuilder, String>() {
53 public Supplier<StringBuilder> supplier() {
54 return new Supplier<StringBuilder>() {
55 public StringBuilder get() {
56 return new StringBuilder();
57 }
58 };
59 }
60
61 public BiConsumer<StringBuilder, CharSequence> accumulator() {
62 return new BiConsumer<StringBuilder, CharSequence>() {
63 public void accept(StringBuilder target, CharSequence value) {
64 target.append(value);
65 }
66 };
67 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected