Add support for RxJava 2 Maybe type

Issue: SPR-14843
This commit is contained in:
Sebastien Deleuze
2016-10-25 16:41:25 +02:00
parent 20dec61d04
commit 2075932780
6 changed files with 77 additions and 2 deletions

View File

@@ -25,6 +25,7 @@ import java.util.function.Predicate;
import io.reactivex.BackpressureStrategy;
import io.reactivex.Flowable;
import io.reactivex.Maybe;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -43,6 +44,7 @@ import org.springframework.util.ClassUtils;
* registered via {@link #registerFluxAdapter} and {@link #registerMonoAdapter}.
*
* @author Rossen Stoyanchev
* @author Sebastien Deleuze
* @since 5.0
*/
public class ReactiveAdapterRegistry {
@@ -296,6 +298,11 @@ public class ReactiveAdapterRegistry {
source -> Flowable.fromPublisher(source).toObservable().singleElement().toSingle(),
new ReactiveAdapter.Descriptor(false, false, false)
);
registry.registerMonoAdapter(Maybe.class,
source -> Mono.from(((Maybe<?>) source).toFlowable()),
source -> Flowable.fromPublisher(source).toObservable().singleElement(),
new ReactiveAdapter.Descriptor(false, true, false)
);
registry.registerMonoAdapter(io.reactivex.Completable.class,
source -> Mono.from(((io.reactivex.Completable) source).toFlowable()),
source -> Flowable.fromPublisher(source).toObservable().ignoreElements(),