Package revxrsal.commands.command
Interface ArgumentStack
- All Superinterfaces:
Cloneable
,Collection<String>
,Deque<String>
,Iterable<String>
,List<String>
,Queue<String>
- All Known Implementing Classes:
LinkedArgumentStack
Represents a mutable stack of strings represented as command arguments.
This class holds extremely similar functionality to a LinkedList, and in most contexts should be safely castable to one.
Command handlers may specify how argument stacks are parsed.
See ArgumentParser
for more information.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns an immutable copy of this stack.Returns this argument stack as an immutable view.static @NotNull ArgumentStack
Returns a newArgumentStack
with the specified arguments, without doing any modification to the input.static @NotNull ArgumentStack
copy
(@NotNull Collection<String> arguments) Returns a newArgumentStack
with the specified arguments, without doing any modification to the input.static @NotNull ArgumentStack
empty()
Returns a new, emptyArgumentStack
.@NotNull String
Joins all present arguments in this stack, starting from the specified index@NotNull String
Joins all present arguments in this stackpopForParameter
(@NotNull CommandParameter parameter) Returns (and removes) the string in which might get concatenated with the rest of the arguments if the parameterconsumes all strings
that follow it.Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Deque
add, addAll, addFirst, addLast, contains, descendingIterator, element, getFirst, getLast, iterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, size
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
-
Method Details
-
join
Joins all present arguments in this stack- Parameters:
delimiter
- Delimiter between these arguments.- Returns:
- The combined string
-
join
Joins all present arguments in this stack, starting from the specified index- Parameters:
delimiter
- Delimiter between these argumentsstartIndex
- The start index to combine from- Returns:
- The combined string
-
popForParameter
Returns (and removes) the string in which might get concatenated with the rest of the arguments if the parameterconsumes all strings
that follow it.- Parameters:
parameter
- The parameter to get for- Returns:
- The string for this parameter. Will return the first argument if the parameter cannot consume all strings.
- See Also:
-
asImmutableView
Returns this argument stack as an immutable view. This can be therefore passed to any conditions or resolvers without having to worry about being unintentionally modified.Note that this does not create an independent copy, and instead returns a view which does not allow modifications. If this argument stack gets modified from somewhere else, the immutable view will also be modified.
- Returns:
- The argument stack as an immutable view
-
asImmutableCopy
Returns an immutable copy of this stack. This copy will behave independently of the originalArgumentStack
.- Returns:
- An immutable copy of this
ArgumentStack
.
-
copy
Returns a newArgumentStack
with the specified arguments, without doing any modification to the input.- Parameters:
arguments
- Arguments to clone from- Returns:
- The newly created argument stack.
-
copy
Returns a newArgumentStack
with the specified arguments, without doing any modification to the input.- Parameters:
arguments
- Arguments to clone from- Returns:
- The newly created argument stack.
-
empty
Returns a new, emptyArgumentStack
.- Returns:
- A new, empty argument stack
-