diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java index f4a64b61ee..b7017340bc 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java @@ -701,12 +701,12 @@ static final class MonoThen { /** Prefer {@link Mono#singleOptional()} over more contrived alternatives. */ // XXX: Consider creating a plugin that flags/discourages `Mono>` method return // types, just as we discourage nullable `Boolean`s and `Optional`s. - static final class MonoCollectToOptional { + static final class MonoSingleOptional { @BeforeTemplate Mono> before(Mono mono) { return Refaster.anyOf( - mono.map(Optional::of).defaultIfEmpty(Optional.empty()), - mono.flux().collect(toOptional())); + mono.flux().collect(toOptional()), + mono.map(Optional::of).defaultIfEmpty(Optional.empty())); } @AfterTemplate diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java index 719a73e4ff..02a3abad19 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java @@ -230,7 +230,7 @@ Mono testMonoThen() { return Mono.just("foo").flux().then(); } - ImmutableSet>> testMonoCollectToOptional() { + ImmutableSet>> testMonoSingleOptional() { return ImmutableSet.of( Mono.just("foo").map(Optional::of).defaultIfEmpty(Optional.empty()), Mono.just("bar").flux().collect(toOptional())); diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java index e95f3297a8..fee65bae6b 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java @@ -224,7 +224,7 @@ Mono testMonoThen() { return Mono.just("foo").then(); } - ImmutableSet>> testMonoCollectToOptional() { + ImmutableSet>> testMonoSingleOptional() { return ImmutableSet.of(Mono.just("foo").singleOptional(), Mono.just("bar").singleOptional()); }