public class MaybeHelper extends Object
| Constructor and Description |
|---|
MaybeHelper() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Maybe<T> |
toMaybe(Consumer<Handler<AsyncResult<T>>> handler)
Returns a
Maybe that, when subscribed, uses the provided handler to adapt a callback-based asynchronous method. |
static <T> MaybeObserver<T> |
toObserver(Handler<AsyncResult<T>> handler)
Adapts an Vert.x
Handler<AsyncResult<T>> to an RxJava2 MaybeObserver. |
static <T> MaybeTransformer<Buffer,T> |
unmarshaller(Class<T> mappedType) |
static <T> MaybeTransformer<Buffer,T> |
unmarshaller(Class<T> mappedType,
ObjectMapper mapper) |
static <T> MaybeTransformer<Buffer,T> |
unmarshaller(TypeReference<T> mappedTypeRef) |
static <T> MaybeTransformer<Buffer,T> |
unmarshaller(TypeReference<T> mappedTypeRef,
ObjectMapper mapper) |
public static <T> Maybe<T> toMaybe(Consumer<Handler<AsyncResult<T>>> handler)
Maybe that, when subscribed, uses the provided handler 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.
handler - the code executed when the returned Maybe is subscribedpublic static <T> MaybeObserver<T> toObserver(Handler<AsyncResult<T>> handler)
Handler<AsyncResult<T>> to an RxJava2 MaybeObserver.
The returned observer can be subscribed to an Maybe.subscribe(MaybeObserver).
handler - the handler to adaptpublic static <T> MaybeTransformer<Buffer,T> unmarshaller(Class<T> mappedType)
public static <T> MaybeTransformer<Buffer,T> unmarshaller(TypeReference<T> mappedTypeRef)
public static <T> MaybeTransformer<Buffer,T> unmarshaller(Class<T> mappedType, ObjectMapper mapper)
public static <T> MaybeTransformer<Buffer,T> unmarshaller(TypeReference<T> mappedTypeRef, ObjectMapper mapper)
Copyright © 2020. All rights reserved.