All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twilio.base.Updater Maven / Gradle / Ivy

package com.twilio.base;

import com.google.common.util.concurrent.ListenableFuture;
import com.twilio.Twilio;
import com.twilio.http.TwilioRestClient;

import java.util.concurrent.Callable;

/**
 * Executor for updates of a resource.
 *
 * @param  type of the resource
 */
public abstract class Updater {

    /**
     * Execute an async request using default client.
     *
     * @return future that resolves to requested object
     */
    public ListenableFuture updateAsync() {
        return updateAsync(Twilio.getRestClient());
    }

    /**
     * Execute an async request using specified client.
     *
     * @param client client used to make request
     * @return future that resolves to requested object
     */
    public ListenableFuture updateAsync(final TwilioRestClient client) {
        return Twilio.getExecutorService().submit(new Callable() {
            public T call() {
                return update(client);
            }
        });
    }

    /**
     * Execute a request using default client.
     *
     * @return Requested object
     */
    public T update() {
        return update(Twilio.getRestClient());
    }

    /**
     * Execute a request using specified client.
     *
     * @param client client used to make request
     * @return Requested object
     */
    public abstract T update(final TwilioRestClient client);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy