org.jdeferred.DeferredRunnable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdeferred-core Show documentation
Show all versions of jdeferred-core Show documentation
Java Deferred/Promise library similar to JQuery.
package org.jdeferred;
import org.jdeferred.DeferredManager.StartPolicy;
import org.jdeferred.impl.DeferredObject;
/**
* Use this as superclass in case you need to be able to be able to notify progress.
* If you don't need to notify progress, you can simply use {@link Runnable}
*
* @see #notify(Object)
* @author Ray Tsang
*
* @param Type used for {@link Deferred#notify(Object)}
*/
public abstract class DeferredRunnable
implements Runnable {
private final Deferred deferred = new DeferredObject();
private final StartPolicy startPolicy;
public DeferredRunnable() {
this.startPolicy = StartPolicy.DEFAULT;
}
public DeferredRunnable(StartPolicy startPolicy) {
this.startPolicy = startPolicy;
}
/**
* @see Deferred#notify(Object)
* @param progress
*/
protected void notify(P progress) {
deferred.notify(progress);
}
protected Deferred getDeferred() {
return deferred;
}
public StartPolicy getStartPolicy() {
return startPolicy;
}
}