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

com.longport.AsyncCallback Maven / Gradle / Ivy

There is a newer version: 2.1.5
Show newest version
package com.longport;

import java.util.concurrent.CompletableFuture;

/**
 * @hidden
 */
public interface AsyncCallback {
    public void callback(Object err, Object obj);

    public static interface AsyncTask {
        void run(AsyncCallback callback);
    }

    @SuppressWarnings("unchecked")
    public static  CompletableFuture executeTask(AsyncTask task) {
        CompletableFuture fut = new CompletableFuture();
        task.run((err, obj) -> {
            if (err == null) {
                fut.complete((T) obj);
            } else {
                fut.completeExceptionally((Throwable) err);
            }
        });
        return fut;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy