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

com.firefly.utils.concurrent.Promise Maven / Gradle / Ivy

There is a newer version: 4.0.3.2
Show newest version
package com.firefly.utils.concurrent;

/**
 * 

* A callback abstraction that handles completed/failed events of asynchronous * operations. *

* * @param * the type of the context object */ public interface Promise { /** *

* Callback invoked when the operation completes. *

* * @param result * the context * @see #failed(Throwable) */ public void succeeded(C result); /** *

* Callback invoked when the operation fails. *

* * @param x * the reason for the operation failure */ public void failed(Throwable x); /** *

* Empty implementation of {@link Promise}. *

* * @param * the type of the result */ public static class Adapter implements Promise { @Override public void succeeded(U result) { } @Override public void failed(Throwable x) { x.printStackTrace(); } } }