-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce {Mono,Flux}DefaultIfEmpty
Refaster rules
#370
Conversation
Looks good. No mutations were possible for these changes. |
2 similar comments
Looks good. No mutations were possible for these changes. |
Looks good. No mutations were possible for these changes. |
Hey @giall ! Nice that you opened the PR! I forgot to update the base branch back to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a commit.
@@ -264,6 +264,32 @@ Flux<T> after(Flux<T> flux, long n) { | |||
} | |||
} | |||
|
|||
/** Prefer {@link Mono#defaultIfEmpty(Object)} over more contrived alternatives. */ | |||
static final class MonoSwitchIfEmptyOfMonoJust<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we name the rules after the preferred expression:
static final class MonoSwitchIfEmptyOfMonoJust<T> { | |
static final class MonoDefaultIfEmpty<T> { |
/** Prefer {@link Mono#defaultIfEmpty(Object)} over more contrived alternatives. */ | ||
static final class MonoSwitchIfEmptyOfMonoJust<T> { | ||
@BeforeTemplate | ||
Mono<T> before(Mono<T> mono, T object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
object
may be a subtype of T
, but I see that in either case Refaster matches correctly (didn't commit the test changes, but the point is that this expression is rewritten as well:
Flux.<Object>just("X").switchIfEmpty(Mono.just(1))
Suggested commit message:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice @giall 馃挭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this up :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice @giall congrats on your first PR 馃殌 !
Suggested commit message LGTM!
1c3d64e
to
27a5d01
Compare
Rebased. Will merge once 馃煝. |
27a5d01
to
4baeda5
Compare
switchIfEmpty({Mono|Flux}.just(...))
using defaultIfEmpty
{Mono,Flux}DefaultIfEmpty
Refaster rules
Saw "good first issue" and could not help myself 馃槃
Issue: #363
Would like some suggestions on the rule names, not too happy with
FluxSwitchIfEmptyOfMonoOrFluxJust
especially.