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 TypeMethodDescriptionvoid
addListener
(Consumer<QueryFuture<T>> listener) Add future listenergetCause()
An error that caused the task failed to do its jobA result from current finished taskboolean
isDone()
Check whether the task is done executed no matter what happen to the taskboolean
Check whether the task is successfully executedvoid
Force to wait current thread until the task finishedvoid
joinThread
(long timeout) Force to wait current thread until the task finished, will ignore if its too long specified by timeoutdefault void
Print error stack trace if availablevoid
removeListener
(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
-