Skip to content

Commit bca6752

Browse files
author
Kaleidox
committed
add link_role refresh command
1 parent a7467cf commit bca6752

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/main/java/org/comroid/api/func/util/Streams.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@ public static <T> Stream<T> of(Spliterator<T> spliterator) {
5656
return StreamSupport.stream(spliterator, false);
5757
}
5858

59+
@SafeVarargs
60+
public static <I> Collector<I, Collection<I>, Stream<I>> prepend(I... values) {
61+
return prepend(Arrays.asList(values));
62+
}
63+
64+
public static <I> Collector<I, Collection<I>, Stream<I>> prepend(Iterable<I> values) {
65+
return prepend(of(values));
66+
}
67+
68+
public static <I> Collector<I, Collection<I>, Stream<I>> prepend(Stream<? extends I> values) {
69+
return Collector.of(ArrayList::new, Collection::add, (l, r) -> {
70+
l.addAll(r);
71+
return l;
72+
}, is -> concat(values, is.stream()));
73+
}
74+
5975
@SafeVarargs
6076
public static <I> Collector<I, Collection<I>, Stream<I>> append(I... values) {
6177
return append(Arrays.asList(values));
@@ -65,17 +81,17 @@ public static <I> Collector<I, Collection<I>, Stream<I>> append(Iterable<I> valu
6581
return append(of(values));
6682
}
6783

68-
public static <T> Stream<T> of(Iterable<T> iterable) {
69-
return StreamSupport.stream(iterable.spliterator(), false);
70-
}
71-
7284
public static <I> Collector<I, Collection<I>, Stream<I>> append(Stream<? extends I> values) {
7385
return Collector.of(ArrayList::new, Collection::add, (l, r) -> {
7486
l.addAll(r);
7587
return l;
7688
}, is -> concat(is.stream(), values));
7789
}
7890

91+
public static <T> Stream<T> of(Iterable<T> iterable) {
92+
return StreamSupport.stream(iterable.spliterator(), false);
93+
}
94+
7995
public static <I> Function<I, Stream<I>> filter(final int next, final Consumer<I> elseConsumer) {
8096
return new Function<>() {
8197
final AtomicInteger count = new AtomicInteger(0);

0 commit comments

Comments
 (0)