Package com.microsoft.rest
Class ServiceFuture<T>
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractFuture<T>
-
- com.microsoft.rest.ServiceFuture<T>
-
- Type Parameters:
T- the type of the returning object
- All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<T>,Future<T>
public class ServiceFuture<T> extends com.google.common.util.concurrent.AbstractFuture<T>An instance of this class provides access to the underlying REST call invocation. This class wraps around the Retrofit Call object and allows updates to it in the progress of a long running operation or a paging operation.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedServiceFuture()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel(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.SubscriptiongetSubscription()booleanisCancelled()protected voidsetSubscription(rx.Subscription subscription)booleansuccess(T result)Invoke this method to report completed, allowingAbstractFuture.get()to be unblocked.
-
-
-
Method Detail
-
fromResponse
public static <T> ServiceFuture<T> fromResponse(rx.Observable<ServiceResponse<T>> observable)
Creates a ServiceCall from an observable object.- Type Parameters:
T- the type of the response- Parameters:
observable- the observable to create from- Returns:
- the created ServiceCall
-
fromResponse
public static <T> ServiceFuture<T> fromResponse(rx.Observable<ServiceResponse<T>> observable, ServiceCallback<T> callback)
Creates a ServiceCall from an observable object and a callback.- Type Parameters:
T- the type of the response- Parameters:
observable- the observable to create fromcallback- the callback to call when events happen- Returns:
- the created ServiceCall
-
fromBody
public static <T> ServiceFuture<T> fromBody(rx.Observable<T> observable, ServiceCallback<T> callback)
Creates a ServiceFuture from an observable object and a callback.- Type Parameters:
T- the type of the response- Parameters:
observable- the observable to create fromcallback- the callback to call when events happen- Returns:
- the created ServiceFuture
-
fromBody
public static ServiceFuture<Void> fromBody(rx.Completable completable, ServiceCallback<Void> callback)
Creates a ServiceFuture from an Completable object and a callback.- Parameters:
completable- the completable to create fromcallback- the callback to call when event happen- Returns:
- the created ServiceFuture
-
fromHeaderResponse
public 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.- Type Parameters:
T- the type of the response bodyV- the type of the response header- Parameters:
observable- the observable of a REST call that returns JSON in a headercallback- the callback to call when events happen- Returns:
- the created ServiceCall
-
getSubscription
public rx.Subscription getSubscription()
- Returns:
- the current Rx subscription associated with the ServiceCall.
-
setSubscription
protected void setSubscription(rx.Subscription subscription)
-
success
public boolean success(T result)
Invoke this method to report completed, allowingAbstractFuture.get()to be unblocked.- Parameters:
result- the service response returned.- Returns:
- true if successfully reported; false otherwise.
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfaceFuture<T>- Overrides:
isCancelledin classcom.google.common.util.concurrent.AbstractFuture<T>
-
-