/**
 *
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 *
 */

package com.microsoft.rest;

import retrofit2.Call;

/**
 * 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.
 */
public class ServiceCall {
    /**
     * The Retrofit method invocation.
     */
    private Call<?> call;

    /**
     * Creates an instance of ServiceCall.
     *
     * @param call the Retrofit call to wrap around.
     */
    public ServiceCall(Call<?> call) {
        this.call = call;
    }

    /**
     * Updates the current Retrofit call object.
     *
     * @param call the new call object.
     */
    public void newCall(Call<?> call) {
        this.call = call;
    }

    /**
     * Gets the current Retrofit call object.
     *
     * @return the current call object.
     */
    public Call<?> getCall() {
        return call;
    }

    /**
     * Cancel the Retrofit call if possible.
     */
    public void cancel() {
        call.cancel();
    }

    /**
     * If the Retrofit call has been canceled.
     *
     * @return true if the call has been canceled; false otherwise.
     */
    public boolean isCanceled() {
        return call.isCanceled();
    }
}

@@ -194,16 +194,74 @@
 .rest;%0A%0A
+import com.google.common.util.concurrent.AbstractFuture;%0A%0A
 import r
@@ -518,34 +518,113 @@
 .%0A *
-/%0Apublic class ServiceCall
+%0A * @param %3CT%3E the type of the returning object%0A */%0Apublic class ServiceCall%3CT%3E extends AbstractFuture%3CT%3E
  %7B%0A 
@@ -1577,11 +1577,643 @@
 );%0A    %7D
+%0A%0A    /**%0A     * Invoke this method to report completed, allowing%0A     * %7B@link AbstractFuture#get()%7D to be unblocked.%0A     *%0A     * @param result the object returned.%0A     * @return true if successfully reported; false otherwise.%0A     */%0A    public boolean success(T result) %7B%0A        return set(result);%0A    %7D%0A%0A    /**%0A     * Invoke this method to report a failure, allowing%0A     * %7B@link AbstractFuture#get()%7D to throw the exception.%0A     *%0A     * @param t the exception thrown.%0A     * @return true if successfully reported; false otherwise.%0A     */%0A    public boolean failure(Throwable t) %7B%0A        return setException(t);%0A    %7D
 %0A%7D%0A

Make ServiceCall Future-like