Package io.vertx.reactivex
Class MaybeHelper
- java.lang.Object
-
- io.vertx.reactivex.MaybeHelper
-
public class MaybeHelper extends Object
- Author:
- Julien Viet
-
-
Constructor Summary
Constructors Constructor Description MaybeHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Future<T>
toFuture(Maybe<T> maybe)
Adapts an RxJava2Maybe<T>
to a Vert.xFuture
.static <T,U>
Future<U>toFuture(Maybe<T> maybe, java.util.function.Function<T,U> adapter)
LiketoFuture(Maybe)
but with anadapter
of the result.static <T> Maybe<T>
toMaybe(java.util.function.Consumer<Handler<AsyncResult<T>>> handler)
Returns aMaybe
that, when subscribed, uses the providedhandler
to adapt a callback-based asynchronous method.static <T> MaybeObserver<T>
toObserver(Handler<AsyncResult<T>> handler)
Adapts an Vert.xHandler<AsyncResult<T>>
to an RxJava2MaybeObserver
.static <T> MaybeTransformer<Buffer,T>
unmarshaller(TypeReference<T> mappedTypeRef)
static <T> MaybeTransformer<Buffer,T>
unmarshaller(TypeReference<T> mappedTypeRef, ObjectCodec mapper)
static <T> MaybeTransformer<Buffer,T>
unmarshaller(Class<T> mappedType)
static <T> MaybeTransformer<Buffer,T>
unmarshaller(Class<T> mappedType, ObjectCodec mapper)
-
-
-
Method Detail
-
toMaybe
public static <T> Maybe<T> toMaybe(java.util.function.Consumer<Handler<AsyncResult<T>>> handler)
Returns aMaybe
that, when subscribed, uses the providedhandler
to adapt a callback-based asynchronous method.For example:
io.vertx.core.Vertx vertx = Vertx.vertx(); Maybe<String> blockingMethodResult = MaybeHelper.toMaybe(handler -> vertx.<String>executeBlocking(fut -> fut.complete(invokeBlocking()), handler));
This is useful when using RxJava without the Vert.x Rxified API or your own asynchronous methods.
- Parameters:
handler
- the code executed when the returnedMaybe
is subscribed
-
toObserver
public static <T> MaybeObserver<T> toObserver(Handler<AsyncResult<T>> handler)
Adapts an Vert.xHandler<AsyncResult<T>>
to an RxJava2MaybeObserver
.The returned observer can be subscribed to an
Maybe.subscribe(MaybeObserver)
.- Parameters:
handler
- the handler to adapt- Returns:
- the observer
-
toFuture
public static <T> Future<T> toFuture(Maybe<T> maybe)
Adapts an RxJava2Maybe<T>
to a Vert.xFuture
.The maybe will be immediately subscribed and the returned future will be updated with the result of the single.
- Parameters:
maybe
- the single to adapt- Returns:
- the future
-
toFuture
public static <T,U> Future<U> toFuture(Maybe<T> maybe, java.util.function.Function<T,U> adapter)
LiketoFuture(Maybe)
but with anadapter
of the result.
-
unmarshaller
public static <T> MaybeTransformer<Buffer,T> unmarshaller(Class<T> mappedType)
-
unmarshaller
public static <T> MaybeTransformer<Buffer,T> unmarshaller(TypeReference<T> mappedTypeRef)
-
unmarshaller
public static <T> MaybeTransformer<Buffer,T> unmarshaller(Class<T> mappedType, ObjectCodec mapper)
-
unmarshaller
public static <T> MaybeTransformer<Buffer,T> unmarshaller(TypeReference<T> mappedTypeRef, ObjectCodec mapper)
-
-