Class CompletableTask<V>
- java.lang.Object
-
- de.dytanic.cloudnet.common.concurrent.CompletableTask<V>
-
- All Implemented Interfaces:
ITask<V>,java.util.concurrent.Callable<V>,java.util.concurrent.Future<V>
- Direct Known Subclasses:
CountingTask,NullCompletableTask
public class CompletableTask<V> extends java.lang.Object implements ITask<V>
-
-
Constructor Summary
Constructors Constructor Description CompletableTask()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull ITask<V>addListener(ITaskListener<V> listener)Vcall()booleancancel(boolean b)@NotNull ITask<V>clearListeners()voidcomplete(V value)voidfail(java.lang.Throwable throwable)Vget()Vget(long l, @NotNull java.util.concurrent.TimeUnit timeUnit)Vget(long time, java.util.concurrent.TimeUnit timeUnit, V def)java.util.concurrent.Callable<V>getCallable()VgetDef(V def)java.util.Collection<ITaskListener<V>>getListeners()booleanisCancelled()booleanisDone()static <I,O>
ITask<O>mapFrom(ITask<I> source, ThrowableFunction<I,O,java.lang.Throwable> mapper)<T> ITask<T>mapThrowable(ThrowableFunction<V,T,java.lang.Throwable> mapper)static <V> CompletableTask<V>supplyAsync(ThrowableSupplier<V,java.lang.Throwable> supplier)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.dytanic.cloudnet.common.concurrent.ITask
addListener, fireExceptionOnFailure, map, onCancelled, onComplete, onComplete, onFailure, onFailure
-
-
-
-
Method Detail
-
supplyAsync
public static <V> CompletableTask<V> supplyAsync(ThrowableSupplier<V,java.lang.Throwable> supplier)
-
mapFrom
public static <I,O> ITask<O> mapFrom(ITask<I> source, ThrowableFunction<I,O,java.lang.Throwable> mapper)
-
addListener
@NotNull public @NotNull ITask<V> addListener(ITaskListener<V> listener)
- Specified by:
addListenerin interfaceITask<V>
-
clearListeners
@NotNull public @NotNull ITask<V> clearListeners()
- Specified by:
clearListenersin interfaceITask<V>
-
getListeners
public java.util.Collection<ITaskListener<V>> getListeners()
- Specified by:
getListenersin interfaceITask<V>
-
getCallable
public java.util.concurrent.Callable<V> getCallable()
- Specified by:
getCallablein interfaceITask<V>
-
fail
public void fail(java.lang.Throwable throwable)
-
complete
public void complete(V value)
-
cancel
public boolean cancel(boolean b)
- Specified by:
cancelin interfacejava.util.concurrent.Future<V>
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfacejava.util.concurrent.Future<V>
-
isDone
public boolean isDone()
- Specified by:
isDonein interfacejava.util.concurrent.Future<V>
-
get
public V get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
getin interfacejava.util.concurrent.Future<V>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
get
public V get(long l, @NotNull @NotNull java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
getin interfacejava.util.concurrent.Future<V>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
mapThrowable
public <T> ITask<T> mapThrowable(ThrowableFunction<V,T,java.lang.Throwable> mapper)
- Specified by:
mapThrowablein interfaceITask<V>
-
-