Class Arguments

  • Direct Known Subclasses:
    AnnoyingSender

    public class Arguments
    extends xyz.srnyx.javautilities.parents.Stringable
    A utility class for managing arguments
    • Field Summary

      Fields 
      Modifier and Type Field Description
      @Nullable java.lang.String[] args
      The arguments
    • Constructor Summary

      Constructors 
      Constructor Description
      Arguments​(@Nullable java.lang.String[] args)
      Construct a new Arguments with the specified arguments
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean argEquals​(int index, @Nullable java.lang.String... strings)
      Returns if the specified args index is equal to any of the specified strings (case-insensitive)
      @Nullable java.lang.String getArgument​(int index)
      Gets the argument at the specified index
      @NotNull java.util.Optional<java.lang.String> getArgumentOptional​(int index)
      Gets the argument at the specified index as an Optional
      @NotNull java.lang.String getArgumentsJoined()
      Gets all arguments joined together
      If no arguments are found, it returns an empty string
      @NotNull java.lang.String getArgumentsJoined​(int start)
      Gets multiple arguments joined together starting from the specified index
      If no arguments are found, it returns an empty string
      @NotNull java.lang.String getArgumentsJoined​(int start, int end)
      Gets multiple arguments joined together starting from the specified index and ending at the specified index (if too high, it will stop at the last argument)
      If no arguments are found, it returns an empty string
      • Methods inherited from class xyz.srnyx.javautilities.parents.Stringable

        toString, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • args

        @Nullable
        public final @Nullable java.lang.String[] args
        The arguments
    • Constructor Detail

      • Arguments

        public Arguments​(@Nullable
                         @Nullable java.lang.String[] args)
        Construct a new Arguments with the specified arguments
        Parameters:
        args - the arguments
    • Method Detail

      • argEquals

        public boolean argEquals​(int index,
                                 @Nullable
                                 @Nullable java.lang.String... strings)
        Returns if the specified args index is equal to any of the specified strings (case-insensitive)
        Parameters:
        index - the argument index
        strings - the strings to compare to
        Returns:
        true if the specified args index is equal to any of the specified strings (case-insensitive)
      • getArgument

        @Nullable
        public @Nullable java.lang.String getArgument​(int index)
        Gets the argument at the specified index
        Parameters:
        index - the argument index
        Returns:
        the argument at the specified index
      • getArgumentOptional

        @NotNull
        public @NotNull java.util.Optional<java.lang.String> getArgumentOptional​(int index)
        Gets the argument at the specified index as an Optional
        Parameters:
        index - the argument index
        Returns:
        the argument at the specified index as an Optional
      • getArgumentsJoined

        @NotNull
        public @NotNull java.lang.String getArgumentsJoined​(int start,
                                                            int end)
        Gets multiple arguments joined together starting from the specified index and ending at the specified index (if too high, it will stop at the last argument)
        If no arguments are found, it returns an empty string
        Parameters:
        start - the starting index
        end - the ending index
        Returns:
        the arguments joined together
      • getArgumentsJoined

        @NotNull
        public @NotNull java.lang.String getArgumentsJoined​(int start)
        Gets multiple arguments joined together starting from the specified index
        If no arguments are found, it returns an empty string
        Parameters:
        start - the starting index
        Returns:
        the arguments joined together
      • getArgumentsJoined

        @NotNull
        public @NotNull java.lang.String getArgumentsJoined()
        Gets all arguments joined together
        If no arguments are found, it returns an empty string
        Returns:
        all arguments joined together