Class OrderActionImpl<T,M extends OrderAction<T,M>>
java.lang.Object
net.dv8tion.jda.internal.requests.RestActionImpl<Void>
net.dv8tion.jda.internal.requests.restaction.order.OrderActionImpl<T,M>
- All Implemented Interfaces:
RestAction<Void>
,OrderAction<T,
M>
- Direct Known Subclasses:
ChannelOrderActionImpl
,RoleOrderActionImpl
public abstract class OrderActionImpl<T,M extends OrderAction<T,M>>
extends RestActionImpl<Void>
implements OrderAction<T,M>
-
Field Summary
Fields inherited from class net.dv8tion.jda.internal.requests.RestActionImpl
LOG
-
Constructor Summary
ConstructorsConstructorDescriptionOrderActionImpl
(JDA api, boolean ascendingOrder, Route.CompiledRoute route) Creates a new OrderAction instanceOrderActionImpl
(JDA api, Route.CompiledRoute route) Creates a new OrderAction instance -
Method Summary
Modifier and TypeMethodDescriptiondeadline
(long timestamp) Similar toRestAction.timeout(long, TimeUnit)
but schedules a deadline at which the request has to be completed.Immutable List representing the currently selected order of entities in this OrderAction instanceThe entity which is currently at theselected position
int
The currently selected position that is in focus for all modification operations of this OrderAction instanceboolean
Whether this instance uses ascending order, from the lowest position to the highest.Moves the currently selected entity above the specified target entity.Moves the currently selected entity below the specified target entity.moveDown
(int amount) Moves the currently selected entityamount
positions DOWN in order by pushing all entities up by one position.moveTo
(int position) Moves the currently selected entity to the specified position (0 based index).moveUp
(int amount) Moves the currently selected entityamount
positions UP in order by pushing all entities down by one position.Reverses thecurrent order
by usingCollections.reverse(orderList)
selectPosition
(int selectedPosition) Selects a new current entity at the specified index
This index is in correlation to thecurrent order
selectPosition
(T selectedEntity) Selects a new current entity based on the index of the specified entity in thecurrent order
This is a convenience function that usesOrderAction.selectPosition(int)
internallysetCheck
(BooleanSupplier checks) Sets the last-second checks before finally executing the http request in the queue.Shuffles thecurrent order
by usingCollections.shuffle(orderList)
sortOrder
(Comparator<T> comparator) swapPosition
(int swapPosition) Swaps the currently selected entity with the entity located at the specified position.swapPosition
(T swapEntity) Swaps the currently selected entity with the specified entity.Timeout for this RestAction instance.Methods inherited from class net.dv8tion.jda.internal.requests.RestActionImpl
complete, getCheck, getDefaultFailure, getDefaultSuccess, getDefaultTimeout, getJDA, handleResponse, isPassContext, priority, queue, setDefaultFailure, setDefaultSuccess, setDefaultTimeout, setErrorMapper, setPassContext, submit
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
addCheck, and, and, complete, complete, completeAfter, delay, delay, delay, delay, flatMap, flatMap, getCheck, getJDA, map, mapToResult, onErrorFlatMap, onErrorFlatMap, onErrorMap, onErrorMap, onSuccess, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter, zip
-
Constructor Details
-
OrderActionImpl
Creates a new OrderAction instance- Parameters:
api
- JDA instance which is associated with the entities contained in the order listroute
- TheCompiledRoute
which is provided to theRestAction Constructor
-
OrderActionImpl
Creates a new OrderAction instance- Parameters:
api
- JDA instance which is associated with the entities contained in the order listascendingOrder
- Whether or not the order of items should be ascendingroute
- TheCompiledRoute
which is provided to theRestAction Constructor
-
-
Method Details
-
setCheck
Description copied from interface:RestAction
Sets the last-second checks before finally executing the http request in the queue.
If the provided supplier evaluates tofalse
or throws an exception this will not be finished. When an exception is thrown from the supplier it will be provided to the failure callback.- Specified by:
setCheck
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Specified by:
setCheck
in interfaceRestAction<T>
- Overrides:
setCheck
in classRestActionImpl<Void>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
- See Also:
-
timeout
Description copied from interface:RestAction
Timeout for this RestAction instance.
If the request doesn't get executed within the timeout it will fail.When a RestAction times out, it will fail with a
TimeoutException
. This is the same asdeadline(System.currentTimeMillis() + unit.toMillis(timeout))
.Example
action.timeout(10, TimeUnit.SECONDS) // 10 seconds from now .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
- Specified by:
timeout
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Specified by:
timeout
in interfaceRestAction<T>
- Parameters:
timeout
- The timeout to useunit
-Unit
for the timeout value- Returns:
- The same RestAction instance with the applied timeout
- See Also:
-
deadline
Description copied from interface:RestAction
Similar toRestAction.timeout(long, TimeUnit)
but schedules a deadline at which the request has to be completed.
If the deadline is reached, the request will fail with aTimeoutException
.This does not mean that the request will immediately timeout when the deadline is reached. JDA will check the deadline right before executing the request or within intervals in a worker thread. This only means the request will timeout if the deadline has passed.
Example
action.deadline(System.currentTimeMillis() + 10000) // 10 seconds from now .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
- Specified by:
deadline
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Specified by:
deadline
in interfaceRestAction<T>
- Overrides:
deadline
in classRestActionImpl<Void>
- Parameters:
timestamp
- Millisecond timestamp at which the request will timeout- Returns:
- The same RestAction with the applied deadline
- See Also:
-
isAscendingOrder
public boolean isAscendingOrder()Description copied from interface:OrderAction
Whether this instance uses ascending order, from the lowest position to the highest.- Specified by:
isAscendingOrder
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Returns:
- True, if this uses ascending order
-
getCurrentOrder
Description copied from interface:OrderAction
Immutable List representing the currently selected order of entities in this OrderAction instance- Specified by:
getCurrentOrder
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Returns:
- Immutable List representing the current order
-
selectPosition
Description copied from interface:OrderAction
Selects a new current entity at the specified index
This index is in correlation to thecurrent order
- Specified by:
selectPosition
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Parameters:
selectedPosition
- The index for the new position that will be in focus for all modification operations- Returns:
- The current OrderAction sub-implementation instance
- See Also:
-
selectPosition
Description copied from interface:OrderAction
Selects a new current entity based on the index of the specified entity in thecurrent order
This is a convenience function that usesOrderAction.selectPosition(int)
internally- Specified by:
selectPosition
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Parameters:
selectedEntity
- The entity for the new position that will be in focus for all modification operations- Returns:
- The current OrderAction sub-implementation instance
- See Also:
-
getSelectedPosition
public int getSelectedPosition()Description copied from interface:OrderAction
The currently selected position that is in focus for all modification operations of this OrderAction instance- Specified by:
getSelectedPosition
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Returns:
- The currently selected index, or -1 if no position has been selected yet
-
getSelectedEntity
Description copied from interface:OrderAction
The entity which is currently at theselected position
- Specified by:
getSelectedEntity
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Returns:
- The currently selected entity
-
moveUp
Description copied from interface:OrderAction
Moves the currently selected entityamount
positions UP in order by pushing all entities down by one position.- Specified by:
moveUp
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Parameters:
amount
- The amount of positions that should be moved- Returns:
- The current OrderAction sub-implementation instance
- See Also:
-
moveDown
Description copied from interface:OrderAction
Moves the currently selected entityamount
positions DOWN in order by pushing all entities up by one position.- Specified by:
moveDown
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Parameters:
amount
- The amount of positions that should be moved- Returns:
- The current OrderAction sub-implementation instance
- See Also:
-
moveTo
Description copied from interface:OrderAction
Moves the currently selected entity to the specified position (0 based index). All entities are moved in the direction of the left hole to fill the gap.- Specified by:
moveTo
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Parameters:
position
- The new not-negative position for the currently selected entity- Returns:
- The current OrderAction sub-implementation instance
- See Also:
-
moveBelow
Description copied from interface:OrderAction
Moves the currently selected entity below the specified target entity.- Specified by:
moveBelow
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Parameters:
other
- The reference entity that should end up above the selected entity- Returns:
- The current OrderAction sub-implementation instance
- See Also:
-
moveAbove
Description copied from interface:OrderAction
Moves the currently selected entity above the specified target entity.- Specified by:
moveAbove
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Parameters:
other
- The reference entity that should end up below the selected entity- Returns:
- The current OrderAction sub-implementation instance
- See Also:
-
swapPosition
Description copied from interface:OrderAction
Swaps the currently selected entity with the entity located at the specified position. No other entities are affected by this operation.- Specified by:
swapPosition
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Parameters:
swapPosition
- 0 based index of target position- Returns:
- The current OrderAction sub-implementation instance
-
swapPosition
Description copied from interface:OrderAction
Swaps the currently selected entity with the specified entity. No other entities are affected by this operation.- Specified by:
swapPosition
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Parameters:
swapEntity
- Target entity to switch positions with- Returns:
- The current OrderAction sub-implementation instance
- See Also:
-
reverseOrder
Description copied from interface:OrderAction
Reverses thecurrent order
by usingCollections.reverse(orderList)
- Specified by:
reverseOrder
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Returns:
- The current OrderAction sub-implementation instance
- See Also:
-
shuffleOrder
Description copied from interface:OrderAction
Shuffles thecurrent order
by usingCollections.shuffle(orderList)
- Specified by:
shuffleOrder
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Returns:
- The current OrderAction sub-implementation instance
- See Also:
-
sortOrder
Description copied from interface:OrderAction
- Specified by:
sortOrder
in interfaceOrderAction<T,
M extends OrderAction<T, M>> - Parameters:
comparator
- Comparator used to sort the current order- Returns:
- The current OrderAction sub-implementation instance
- See Also:
-