Interface ArgumentStack

All Superinterfaces:
Cloneable, Collection<String>, Deque<String>, Iterable<String>, List<String>, Queue<String>
All Known Implementing Classes:
LinkedArgumentStack

public interface ArgumentStack extends Deque<String>, List<String>, Cloneable
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 Details

    • join

      @NotNull @NotNull String join(String delimiter)
      Joins all present arguments in this stack
      Parameters:
      delimiter - Delimiter between these arguments.
      Returns:
      The combined string
    • join

      @NotNull @NotNull String join(@NotNull @NotNull String delimiter, int startIndex)
      Joins all present arguments in this stack, starting from the specified index
      Parameters:
      delimiter - Delimiter between these arguments
      startIndex - The start index to combine from
      Returns:
      The combined string
    • popForParameter

      String popForParameter(@NotNull @NotNull CommandParameter parameter)
      Returns (and removes) the string in which might get concatenated with the rest of the arguments if the parameter consumes 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

      @NotNull @NotNull @UnmodifiableView List<String> 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

      @NotNull @NotNull @Unmodifiable List<String> asImmutableCopy()
      Returns an immutable copy of this stack. This copy will behave independently of the original ArgumentStack.
      Returns:
      An immutable copy of this ArgumentStack.
    • copy

      @NotNull static @NotNull ArgumentStack copy(@NotNull @NotNull Collection<String> arguments)
      Returns a new ArgumentStack with the specified arguments, without doing any modification to the input.
      Parameters:
      arguments - Arguments to clone from
      Returns:
      The newly created argument stack.
    • copy

      @NotNull static @NotNull ArgumentStack copy(@NotNull @NotNull String... arguments)
      Returns a new ArgumentStack with the specified arguments, without doing any modification to the input.
      Parameters:
      arguments - Arguments to clone from
      Returns:
      The newly created argument stack.
    • empty

      @NotNull static @NotNull ArgumentStack empty()
      Returns a new, empty ArgumentStack.
      Returns:
      A new, empty argument stack