mirror of
https://github.com/jlengrand/error-prone-support.git
synced 2026-03-10 08:11:25 +00:00
Add templates for Gravitee migration
This commit is contained in:
committed by
Pieter Dirk Soels
parent
3d4ed4daa8
commit
edebc1a7d2
@@ -23,8 +23,11 @@ import io.reactivex.MaybeSource;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.flowables.GroupedFlowable;
|
||||
import io.reactivex.functions.Action;
|
||||
import io.reactivex.functions.BiFunction;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.functions.Predicate;
|
||||
import java.util.Collection;
|
||||
@@ -767,7 +770,7 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
|
||||
static final class FlowableFlatMap<I, T extends I, O, P extends Publisher<? extends O>> {
|
||||
@BeforeTemplate
|
||||
Flowable<O> before(Flowable<T> flowable, Function<I, P> function) {
|
||||
Flowable<O> before(Flowable<T> flowable, Function<? super I, ? extends Publisher<? extends O>> function) {
|
||||
return flowable.flatMap(function);
|
||||
}
|
||||
|
||||
@@ -791,6 +794,20 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
// XXX: final Flowable flatMap(Function,Function,Callable)
|
||||
// XXX: final Flowable flatMap(Function,Function,Callable,int)
|
||||
// XXX: final Flowable flatMap(Function,int)
|
||||
static final class FlowableFlatMapInt<I, T extends I, O, P extends Publisher<? extends O>> {
|
||||
@BeforeTemplate
|
||||
Flowable<O> before(Flowable<T> flowable, Function<? super I, ? extends Publisher<? extends O>> function, Integer i) {
|
||||
return flowable.flatMap(function, i);
|
||||
}
|
||||
|
||||
@UseImportPolicy(ImportPolicy.IMPORT_CLASS_DIRECTLY)
|
||||
@AfterTemplate
|
||||
Flowable<O> after(Flowable<I> flowable, Function<I, P> function, Integer i) {
|
||||
return RxJava2Adapter.fluxToFlowable(
|
||||
RxJava2Adapter.flowableToFlux(flowable)
|
||||
.flatMap(RxJavaReactorMigrationUtil.toJdkFunction(function), i));
|
||||
}
|
||||
}
|
||||
|
||||
static final class FlowableFlatMapCompletable<T, R extends CompletableSource> {
|
||||
@BeforeTemplate
|
||||
@@ -807,8 +824,7 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
x ->
|
||||
RxJava2Adapter.completableToMono(
|
||||
Completable.wrap(
|
||||
RxJavaReactorMigrationUtil.<T, R>toJdkFunction(function)
|
||||
.apply(x))))
|
||||
RxJavaReactorMigrationUtil.<T, R>toJdkFunction(function).apply(x))))
|
||||
.then());
|
||||
}
|
||||
}
|
||||
@@ -926,7 +942,24 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
}
|
||||
|
||||
// XXX: final Flowable flatMapMaybe(Function,boolean,int)
|
||||
// XXX: final Flowable flatMapSingle(Function)
|
||||
static final class FlowableFlatMapSingle<S, T extends S, R, P extends R, M extends Single<P>> {
|
||||
@BeforeTemplate
|
||||
Flowable<R> before(
|
||||
Flowable<T> flowable, Function<? super S, ? extends SingleSource<? extends R>> function) {
|
||||
return flowable.flatMapSingle(function);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Flowable<R> after(Flowable<T> flowable, Function<S, M> function) {
|
||||
return RxJava2Adapter.fluxToFlowable(
|
||||
RxJava2Adapter.flowableToFlux(flowable)
|
||||
.flatMap(
|
||||
e ->
|
||||
RxJava2Adapter.singleToMono(
|
||||
RxJavaReactorMigrationUtil.<S, M>toJdkFunction(function).apply(e))));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: final Flowable flatMapSingle(Function,boolean,int)
|
||||
// XXX: final Disposable forEach(Consumer)
|
||||
// XXX: final Disposable forEachWhile(Predicate)
|
||||
@@ -1179,10 +1212,81 @@ final class RxJavaFlowableToReactorTemplates {
|
||||
// XXX: final Flowable startWith(Object)
|
||||
// XXX: final Flowable startWith(Publisher)
|
||||
// XXX: final Flowable startWithArray(Object[])
|
||||
// XXX: final Disposable subscribe()
|
||||
// XXX: final Disposable subscribe(Consumer)
|
||||
// XXX: final Disposable subscribe(Consumer,Consumer)
|
||||
// XXX: final Disposable subscribe(Consumer,Consumer,Action)
|
||||
|
||||
// XXX: Test this.
|
||||
static final class FlowableSubscribe<T> {
|
||||
@BeforeTemplate
|
||||
Disposable before(Flowable<T> flowable) {
|
||||
return flowable.subscribe();
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
reactor.core.Disposable after(Flowable<T> flowable) {
|
||||
return RxJava2Adapter.flowableToFlux(flowable).subscribe();
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Test this.
|
||||
static final class FlowableSubscribeConsumer<T> {
|
||||
@BeforeTemplate
|
||||
Disposable before(Flowable<T> flowable, Consumer<? super T> consumer) {
|
||||
return flowable.subscribe(consumer);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
reactor.core.Disposable after(Flowable<T> flowable, Consumer<? super T> consumer) {
|
||||
return RxJava2Adapter.flowableToFlux(flowable)
|
||||
.subscribe(RxJavaReactorMigrationUtil.toJdkConsumer(consumer));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Test this.
|
||||
static final class FlowableSubscribeTwoConsumers<T> {
|
||||
@BeforeTemplate
|
||||
Disposable before(
|
||||
Flowable<T> flowable,
|
||||
Consumer<? super T> consumer1,
|
||||
Consumer<? super Throwable> consumer2) {
|
||||
return flowable.subscribe(consumer1, consumer2);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
reactor.core.Disposable after(
|
||||
Flowable<T> flowable,
|
||||
Consumer<? super T> consumer1,
|
||||
Consumer<? super Throwable> consumer2) {
|
||||
return RxJava2Adapter.flowableToFlux(flowable)
|
||||
.subscribe(
|
||||
RxJavaReactorMigrationUtil.toJdkConsumer(consumer1),
|
||||
RxJavaReactorMigrationUtil.toJdkConsumer(consumer2));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Test this.
|
||||
static final class FlowableSubscribeTwoConsumersWithAction<T> {
|
||||
@BeforeTemplate
|
||||
Disposable before(
|
||||
Flowable<T> flowable,
|
||||
Consumer<? super T> consumer1,
|
||||
Consumer<? super Throwable> consumer2,
|
||||
Action action) {
|
||||
return flowable.subscribe(consumer1, consumer2, action);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
reactor.core.Disposable after(
|
||||
Flowable<T> flowable,
|
||||
Consumer<? super T> consumer1,
|
||||
Consumer<? super Throwable> consumer2,
|
||||
Action action) {
|
||||
return RxJava2Adapter.flowableToFlux(flowable)
|
||||
.subscribe(
|
||||
RxJavaReactorMigrationUtil.toJdkConsumer(consumer1),
|
||||
RxJavaReactorMigrationUtil.toJdkConsumer(consumer2),
|
||||
RxJavaReactorMigrationUtil.toRunnable(action));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: final Disposable subscribe(Consumer,Consumer,Action,Consumer)
|
||||
// XXX: final void subscribe(FlowableSubscriber)
|
||||
// XXX: final void subscribe(Subscriber)
|
||||
|
||||
@@ -20,6 +20,7 @@ import io.reactivex.MaybeSource;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Action;
|
||||
import io.reactivex.functions.BiFunction;
|
||||
import io.reactivex.functions.Consumer;
|
||||
@@ -28,6 +29,7 @@ import io.reactivex.functions.Predicate;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.adapter.rxjava.RxJava2Adapter;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -490,8 +492,43 @@ final class RxJavaMaybeToReactorTemplates {
|
||||
}
|
||||
|
||||
// XXX: public final Observable flatMapObservable(Function)
|
||||
// XXX: public final Flowable flatMapPublisher(Function)
|
||||
// XXX: public final Single flatMapSingle(Function)
|
||||
|
||||
static final class MaybeFlatMapPublisher<T, O extends T, R extends Publisher<O>> {
|
||||
@BeforeTemplate
|
||||
Flowable<O> before(
|
||||
Maybe<T> maybe, Function<? super T, ? extends Publisher<? extends O>> function) {
|
||||
return maybe.flatMapPublisher(function);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Flowable<O> after(Maybe<T> maybe, Function<T, R> function) {
|
||||
return RxJava2Adapter.monoToFlowable(
|
||||
RxJava2Adapter.maybeToMono(maybe)
|
||||
.flatMap(
|
||||
y ->
|
||||
Mono.from(
|
||||
RxJavaReactorMigrationUtil.<T, R>toJdkFunction(function).apply(y))));
|
||||
}
|
||||
}
|
||||
|
||||
static final class MaybeFlatMapSingle<T, O extends T, R extends SingleSource<O>> {
|
||||
@BeforeTemplate
|
||||
Single<O> before(
|
||||
Maybe<T> maybe, Function<? super T, ? extends SingleSource<? extends O>> function) {
|
||||
return maybe.flatMapSingle(function);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Single<O> after(Maybe<T> maybe, Function<T, R> function) {
|
||||
return RxJava2Adapter.monoToSingle(
|
||||
RxJava2Adapter.maybeToMono(maybe)
|
||||
.flatMap(
|
||||
y ->
|
||||
RxJava2Adapter.singleToMono(
|
||||
Single.wrap(
|
||||
RxJavaReactorMigrationUtil.<T, R>toJdkFunction(function).apply(y)))));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: public final Maybe flatMapSingleElement(Function)
|
||||
// The following template is required to rewrite this code from platform:
|
||||
@@ -610,10 +647,71 @@ final class RxJavaMaybeToReactorTemplates {
|
||||
// XXX: public final Maybe retry(Predicate)
|
||||
// XXX: public final Maybe retryUntil(BooleanSupplier)
|
||||
// XXX: public final Maybe retryWhen(Function)
|
||||
// XXX: public final Disposable subscribe()
|
||||
// XXX: public final Disposable subscribe(Consumer)
|
||||
// XXX: public final Disposable subscribe(Consumer,Consumer)
|
||||
// XXX: public final Disposable subscribe(Consumer,Consumer,Action)
|
||||
|
||||
// XXX: Test this.
|
||||
static final class MaybeSubscribe<T> {
|
||||
@BeforeTemplate
|
||||
Disposable before(Maybe<T> maybe) {
|
||||
return maybe.subscribe();
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
reactor.core.Disposable after(Maybe<T> maybe) {
|
||||
return RxJava2Adapter.maybeToMono(maybe).subscribe();
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Test this.
|
||||
static final class MaybeSubscribeConsumer<T> {
|
||||
@BeforeTemplate
|
||||
Disposable before(Maybe<T> maybe, Consumer<? super T> consumer) {
|
||||
return maybe.subscribe(consumer);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
reactor.core.Disposable after(Maybe<T> maybe, Consumer<? super T> consumer) {
|
||||
return RxJava2Adapter.maybeToMono(maybe)
|
||||
.subscribe(RxJavaReactorMigrationUtil.toJdkConsumer(consumer));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Test this.
|
||||
static final class MaybeSubscribeTwoConsumers<T> {
|
||||
@BeforeTemplate
|
||||
Disposable before(
|
||||
Maybe<T> maybe, Consumer<? super T> consumer1, Consumer<? super Throwable> consumer2) {
|
||||
return maybe.subscribe(consumer1, consumer2);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
reactor.core.Disposable after(
|
||||
Maybe<T> maybe, Consumer<? super T> consumer1, Consumer<? super Throwable> consumer2) {
|
||||
return RxJava2Adapter.maybeToMono(maybe)
|
||||
.subscribe(
|
||||
RxJavaReactorMigrationUtil.toJdkConsumer(consumer1),
|
||||
RxJavaReactorMigrationUtil.toJdkConsumer(consumer2));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Test this.
|
||||
static final class MaybeSubscribeTwoConsumersWithAction<T> {
|
||||
@BeforeTemplate
|
||||
Disposable before(
|
||||
Maybe<T> maybe, Consumer<? super T> consumer1, Consumer<? super Throwable> consumer2, Action action) {
|
||||
return maybe.subscribe(consumer1, consumer2, action);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
reactor.core.Disposable after(
|
||||
Maybe<T> maybe, Consumer<? super T> consumer1, Consumer<? super Throwable> consumer2, Action action) {
|
||||
return RxJava2Adapter.maybeToMono(maybe)
|
||||
.subscribe(
|
||||
RxJavaReactorMigrationUtil.toJdkConsumer(consumer1),
|
||||
RxJavaReactorMigrationUtil.toJdkConsumer(consumer2),
|
||||
RxJavaReactorMigrationUtil.toRunnable(action));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: public final void subscribe(MaybeObserver)
|
||||
// XXX: public final Maybe subscribeOn(Scheduler)
|
||||
// XXX: public final MaybeObserver subscribeWith(MaybeObserver)
|
||||
|
||||
@@ -17,7 +17,6 @@ import io.reactivex.Maybe;
|
||||
import io.reactivex.MaybeSource;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.functions.Predicate;
|
||||
import java.util.concurrent.Callable;
|
||||
@@ -135,7 +134,19 @@ final class RxJavaObservableToReactorTemplates {
|
||||
// XXX: public static Observable fromFuture(Future,long,TimeUnit,Scheduler)
|
||||
// XXX: public static Observable fromFuture(Future,Scheduler)
|
||||
// XXX: public static Observable fromIterable(Iterable)
|
||||
// XXX: public static Observable fromPublisher(org.reactivestreams.Publisher)
|
||||
|
||||
static final class ObservableFromPublisher<T> {
|
||||
@BeforeTemplate
|
||||
Observable<T> before(Publisher<? extends T> source) {
|
||||
return Observable.fromPublisher(source);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Observable<T> after(Publisher<? extends T> source) {
|
||||
return RxJava2Adapter.fluxToObservable(Flux.from(source));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: public static Observable generate(Callable,BiConsumer)
|
||||
// XXX: public static Observable generate(Callable,BiConsumer,Consumer)
|
||||
// XXX: public static Observable generate(Callable,BiFunction)
|
||||
@@ -420,7 +431,8 @@ final class RxJavaObservableToReactorTemplates {
|
||||
z ->
|
||||
RxJava2Adapter.observableToFlux(
|
||||
Observable.wrap(
|
||||
RxJavaReactorMigrationUtil.<I, P>toJdkFunction(function).apply(z)), BackpressureStrategy.BUFFER)));
|
||||
RxJavaReactorMigrationUtil.<I, P>toJdkFunction(function).apply(z)),
|
||||
BackpressureStrategy.BUFFER)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,10 +449,37 @@ final class RxJavaObservableToReactorTemplates {
|
||||
// XXX: public final Observable flatMap(Function,int)
|
||||
// XXX: public final Completable flatMapCompletable(Function)
|
||||
// XXX: public final Completable flatMapCompletable(Function,boolean)
|
||||
// XXX: public final Observable flatMapIterable(Function)
|
||||
|
||||
static final class ObservableFromIterable<T> {
|
||||
@BeforeTemplate
|
||||
Observable<T> before(Iterable<? extends T> iterable) {
|
||||
return Observable.fromIterable(iterable);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Observable<T> after(Iterable<? extends T> iterable) {
|
||||
return RxJava2Adapter.fluxToObservable(Flux.fromIterable(iterable));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: public final Observable flatMapIterable(Function,BiFunction)
|
||||
// XXX: public final Observable flatMapMaybe(Function) <-- this one?
|
||||
// XXX: public final Observable flatMapMaybe(Function,boolean)
|
||||
|
||||
static final class ObservableFlatMapMaybe<T, R, O extends R, M extends MaybeSource<O>> {
|
||||
Observable<O> before(
|
||||
Observable<T> observable, Function<? super T, ? extends MaybeSource<? extends O>> mapper) {
|
||||
return observable.flatMapMaybe(mapper);
|
||||
}
|
||||
|
||||
Observable<O> after(Observable<T> observable, Function<T, M> mapper) {
|
||||
return RxJava2Adapter.fluxToObservable(
|
||||
RxJava2Adapter.observableToFlux(observable, BackpressureStrategy.BUFFER)
|
||||
.flatMap(
|
||||
t ->
|
||||
RxJava2Adapter.maybeToMono(
|
||||
Maybe.wrap(
|
||||
RxJavaReactorMigrationUtil.<T, M>toJdkFunction(mapper).apply(t)))));
|
||||
}
|
||||
} // XXX: public final Observable flatMapMaybe(Function,boolean)
|
||||
// XXX: public final Observable flatMapSingle(Function)
|
||||
// XXX: public final Observable flatMapSingle(Function,boolean)
|
||||
// XXX: public final Disposable forEach(Consumer)
|
||||
|
||||
@@ -17,14 +17,17 @@ import io.reactivex.Maybe;
|
||||
import io.reactivex.MaybeSource;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.BiFunction;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.functions.Predicate;
|
||||
import io.reactivex.observers.TestObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import java.util.concurrent.Callable;
|
||||
import org.reactivestreams.Publisher;
|
||||
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;
|
||||
@@ -112,7 +115,19 @@ final class RxJavaSingleToReactorTemplates {
|
||||
// XXX: public static Single fromFuture(Future,long,TimeUnit,Scheduler)
|
||||
// XXX: public static Single fromFuture(Future,Scheduler)
|
||||
// XXX: public static Single fromObservable(ObservableSource)
|
||||
// XXX: public static Single fromPublisher(Publisher)
|
||||
|
||||
static final class SingleFromPublisher<T> {
|
||||
@BeforeTemplate
|
||||
Single<T> before(Publisher<? extends T> source) {
|
||||
return Single.fromPublisher(source);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Single<T> after(Publisher<? extends T> source) {
|
||||
return RxJava2Adapter.monoToSingle(Mono.from(source));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static final class SingleJust<T> {
|
||||
@BeforeTemplate
|
||||
@@ -535,7 +550,7 @@ final class RxJavaSingleToReactorTemplates {
|
||||
|
||||
static final class SingleMap<I, T extends I, O> {
|
||||
@BeforeTemplate
|
||||
Single<O> before(Single<T> single, Function<I, O> function) {
|
||||
Single<O> before(Single<T> single, Function<? super I, ? extends O> function) {
|
||||
return single.map(function);
|
||||
}
|
||||
|
||||
@@ -581,18 +596,18 @@ final class RxJavaSingleToReactorTemplates {
|
||||
static final class SingleOnErrorResumeNext<
|
||||
S, T extends S, R, P extends Throwable, Q extends Single<T>> {
|
||||
@BeforeTemplate
|
||||
Single<T> before(Single<T> single, Function<? super Throwable, Q> function) {
|
||||
Single<T> before(Single<T> single, Function<? super Throwable, ? extends SingleSource<? extends T>> function) {
|
||||
return single.onErrorResumeNext(function);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Single<T> after(Single<T> single, Function<Throwable, Single<T>> function) {
|
||||
Single<T> after(Single<T> single, Function<Throwable, Q> function) {
|
||||
return RxJava2Adapter.monoToSingle(
|
||||
RxJava2Adapter.singleToMono(single)
|
||||
.onErrorResume(
|
||||
err ->
|
||||
RxJava2Adapter.singleToMono(
|
||||
RxJavaReactorMigrationUtil.<Throwable, Single<T>>toJdkFunction(function)
|
||||
RxJavaReactorMigrationUtil.<Throwable, Q>toJdkFunction(function)
|
||||
.apply(err))));
|
||||
}
|
||||
} // Why doesn't it add the <Throwable, Single<T>>???????
|
||||
@@ -628,15 +643,55 @@ final class RxJavaSingleToReactorTemplates {
|
||||
// XXX: public final Single retry(long)
|
||||
// XXX: public final Single retry(long,Predicate)
|
||||
// XXX: public final Single retry(Predicate)
|
||||
// XXX: public final Single retryWhen(Function)
|
||||
|
||||
// Can be skipped because of:
|
||||
// https://picnic.atlassian.net/browse/PRP-12237
|
||||
// XXX: public final Single retryWhen(Function)
|
||||
// XXX: Test this.
|
||||
static final class SingleSubscribe<T> {
|
||||
@BeforeTemplate
|
||||
Disposable before(Single<T> single) {
|
||||
return single.subscribe();
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
reactor.core.Disposable after(Single<T> single) {
|
||||
return RxJava2Adapter.singleToMono(single).subscribe();
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: public final Disposable subscribe()
|
||||
// XXX: public final Disposable subscribe(BiConsumer)
|
||||
// XXX: public final Disposable subscribe(Consumer)
|
||||
// XXX: public final Disposable subscribe(Consumer,Consumer)
|
||||
|
||||
// XXX: Test this.
|
||||
static final class SingleSubscribeConsumer<T> {
|
||||
@BeforeTemplate
|
||||
Disposable before(Single<T> single, Consumer<? super T> consumer) {
|
||||
return single.subscribe(consumer);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
reactor.core.Disposable after(Single<T> single, Consumer<? super T> consumer) {
|
||||
return RxJava2Adapter.singleToMono(single)
|
||||
.subscribe(RxJavaReactorMigrationUtil.toJdkConsumer(consumer));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Test this.
|
||||
static final class SingleSubscribeTwoConsumers<T> {
|
||||
@BeforeTemplate
|
||||
Disposable before(
|
||||
Single<T> single, Consumer<? super T> consumer1, Consumer<? super Throwable> consumer2) {
|
||||
return single.subscribe(consumer1, consumer2);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
reactor.core.Disposable after(
|
||||
Single<T> single, Consumer<? super T> consumer1, Consumer<? super Throwable> consumer2) {
|
||||
return RxJava2Adapter.singleToMono(single)
|
||||
.subscribe(
|
||||
RxJavaReactorMigrationUtil.toJdkConsumer(consumer1),
|
||||
RxJavaReactorMigrationUtil.toJdkConsumer(consumer2));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: public final void subscribe(SingleObserver)
|
||||
|
||||
// XXX: Not accounting for the Schedulers.computation()
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.errorprone.matchers.IsMethodReferenceOrLambdaHasReturnStatement;
|
||||
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.CanTransformToTargetType;
|
||||
import com.google.errorprone.refaster.annotation.NotMatches;
|
||||
import io.reactivex.BackpressureStrategy;
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.functions.Action;
|
||||
@@ -168,40 +170,42 @@ public final class RxJavaToReactorTemplates {
|
||||
|
||||
// XXX: @NotMatches(IsMethodReferenceOrLambdaHasReturnStatement.class) add this temporarily
|
||||
// and remove at end of migration.
|
||||
@SuppressWarnings("NoFunctionalReturnType")
|
||||
static final class UnnecessaryFunctionConversion<I, O> {
|
||||
@BeforeTemplate
|
||||
java.util.function.Function<I, O> before(@CanTransformToTargetType Function<I, O> function) {
|
||||
return Refaster.anyOf(
|
||||
// RxJavaReactorMigrationUtil.toJdkFunction((Function<I, O>) function), --> This
|
||||
// one gets us in non-compilable state.
|
||||
RxJavaReactorMigrationUtil.toJdkFunction(function));
|
||||
}
|
||||
|
||||
// XXX: Redundant cast to cover the case in which `function` is a method reference on which
|
||||
// `.apply` is invoked.
|
||||
// XXX: This happens e.g. in lambda expressions, but we can't seem to match those with
|
||||
// Refaster preventing simplification. Investigate.
|
||||
@AfterTemplate
|
||||
java.util.function.Function<I, O> after(java.util.function.Function<I, O> function) {
|
||||
return function;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("NoFunctionalReturnType")
|
||||
static final class UnnecessaryBiFunctionConversion<T, U, R> {
|
||||
@BeforeTemplate
|
||||
java.util.function.BiFunction<? super T, ? super U, ? extends R> before(
|
||||
@CanTransformToTargetType BiFunction<? super T, ? super U, ? extends R> zipper) {
|
||||
return RxJavaReactorMigrationUtil.toJdkBiFunction(zipper);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
java.util.function.BiFunction<? super T, ? super U, ? extends R> after(
|
||||
java.util.function.BiFunction<? super T, ? super U, ? extends R> zipper) {
|
||||
return zipper;
|
||||
}
|
||||
}
|
||||
// @SuppressWarnings("NoFunctionalReturnType")
|
||||
// static final class UnnecessaryFunctionConversion<I, O> {
|
||||
// @BeforeTemplate
|
||||
// java.util.function.Function<I, O> before(
|
||||
// @NotMatches(IsMethodReferenceOrLambdaHasReturnStatement.class) @CanTransformToTargetType
|
||||
// Function<I, O> function) {
|
||||
// return Refaster.anyOf(
|
||||
// // RxJavaReactorMigrationUtil.toJdkFunction((Function<I, O>) function), -->
|
||||
// // This one gets us in non-compilable state.
|
||||
// RxJavaReactorMigrationUtil.toJdkFunction(function));
|
||||
// }
|
||||
//
|
||||
// // XXX: Redundant cast to cover the case in which `function` is a method reference on which
|
||||
// // `.apply` is invoked.
|
||||
// // XXX: This happens e.g. in lambda expressions, but we can't seem to match those with
|
||||
// // Refaster preventing simplification. Investigate.
|
||||
// @AfterTemplate
|
||||
// java.util.function.Function<I, O> after(java.util.function.Function<I, O> function) {
|
||||
// return function;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings("NoFunctionalReturnType")
|
||||
// static final class UnnecessaryBiFunctionConversion<T, U, R> {
|
||||
// @BeforeTemplate
|
||||
// java.util.function.BiFunction<? super T, ? super U, ? extends R> before(
|
||||
// @CanTransformToTargetType BiFunction<? super T, ? super U, ? extends R> zipper) {
|
||||
// return RxJavaReactorMigrationUtil.toJdkBiFunction(zipper);
|
||||
// }
|
||||
//
|
||||
// @AfterTemplate
|
||||
// java.util.function.BiFunction<? super T, ? super U, ? extends R> after(
|
||||
// java.util.function.BiFunction<? super T, ? super U, ? extends R> zipper) {
|
||||
// return zipper;
|
||||
// }
|
||||
// }
|
||||
|
||||
@SuppressWarnings("NoFunctionalReturnType")
|
||||
static final class UnnecessaryConsumerConversion<T> {
|
||||
|
||||
Reference in New Issue
Block a user