Package net.dv8tion.jda.core.requests
Class RestAction.EmptyRestAction<T>
- java.lang.Object
-
- net.dv8tion.jda.core.requests.RestAction<T>
-
- net.dv8tion.jda.core.requests.RestAction.EmptyRestAction<T>
-
- Type Parameters:
T
- The generic response type for this RestAction
- Enclosing class:
- RestAction<T>
public static class RestAction.EmptyRestAction<T> extends RestAction<T>
Specialized form ofRestAction
that is used to provide information that has already been retrieved or generated so that another request does not need to be made to Discord.
Basically: Allows you to provide a value directly to the success returns.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.dv8tion.jda.core.requests.RestAction
RestAction.EmptyRestAction<T>
-
-
Field Summary
-
Fields inherited from class net.dv8tion.jda.core.requests.RestAction
DEFAULT_FAILURE, DEFAULT_SUCCESS, LOG
-
-
Constructor Summary
Constructors Constructor Description EmptyRestAction(JDA api, T returnObj)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
complete(boolean shouldQueue)
Blocks the current Thread and awaits the completion of anRestAction.submit()
request.void
queue(java.util.function.Consumer<? super T> success, java.util.function.Consumer<? super java.lang.Throwable> failure)
Submits a Request for execution.RequestFuture<T>
submit(boolean shouldQueue)
Submits a Request for execution and provides aRequestFuture
representing its completion task.-
Methods inherited from class net.dv8tion.jda.core.requests.RestAction
complete, completeAfter, getJDA, isPassContext, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, setCheck, setPassContext, submit, submitAfter, submitAfter
-
-
-
-
Method Detail
-
queue
public void queue(java.util.function.Consumer<? super T> success, java.util.function.Consumer<? super java.lang.Throwable> failure)
Description copied from class:RestAction
Submits a Request for execution.This method is asynchronous
- Overrides:
queue
in classRestAction<T>
- Parameters:
success
- The success callback that will be called at a convenient time for the API. (can be null)failure
- The failure callback that will be called if the Request encounters an exception at its execution point.
-
submit
public RequestFuture<T> submit(boolean shouldQueue)
Description copied from class:RestAction
Submits a Request for execution and provides aRequestFuture
representing its completion task.
Cancelling the returned Future will result in the cancellation of the Request!Note: The usage of
CompletionStage.toCompletableFuture()
is not supported.- Overrides:
submit
in classRestAction<T>
- Parameters:
shouldQueue
- Whether the Request should automatically handle rate limitations. (default true)- Returns:
- Never-null
RequestFuture
task representing the completion promise
-
complete
public T complete(boolean shouldQueue)
Description copied from class:RestAction
Blocks the current Thread and awaits the completion of anRestAction.submit()
request.
Used for synchronous logic.- Overrides:
complete
in classRestAction<T>
- Parameters:
shouldQueue
- Whether this should automatically handle rate limitations (default true)- Returns:
- The response value
-
-