Skip to content

Commit d1b8bef

Browse files
committed
Java: Add more stream functions. Comment methods out, where we are not happy with the generated result.
1 parent 62de3e4 commit d1b8bef

File tree

1 file changed

+146
-5
lines changed
  • java/ql/test/utils/model-generator/typebasedflow/p

1 file changed

+146
-5
lines changed

java/ql/test/utils/model-generator/typebasedflow/p/Stream.java

Lines changed: 146 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package p;
22

3+
import java.util.*;
34
import java.util.function.*;
4-
import java.util.Iterator;
5-
import java.util.stream.Collector;
5+
import java.util.stream.*;
66

77
public class Stream<T> {
88

@@ -19,9 +19,9 @@ public <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator,
1919
}
2020

2121
// Collector is not a functional interface, so this is not supported
22-
// public <R, A> R collect(Collector<? super T, A, R> collector) {
23-
// throw null;
24-
// }
22+
public <R, A> R collect(Collector<? super T, A, R> collector) {
23+
throw null;
24+
}
2525

2626
public static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b) {
2727
throw null;
@@ -30,4 +30,145 @@ public static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b)
3030
public Stream<T> distinct() {
3131
throw null;
3232
}
33+
34+
public static <T> Stream<T> empty() {
35+
throw null;
36+
}
37+
38+
public Stream<T> filter(Predicate<? super T> predicate) {
39+
throw null;
40+
}
41+
42+
public Optional<T> findAny() {
43+
throw null;
44+
}
45+
46+
public Optional<T> findFirst() {
47+
throw null;
48+
}
49+
50+
// public <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends
51+
// R>> mapper) {
52+
// throw null;
53+
// }
54+
55+
public DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) {
56+
throw null;
57+
}
58+
59+
public IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper) {
60+
throw null;
61+
}
62+
63+
public LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
64+
throw null;
65+
}
66+
67+
public void forEach(Consumer<? super T> action) {
68+
throw null;
69+
}
70+
71+
public void forEachOrdered(Consumer<? super T> action) {
72+
throw null;
73+
}
74+
75+
// Issue with model generator. Return value is not correctly identified as a
76+
// collection like type.
77+
// public static <T> Stream<T> generate(Supplier<T> s) {
78+
// throw null;
79+
// }
80+
81+
// Issue with model generator. Return value is not correctly identified as a
82+
// collection like type.
83+
// public static <T> Stream<T> iterate(T seed, UnaryOperator<T> f) {
84+
// throw null;
85+
// }
86+
87+
public Stream<T> limit(long maxSize) {
88+
throw null;
89+
}
90+
91+
// Issue with model generator. Return value is not correctly identified as a
92+
// collection like type and also the type parameter is not correctly identified.
93+
// public <R> Stream<R> map(Function<? super T, ? extends R> mapper) {
94+
// throw null;
95+
// }
96+
97+
public DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper) {
98+
throw null;
99+
}
100+
101+
public IntStream mapToInt(ToIntFunction<? super T> mapper) {
102+
throw null;
103+
}
104+
105+
public LongStream mapToLong(ToLongFunction<? super T> mapper) {
106+
throw null;
107+
}
108+
109+
public Optional<T> max(Comparator<? super T> comparator) {
110+
throw null;
111+
}
112+
113+
public Optional<T> min(Comparator<? super T> comparator) {
114+
throw null;
115+
}
116+
117+
public boolean noneMatch(Predicate<? super T> predicate) {
118+
throw null;
119+
}
120+
121+
// Issue with model generator. ... is not supported.
122+
// public static <T> Stream<T> of(T... t) {
123+
// throw null;
124+
// }
125+
126+
// Issue with model generator. Return value is not correctly identified as a
127+
// collection like type and also the type parameter is not correctly identified.
128+
// public static <T> Stream<T> of(T t) {
129+
// throw null;
130+
// }
131+
132+
public Stream<T> peek(Consumer<? super T> action) {
133+
throw null;
134+
}
135+
136+
// Model generator yields a couple of extra results as models are generated for
137+
// writing to the stream.
138+
public Optional<T> reduce(BinaryOperator<T> accumulator) {
139+
throw null;
140+
}
141+
142+
// Model generator yields a couple of extra results as models are generated for
143+
// writing to the stream.
144+
public T reduce(T identity, BinaryOperator<T> accumulator) {
145+
throw null;
146+
}
147+
148+
public <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) {
149+
throw null;
150+
}
151+
152+
public Stream<T> skip(long n) {
153+
throw null;
154+
}
155+
156+
public Stream<T> sorted() {
157+
throw null;
158+
}
159+
160+
public Stream<T> sorted(Comparator<? super T> comparator) {
161+
throw null;
162+
}
163+
164+
// Models can never be generated correctly based on the type information
165+
// as it involves downcasting.
166+
public Object[] toArray() {
167+
throw null;
168+
}
169+
170+
// Issue with model generator - no models are generated.
171+
// public <A> A[] toArray(IntFunction<A[]> generator) {
172+
// throw null;
173+
// }
33174
}

0 commit comments

Comments
 (0)