T
- the type of the returning objectpublic class ServiceFuture<T>
extends com.google.common.util.concurrent.AbstractFuture<T>
Modifier | Constructor and Description |
---|---|
protected |
ServiceFuture() |
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
static ServiceFuture<Void> |
fromBody(rx.Completable completable,
ServiceCallback<Void> callback)
Creates a ServiceFuture from an Completable object and a callback.
|
static <T> ServiceFuture<T> |
fromBody(rx.Observable<T> observable,
ServiceCallback<T> callback)
Creates a ServiceFuture from an observable object and a callback.
|
static <T,V> ServiceFuture<T> |
fromHeaderResponse(rx.Observable<ServiceResponseWithHeaders<T,V>> observable,
ServiceCallback<T> callback)
Creates a ServiceCall from an observable and a callback for a header response.
|
static <T> ServiceFuture<T> |
fromResponse(rx.Observable<ServiceResponse<T>> observable)
Creates a ServiceCall from an observable object.
|
static <T> ServiceFuture<T> |
fromResponse(rx.Observable<ServiceResponse<T>> observable,
ServiceCallback<T> callback)
Creates a ServiceCall from an observable object and a callback.
|
rx.Subscription |
getSubscription() |
boolean |
isCancelled() |
protected void |
setSubscription(rx.Subscription subscription) |
boolean |
success(T result)
Invoke this method to report completed, allowing
AbstractFuture.get() to be unblocked. |
public static <T> ServiceFuture<T> fromResponse(rx.Observable<ServiceResponse<T>> observable)
T
- the type of the responseobservable
- the observable to create frompublic static <T> ServiceFuture<T> fromResponse(rx.Observable<ServiceResponse<T>> observable, ServiceCallback<T> callback)
T
- the type of the responseobservable
- the observable to create fromcallback
- the callback to call when events happenpublic static <T> ServiceFuture<T> fromBody(rx.Observable<T> observable, ServiceCallback<T> callback)
T
- the type of the responseobservable
- the observable to create fromcallback
- the callback to call when events happenpublic static ServiceFuture<Void> fromBody(rx.Completable completable, ServiceCallback<Void> callback)
completable
- the completable to create fromcallback
- the callback to call when event happenpublic static <T,V> ServiceFuture<T> fromHeaderResponse(rx.Observable<ServiceResponseWithHeaders<T,V>> observable, ServiceCallback<T> callback)
T
- the type of the response bodyV
- the type of the response headerobservable
- the observable of a REST call that returns JSON in a headercallback
- the callback to call when events happenpublic rx.Subscription getSubscription()
protected void setSubscription(rx.Subscription subscription)
public boolean success(T result)
AbstractFuture.get()
to be unblocked.result
- the service response returned.public boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled
in interface Future<T>
isCancelled
in class com.google.common.util.concurrent.AbstractFuture<T>
Copyright © 2019. All rights reserved.