Package septogeddon.pluginquery.api
Interface QueryFuture<T>
- Type Parameters:
T- Type returned in the future
- All Known Implementing Classes:
QueryChannelFuture,QueryCompletableFuture,QueryFutureAdapter
public interface QueryFuture<T>
Future handling
- Author:
- Thito Yalasatria Sunarya
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(Consumer<QueryFuture<T>> listener) Add future listenergetCause()An error that caused the task failed to do its jobA result from current finished taskbooleanisDone()Check whether the task is done executed no matter what happen to the taskbooleanCheck whether the task is successfully executedvoidForce to wait current thread until the task finishedvoidjoinThread(long timeout) Force to wait current thread until the task finished, will ignore if its too long specified by timeoutdefault voidPrint error stack trace if availablevoidremoveListener(Consumer<QueryFuture<T>> listener) Remove future listenerdefault QueryFuture<T> thenAccept(Consumer<T> consumer) Consume the result when the task successfully executed
-
Method Details
-
isDone
boolean isDone()Check whether the task is done executed no matter what happen to the task- Returns:
-
isSuccess
boolean isSuccess()Check whether the task is successfully executed- Returns:
-
getCause
Throwable getCause()An error that caused the task failed to do its job- Returns:
-
getResult
T getResult()A result from current finished task- Returns:
-
joinThread
void joinThread()Force to wait current thread until the task finished -
joinThread
void joinThread(long timeout) Force to wait current thread until the task finished, will ignore if its too long specified by timeout- Parameters:
timeout-
-
addListener
Add future listener- Parameters:
listener-
-
thenAccept
Consume the result when the task successfully executed- Parameters:
consumer-- Returns:
- the same instance
-
removeListener
Remove future listener- Parameters:
listener-
-
printStackTrace
default void printStackTrace()Print error stack trace if available
-