Skip to content

Commit

Permalink
Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed May 11, 2023
1 parent 298e3f8 commit 78b0417
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS;
import static java.util.Comparator.naturalOrder;
import static java.util.Comparator.reverseOrder;
import static java.util.function.Function.identity;
import static java.util.function.Predicate.not;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.filtering;
Expand Down Expand Up @@ -627,9 +628,8 @@ R after(

static final class StreamsConcat<T> {
@BeforeTemplate
@SuppressWarnings("StreamOfArray")
Stream<T> before(@Repeated Stream<T> stream) {
return Stream.of(Refaster.asVarargs(stream)).flatMap(Function.identity());
return Stream.of(Refaster.asVarargs(stream)).flatMap(Refaster.anyOf(identity(), s -> s));
}

@AfterTemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static java.util.Comparator.comparingInt;
import static java.util.Comparator.reverseOrder;
import static java.util.function.Function.identity;
import static java.util.function.Predicate.not;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.filtering;
Expand Down Expand Up @@ -40,6 +41,7 @@ public ImmutableSet<Object> elidedTypesAndStaticImports() {
counting(),
filtering(null, null),
flatMapping(null, null),
identity(),
mapping(null, null),
maxBy(null),
minBy(null),
Expand Down Expand Up @@ -251,8 +253,9 @@ ImmutableSet<Integer> testStreamFlatMapCollect() {
return Stream.of(1).collect(flatMapping(n -> Stream.of(n, n), toImmutableSet()));
}

Stream<Integer> testStreamsConcat() {
return Stream.of(Stream.of(1), Stream.of(2), Stream.of(3), Stream.of(4))
.flatMap(Function.identity());
ImmutableSet<Stream<Integer>> testStreamsConcat() {
return ImmutableSet.of(
Stream.of(Stream.of(1), Stream.of(2)).flatMap(identity()),
Stream.of(Stream.of(3), Stream.of(4)).flatMap(v -> v));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static java.util.Comparator.comparingInt;
import static java.util.Comparator.naturalOrder;
import static java.util.Comparator.reverseOrder;
import static java.util.function.Function.identity;
import static java.util.function.Predicate.not;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.filtering;
Expand Down Expand Up @@ -42,6 +43,7 @@ public ImmutableSet<Object> elidedTypesAndStaticImports() {
counting(),
filtering(null, null),
flatMapping(null, null),
identity(),
mapping(null, null),
maxBy(null),
minBy(null),
Expand Down Expand Up @@ -252,7 +254,8 @@ ImmutableSet<Integer> testStreamFlatMapCollect() {
return Stream.of(1).flatMap(n -> Stream.of(n, n)).collect(toImmutableSet());
}

Stream<Integer> testStreamsConcat() {
return Streams.concat(Stream.of(1), Stream.of(2), Stream.of(3), Stream.of(4));
ImmutableSet<Stream<Integer>> testStreamsConcat() {
return ImmutableSet.of(
Streams.concat(Stream.of(1), Stream.of(2)), Streams.concat(Stream.of(3), Stream.of(4)));
}
}

0 comments on commit 78b0417

Please sign in to comment.