Package de.scravy.bedrock
Class Promise<T>
java.lang.Object
de.scravy.bedrock.Promise<T>
- All Implemented Interfaces:
Callback<T>
public class Promise<T> extends Object implements Callback<T>
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPromise.State -
Method Summary
Modifier and Type Method Description voidcall(Object error, T result)voidfail(Throwable exc)static <T> Promise<T>failed(Throwable value)Promise<T>filter(Predicate<T> predicate)voidfulfill(T result)static <T> Promise<T>fulfilled(T value)Tget()ThrowablegetException()TgetValue()booleanisFailure()booleanisPending()booleanisSuccess()<U> Promise<U>map(ThrowingFunction<T,U> function)Promise<T>onComplete(Callback<T> callback)Promise<T>onFailure(ThrowingConsumer<Throwable> consumer)Promise<T>onSuccess(ThrowingConsumer<T> consumer)static <T> Promise<T>promise()Optional<T>toOptional()Try<T>toTry()voidwaitFor()
-
Method Details
-
promise
-
fulfilled
-
failed
-
fulfill
-
fail
-
get
- Throws:
AsyncExecutionException
-
waitFor
public void waitFor() -
getException
-
getValue
-
isSuccess
public boolean isSuccess() -
isFailure
public boolean isFailure() -
isPending
public boolean isPending() -
map
-
filter
-
onComplete
-
onSuccess
-
onFailure
-
toOptional
-
toTry
-
call
-