Skip to content

Commit

Permalink
Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 authored and rickie committed Dec 5, 2022
1 parent 0396284 commit 27f5312
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Mono<T> after(Supplier<? extends T> supplier) {
static final class MonoEmpty<T> {
@BeforeTemplate
Mono<T> before() {
return Refaster.anyOf(Mono.just(null), Mono.justOrEmpty(null));
return Refaster.anyOf(Mono.justOrEmpty(null), Mono.justOrEmpty(Optional.empty()));
}

@AfterTemplate
Expand All @@ -73,16 +73,28 @@ Mono<T> after() {
}
}

/** Prefer {@link Mono#justOrEmpty(Optional)} over more contrived alternatives. */
static final class MonoJustOrEmpty<T> {
/** Prefer {@link Mono#just(Object)} over more contrived alternatives. */
static final class MonoJust<T> {
@BeforeTemplate
@SuppressWarnings("NullAway")
Mono<T> before(@Nullable T value) {
return Mono.justOrEmpty(Refaster.anyOf(Optional.of(value), Optional.ofNullable(value)));
Mono<T> before(T value) {
return Mono.justOrEmpty(Optional.of(value));
}

@AfterTemplate
Mono<T> after(@Nullable T value) {
Mono<T> after(T value) {
return Mono.just(value);
}
}

/** Prefer {@link Mono#justOrEmpty(Object)} over more contrived alternatives. */
static final class MonoJustOrEmpty<@Nullable T> {
@BeforeTemplate
Mono<T> before(T value) {
return Mono.justOrEmpty(Optional.ofNullable(value));
}

@AfterTemplate
Mono<T> after(T value) {
return Mono.justOrEmpty(value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ ImmutableSet<Mono<?>> testMonoFromSupplier() {
}

ImmutableSet<Mono<String>> testMonoEmpty() {
return ImmutableSet.of(Mono.just(null), Mono.justOrEmpty(null));
return ImmutableSet.of(Mono.justOrEmpty(null), Mono.justOrEmpty(Optional.empty()));
}

ImmutableSet<Mono<Integer>> testMonoJustOrEmpty() {
return ImmutableSet.of(
Mono.justOrEmpty(Optional.of(1)), Mono.justOrEmpty(Optional.ofNullable(2)));
Mono<Integer> testMonoJust() {
return Mono.justOrEmpty(Optional.of(1));
}

Mono<Integer> testMonoJustOrEmpty() {
return Mono.justOrEmpty(Optional.ofNullable(1));
}

ImmutableSet<Mono<Integer>> testMonoFromOptional() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ ImmutableSet<Mono<String>> testMonoEmpty() {
return ImmutableSet.of(Mono.empty(), Mono.empty());
}

ImmutableSet<Mono<Integer>> testMonoJustOrEmpty() {
return ImmutableSet.of(Mono.justOrEmpty(1), Mono.justOrEmpty(2));
Mono<Integer> testMonoJust() {
return Mono.just(1);
}

Mono<Integer> testMonoJustOrEmpty() {
return Mono.justOrEmpty(1);
}

ImmutableSet<Mono<Integer>> testMonoFromOptional() {
Expand Down

0 comments on commit 27f5312

Please sign in to comment.