mirror of
https://github.com/jlengrand/error-prone-support.git
synced 2026-03-10 15:49:33 +00:00
Add RxJavaUnwrapTemplates
This commit is contained in:
committed by
Pieter Dirk Soels
parent
a80ca8b0cd
commit
b45e5bf43d
@@ -27,6 +27,7 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import org.junit.After;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.adapter.rxjava.RxJava2Adapter;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -561,18 +562,21 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
static final class FlowableConcatMapMaybeDelayError<T, R> {
|
||||
@BeforeTemplate
|
||||
Flowable<R> before(
|
||||
Flowable<T> flowable, Function<? super T, ? extends MaybeSource<? extends R>> mapper) {
|
||||
return flowable.concatMapMaybeDelayError(mapper);
|
||||
Flowable<T> flowable, Function<? super T, ? extends MaybeSource<? extends R>> function) {
|
||||
return flowable.concatMapMaybeDelayError(function);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Flowable<R> after(
|
||||
Flowable<T> flowable, Function<? super T, ? extends MaybeSource<? extends R>> mapper) {
|
||||
Flowable<T> flowable, Function<? super T, ? extends MaybeSource<? extends R>> function) {
|
||||
return RxJava2Adapter.fluxToFlowable(
|
||||
RxJava2Adapter.flowableToFlux(flowable)
|
||||
.concatMapDelayError(
|
||||
e ->
|
||||
Maybe.wrap(RxJavaReactorMigrationUtil.toJdkFunction(mapper).apply(e))
|
||||
Maybe.wrap(
|
||||
RxJavaReactorMigrationUtil.toJdkFunction(
|
||||
(Function<T, MaybeSource<R>>) function)
|
||||
.apply(e))
|
||||
.toFlowable()));
|
||||
}
|
||||
}
|
||||
@@ -731,12 +735,13 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
|
||||
static final class FlowableFlatMapCompletable<T, R extends CompletableSource> {
|
||||
@BeforeTemplate
|
||||
Completable before(Flowable<T> flowable, Function<T, R> function) {
|
||||
Completable before(
|
||||
Flowable<T> flowable, Function<? super T, ? extends CompletableSource> function) {
|
||||
return flowable.flatMapCompletable(function);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(Flowable<T> flowable, Function<T, R> function) {
|
||||
Completable after(Flowable<T> flowable, Function<? super T, ? extends R> function) {
|
||||
return RxJava2Adapter.monoToCompletable(
|
||||
RxJava2Adapter.flowableToFlux(flowable)
|
||||
.flatMap(
|
||||
@@ -750,10 +755,11 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class FlowableUnwrapLambda<T> {
|
||||
abstract static class FlowableFlatMapCompletableUnwrapLambda<T> {
|
||||
@Placeholder
|
||||
abstract Mono<?> placeholder(@MayOptionallyUse T input);
|
||||
|
||||
// XXX: Perhaps: `? extends Publisher.....`
|
||||
@BeforeTemplate
|
||||
java.util.function.Function<T, Publisher<? extends Void>> before() {
|
||||
return e ->
|
||||
@@ -792,46 +798,8 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
// // XXX: Delete this/move it.
|
||||
// static final class XXXv1<I, O> {
|
||||
// @BeforeTemplate
|
||||
// Function<I, O> before(Function<I, O> function) {
|
||||
// return i -> function.apply(i);
|
||||
// }
|
||||
//
|
||||
// @BeforeTemplate
|
||||
// Function<I, O> before2(Function<I, O> function) {
|
||||
// return function::apply;
|
||||
// }
|
||||
//
|
||||
// @AfterTemplate
|
||||
// Function<I, O> after(Function<I, O> function) {
|
||||
// return function;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // XXX: Delete this/move it.
|
||||
// static final class XXXv2<I, O> {
|
||||
// @BeforeTemplate
|
||||
// // Or: @LambdaExprOrMethodReferenceReceiverEnsuresType
|
||||
// Function<I, O> before(Function<I, O> function) {
|
||||
// return Refaster.<Function<I, O>>receiverEnsuresType(i -> function.apply(i));
|
||||
// }
|
||||
//
|
||||
// @BeforeTemplate
|
||||
// Function<I, O> before2(Function<I, O> function) {
|
||||
// return function::apply;
|
||||
// }
|
||||
//
|
||||
// @AfterTemplate
|
||||
// Function<I, O> after(Function<I, O> function) {
|
||||
// return function;
|
||||
// }
|
||||
// }
|
||||
|
||||
// XXX: final Completable flatMapCompletable(Function,boolean,int)
|
||||
|
||||
// XXX: Test this one. Doesnt pick up one in bad-word-service.
|
||||
static final class FlowableFlatMapIterable<T, R> {
|
||||
@BeforeTemplate
|
||||
Flowable<R> before(
|
||||
@@ -852,7 +820,7 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
// XXX: final Flowable flatMapIterable(Function,BiFunction,int)
|
||||
// XXX: final Flowable flatMapIterable(Function,int)
|
||||
|
||||
static final class FlatMapMaybe<T, R> {
|
||||
static final class FlowableFlatMapMaybe<T, R> {
|
||||
@BeforeTemplate
|
||||
Flowable<R> before(
|
||||
Flowable<T> flowable, Function<? super T, ? extends MaybeSource<? extends R>> function) {
|
||||
@@ -868,7 +836,9 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
e ->
|
||||
RxJava2Adapter.maybeToMono(
|
||||
Maybe.wrap(
|
||||
RxJavaReactorMigrationUtil.toJdkFunction(function).apply(e)))));
|
||||
RxJavaReactorMigrationUtil.toJdkFunction(
|
||||
(Function<T, MaybeSource<R>>) function)
|
||||
.apply(e)))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -962,6 +932,30 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
// XXX: final Flowable onBackpressureLatest()
|
||||
// XXX: final Flowable onErrorResumeNext(Function) -> Required
|
||||
// XXX: final Flowable onErrorResumeNext(Publisher) -> Required? check consentTextServiceImpl
|
||||
|
||||
// @BeforeTemplate
|
||||
// Flowable<T> before(Flowable<T> flowable, Publisher<? extends T> publisher) {
|
||||
// return flowable.onErrorResumeNext(publisher);
|
||||
// }
|
||||
|
||||
static final class FlowableOnErrorResumeNext<T> {
|
||||
@BeforeTemplate
|
||||
Flowable<T> before(
|
||||
Flowable<T> flowable,
|
||||
Function<? super Throwable, ? extends Publisher<? extends T>> function) {
|
||||
return flowable.onErrorResumeNext(function);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Flowable<T> after(
|
||||
Flowable<T> flowable,
|
||||
Function<? super Throwable, ? extends Publisher<? extends T>> function) {
|
||||
return RxJava2Adapter.fluxToFlowable(
|
||||
RxJava2Adapter.flowableToFlux(flowable)
|
||||
.onErrorResume(RxJavaReactorMigrationUtil.toJdkFunction(function)));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: final Flowable onErrorReturn(Function) --> Required, ibanBlacklistServiceClient 60
|
||||
// XXX: final Flowable onErrorReturnItem(Object)
|
||||
// XXX: final Flowable onExceptionResumeNext(Publisher)
|
||||
|
||||
@@ -17,6 +17,7 @@ import io.reactivex.CompletableSource;
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.MaybeSource;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.functions.Action;
|
||||
@@ -512,23 +513,6 @@ final class RxJavaMaybeToReactorTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Discuss with Stephan. Still not useful for methodreferences.
|
||||
// abstract class MaybeUnwrapSingleElement<T, O> {
|
||||
// @BeforeTemplate
|
||||
// Maybe<O> after(
|
||||
// Maybe<T> maybe, Function<? super T, ? extends SingleSource<? extends O>> function) {
|
||||
// return RxJava2Adapter.monoToMaybe(
|
||||
// RxJava2Adapter.maybeToMono(maybe)
|
||||
// .flatMap(
|
||||
// e ->
|
||||
// RxJava2Adapter.singleToMono(
|
||||
// Single.wrap(
|
||||
// RxJavaReactorMigrationUtil.toJdkFunction(
|
||||
// (Function<T, SingleSource<O>>) function)
|
||||
// .apply(e)))));
|
||||
// }
|
||||
// }
|
||||
|
||||
// XXX: public final Flowable flattenAsFlowable(Function)
|
||||
// XXX: public final Observable flattenAsObservable(Function)
|
||||
// XXX: public final Maybe hide()
|
||||
@@ -653,7 +637,17 @@ final class RxJavaMaybeToReactorTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: public final Observable toObservable()
|
||||
static final class MaybeToObservable<T> {
|
||||
@BeforeTemplate
|
||||
Observable<T> before(Maybe<T> maybe) {
|
||||
return maybe.toObservable();
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Observable<T> after(Maybe<T> maybe) {
|
||||
return RxJava2Adapter.fluxToObservable(RxJava2Adapter.maybeToMono(maybe).flux());
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: This one should be improved, it is not correct yet.
|
||||
static final class MaybeToSingle<T> {
|
||||
@@ -755,21 +749,6 @@ final class RxJavaMaybeToReactorTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: The following two are combined often.
|
||||
// static final class MaybeTestAssertValueSet<T> {
|
||||
// @BeforeTemplate
|
||||
// void before(Maybe<T> maybe, Collection<? extends T> expected) throws InterruptedException {
|
||||
// maybe.test().await().assertValueSet(expected);
|
||||
// expected.it
|
||||
// }
|
||||
//
|
||||
// @AfterTemplate
|
||||
// void after(Maybe<T> maybe, Collection<? extends T> expected) {
|
||||
// RxJava2Adapter.maybeToMono(maybe).as(StepVerifier::create).expectNextMatches(t ->
|
||||
// ).verifyComplete();
|
||||
// }
|
||||
// }
|
||||
|
||||
static final class MaybeTestAssertValueCount<T> {
|
||||
@BeforeTemplate
|
||||
void before(Maybe<T> maybe, int count) throws InterruptedException {
|
||||
|
||||
@@ -15,8 +15,10 @@ import io.reactivex.Completable;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.functions.Predicate;
|
||||
import java.util.concurrent.Callable;
|
||||
import reactor.adapter.rxjava.RxJava2Adapter;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import tech.picnic.errorprone.migration.util.RxJavaReactorMigrationUtil;
|
||||
|
||||
@@ -105,15 +107,27 @@ final class RxJavaObservableToReactorTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: public static Observable error(Callable) --> Required
|
||||
// XXX: public static Observable error(Throwable) --> Required
|
||||
// XXX: public static Observable error(Callable)
|
||||
// XXX: public static Observable error(Throwable)
|
||||
// XXX: public static Observable fromArray(Object[])
|
||||
// XXX: public static Observable fromCallable(Callable) --> Required
|
||||
|
||||
static final class ObservableFromCallable<T> {
|
||||
@BeforeTemplate
|
||||
Observable<? extends T> before(Callable<? extends T> callable) {
|
||||
return Observable.fromCallable(callable);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Observable<? extends T> after(Callable<? extends T> callable) {
|
||||
return RxJava2Adapter.fluxToObservable(Mono.fromSupplier(RxJavaReactorMigrationUtil.callableAsSupplier(callable)).flux());
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: public static Observable fromFuture(Future)
|
||||
// XXX: public static Observable fromFuture(Future,long,TimeUnit)
|
||||
// XXX: public static Observable fromFuture(Future,long,TimeUnit,Scheduler)
|
||||
// XXX: public static Observable fromFuture(Future,Scheduler)
|
||||
// XXX: public static Observable fromIterable(Iterable) --> Required.
|
||||
// XXX: public static Observable fromIterable(Iterable)
|
||||
// XXX: public static Observable fromPublisher(org.reactivestreams.Publisher)
|
||||
// XXX: public static Observable generate(Callable,BiConsumer)
|
||||
// XXX: public static Observable generate(Callable,BiConsumer,Consumer)
|
||||
@@ -367,8 +381,8 @@ final class RxJavaObservableToReactorTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: public final Single firstOrError() --> This one maybe?
|
||||
// XXX: public final Observable flatMap(Function) --> Is suspect this one as well.
|
||||
// XXX: public final Single firstOrError()
|
||||
// XXX: public final Observable flatMap(Function)
|
||||
// XXX: public final Observable flatMap(Function,BiFunction)
|
||||
// XXX: public final Observable flatMap(Function,BiFunction,boolean)
|
||||
// XXX: public final Observable flatMap(Function,BiFunction,boolean,int)
|
||||
@@ -384,7 +398,7 @@ final class RxJavaObservableToReactorTemplates {
|
||||
// XXX: public final Completable flatMapCompletable(Function,boolean)
|
||||
// XXX: public final Observable flatMapIterable(Function)
|
||||
// XXX: public final Observable flatMapIterable(Function,BiFunction)
|
||||
// XXX: public final Observable flatMapMaybe(Function)
|
||||
// XXX: public final Observable flatMapMaybe(Function) <-- this one?
|
||||
// XXX: public final Observable flatMapMaybe(Function,boolean)
|
||||
// XXX: public final Observable flatMapSingle(Function)
|
||||
// XXX: public final Observable flatMapSingle(Function,boolean)
|
||||
@@ -437,7 +451,7 @@ final class RxJavaObservableToReactorTemplates {
|
||||
// XXX: public final Observable onErrorReturnItem(Object)
|
||||
// XXX: public final Observable onExceptionResumeNext(ObservableSource)
|
||||
// XXX: public final Observable onTerminateDetach()
|
||||
// XXX: public final ConnectableObservable publish() --> Required.
|
||||
// XXX: public final ConnectableObservable publish()
|
||||
// XXX: public final Observable publish(Function)
|
||||
// XXX: public final Maybe reduce(BiFunction)
|
||||
// XXX: public final Single reduce(Object,BiFunction)
|
||||
@@ -734,23 +748,6 @@ final class RxJavaObservableToReactorTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: The following two are combined often.
|
||||
// static final class ObservableTestAssertValueSet<T> {
|
||||
// @BeforeTemplate
|
||||
// void before(Observable<T> observable, Collection<? extends T> expected) throws
|
||||
// InterruptedException {
|
||||
// observable.test().await().assertValueSet(expected);
|
||||
// expected.it
|
||||
// }
|
||||
//
|
||||
// @AfterTemplate
|
||||
// void after(Observable<T> observable, Collection<? extends T> expected) {
|
||||
// RxJava2Adapter.observableToMono(observable).as(StepVerifier::create).expectNextMatches(t
|
||||
// ->
|
||||
// ).verifyComplete();
|
||||
// }
|
||||
// }
|
||||
|
||||
// XXX: Default BackpressureStrategy.BUFFER
|
||||
static final class ObservableTestAssertValueCount<T> {
|
||||
@BeforeTemplate
|
||||
|
||||
@@ -433,10 +433,7 @@ final class RxJavaSingleToReactorTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Test this one.
|
||||
// In this case it doesnt work: flatMap(e ->
|
||||
// RxJava2Adapter.maybeToMono(geocodingService::complete.apply(e))). (see before apply is an
|
||||
// error)
|
||||
// XXX: Test this one
|
||||
static final class SingleFlatMapMaybe<T, R> {
|
||||
@BeforeTemplate
|
||||
Maybe<R> before(
|
||||
@@ -452,29 +449,32 @@ final class RxJavaSingleToReactorTemplates {
|
||||
.flatMap(
|
||||
e ->
|
||||
RxJava2Adapter.maybeToMono(
|
||||
Maybe.wrap(RxJavaReactorMigrationUtil.toJdkFunction(mapper).apply(e)))));
|
||||
Maybe.wrap(
|
||||
RxJavaReactorMigrationUtil.toJdkFunction(
|
||||
(Function<T, MaybeSource<R>>) mapper)
|
||||
.apply(e)))));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Test this one.
|
||||
abstract static class SingleFlatMapMaybeUnwrapLambda<T, R> {
|
||||
@Placeholder
|
||||
abstract Mono<? extends R> placeholder(@MayOptionallyUse T input);
|
||||
|
||||
@BeforeTemplate
|
||||
java.util.function.Function<T, ? extends Mono<? extends R>> before() {
|
||||
return e ->
|
||||
RxJava2Adapter.maybeToMono(
|
||||
RxJavaReactorMigrationUtil.toJdkFunction(
|
||||
ident -> RxJava2Adapter.monoToMaybe(placeholder(e)))
|
||||
.apply(e));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
java.util.function.Function<T, ? extends Mono<? extends R>> after() {
|
||||
return v -> placeholder(v);
|
||||
}
|
||||
}
|
||||
// XXX: Test this one. (Disabled, created a better one (?) in RxJavaUnwrapTemplates.
|
||||
// abstract static class SingleFlatMapMaybeUnwrapLambda<T, R> {
|
||||
// @Placeholder
|
||||
// abstract Mono<? extends R> placeholder(@MayOptionallyUse T input);
|
||||
//
|
||||
// @BeforeTemplate
|
||||
// java.util.function.Function<T, ? extends Mono<? extends R>> before() {
|
||||
// return e ->
|
||||
// RxJava2Adapter.maybeToMono(
|
||||
// RxJavaReactorMigrationUtil.toJdkFunction(
|
||||
// ident -> RxJava2Adapter.monoToMaybe(placeholder(e)))
|
||||
// .apply(e));
|
||||
// }
|
||||
//
|
||||
// @AfterTemplate
|
||||
// java.util.function.Function<T, ? extends Mono<? extends R>> after() {
|
||||
// return v -> placeholder(v);
|
||||
// }
|
||||
// }
|
||||
|
||||
// XXX: public final Observable flatMapObservable(Function)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.google.errorprone.refaster.annotation.BeforeTemplate;
|
||||
import com.google.errorprone.refaster.annotation.CanTransformToTargetType;
|
||||
import com.google.errorprone.refaster.annotation.NotMatches;
|
||||
import io.reactivex.BackpressureStrategy;
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.functions.Action;
|
||||
import io.reactivex.functions.BiFunction;
|
||||
import io.reactivex.functions.Consumer;
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.errorprone.refaster.Refaster;
|
||||
import com.google.errorprone.refaster.annotation.AfterTemplate;
|
||||
import com.google.errorprone.refaster.annotation.BeforeTemplate;
|
||||
import com.google.errorprone.refaster.annotation.MayOptionallyUse;
|
||||
import com.google.errorprone.refaster.annotation.Placeholder;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.MaybeSource;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.functions.Function;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.adapter.rxjava.RxJava2Adapter;
|
||||
import reactor.core.publisher.Mono;
|
||||
import tech.picnic.errorprone.migration.util.RxJavaReactorMigrationUtil;
|
||||
|
||||
public final class RxJavaUnwrapTemplates {
|
||||
private RxJavaUnwrapTemplates() {}
|
||||
|
||||
abstract static class FlowableConcatMapCompletableUnwrapLambda<T> {
|
||||
@Placeholder
|
||||
abstract Mono<?> placeholder(@MayOptionallyUse T input);
|
||||
|
||||
@BeforeTemplate
|
||||
java.util.function.Function<? super T, ? extends Publisher<?>> before() {
|
||||
return e ->
|
||||
RxJava2Adapter.completableToMono(
|
||||
RxJavaReactorMigrationUtil.toJdkFunction(
|
||||
(T ident) -> RxJava2Adapter.monoToCompletable(placeholder(ident)))
|
||||
.apply(e));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
java.util.function.Function<T, ? extends Publisher<?>> after() {
|
||||
return v -> placeholder(v);
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class MaybeFlatMapUnwrapLambda<I, T extends I, O> {
|
||||
@Placeholder
|
||||
abstract Mono<? extends O> placeholder(@MayOptionallyUse T input);
|
||||
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.function.Function<? super T, ? extends Mono<? extends O>> before() {
|
||||
return v ->
|
||||
RxJava2Adapter.maybeToMono(
|
||||
(Maybe<O>)
|
||||
RxJavaReactorMigrationUtil.toJdkFunction(
|
||||
(T ident) -> RxJava2Adapter.monoToMaybe(placeholder(ident)))
|
||||
.apply(v));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
java.util.function.Function<? super T, ? extends Mono<? extends O>> after() {
|
||||
return v -> placeholder(v);
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class MaybeFlatMapSingleElementUnwrapLambda<T, R> {
|
||||
@Placeholder
|
||||
abstract Mono<R> placeholder(@MayOptionallyUse T input);
|
||||
|
||||
@BeforeTemplate
|
||||
java.util.function.Function<T, ? extends Mono<? extends R>> before() {
|
||||
return e ->
|
||||
RxJava2Adapter.singleToMono(
|
||||
Single.wrap(
|
||||
RxJavaReactorMigrationUtil.toJdkFunction(
|
||||
(Function<T, SingleSource<R>>)
|
||||
(T ident) -> RxJava2Adapter.monoToSingle(placeholder(ident)))
|
||||
.apply(e)));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
java.util.function.Function<T, ? extends Mono<? extends R>> after() {
|
||||
return e -> placeholder(e);
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class SingleFlatMapMaybeUnwrapLambda<T, R> {
|
||||
@Placeholder
|
||||
abstract Mono<R> placeholder(@MayOptionallyUse T input);
|
||||
|
||||
@BeforeTemplate
|
||||
java.util.function.Function<? super T, ? extends Mono<? extends R>> before() {
|
||||
return Refaster.anyOf(
|
||||
e ->
|
||||
RxJava2Adapter.maybeToMono(
|
||||
Maybe.wrap(
|
||||
RxJavaReactorMigrationUtil.toJdkFunction(
|
||||
(Function<T, MaybeSource<R>>)
|
||||
(T ident) -> RxJava2Adapter.monoToMaybe(placeholder(ident)))
|
||||
.apply(e))),
|
||||
e ->
|
||||
RxJava2Adapter.maybeToMono(
|
||||
Maybe.wrap(
|
||||
RxJavaReactorMigrationUtil.toJdkFunction(
|
||||
(Function<T, MaybeSource<R>>)
|
||||
ident -> RxJava2Adapter.monoToMaybe(placeholder(ident)))
|
||||
.apply(e))));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
java.util.function.Function<? super T, ? extends Mono<? extends R>> after() {
|
||||
return e -> placeholder(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ final class RxJavaFlowableToReactorTemplatesTest implements RefasterTemplateTest
|
||||
return Flowable.just(1).concatMapMaybeDelayError(Maybe::just);
|
||||
}
|
||||
|
||||
Flowable<Integer> testFlatMapMaybe() {
|
||||
Flowable<Integer> testFlowableFlatMapMaybe() {
|
||||
return Flowable.just(1).flatMapMaybe(Maybe::just);
|
||||
}
|
||||
|
||||
@@ -175,6 +175,10 @@ final class RxJavaFlowableToReactorTemplatesTest implements RefasterTemplateTest
|
||||
return Flowable.just(1).mergeWith(Single.just(1));
|
||||
}
|
||||
|
||||
Flowable<Integer> testFlowableOnErrorResumeNext() {
|
||||
return Flowable.just(1).onErrorResumeNext((Throwable throwable) -> Flux.just(1));
|
||||
}
|
||||
|
||||
Single<Integer> testFlowableSingleDefault() {
|
||||
return Flowable.just(1).single(2);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ final class RxJavaFlowableToReactorTemplatesTest implements RefasterTemplateTest
|
||||
.toFlowable()));
|
||||
}
|
||||
|
||||
Flowable<Integer> testFlatMapMaybe() {
|
||||
Flowable<Integer> testFlowableFlatMapMaybe() {
|
||||
return RxJava2Adapter.fluxToFlowable(
|
||||
RxJava2Adapter.flowableToFlux(Flowable.just(1))
|
||||
.flatMap(
|
||||
|
||||
@@ -153,6 +153,10 @@ final class RxJavaMaybeToReactorTemplatesTest implements RefasterTemplateTestCas
|
||||
return Maybe.just(1).toFlowable();
|
||||
}
|
||||
|
||||
Completable<Integer> testMaybeToObservable() {
|
||||
return Maybe.just(1).toObservable();
|
||||
}
|
||||
|
||||
@SuppressWarnings("MaybeJust")
|
||||
private Maybe<Integer> getMaybe() {
|
||||
return Maybe.just(3);
|
||||
|
||||
Reference in New Issue
Block a user