Class FlagContainer

java.lang.Object
de.eldoria.eldoutilities.utils.FlagContainer

public class FlagContainer extends Object
  • Method Details

    • of

      public static FlagContainer of(Plugin plugin, String[] args)
      Create a new flag container based on the arguments
      Parameters:
      args - args
      Returns:
      new flag container with parsed args
    • isFlag

      public static boolean isFlag(String value)
    • has

      public boolean has(@NotNull @NotNull String flag)
      Check if a flag is present in the container.
      Parameters:
      flag - flag to check
      Returns:
      true if flag is present
    • hasValue

      public boolean hasValue(String flag)
      Check if the flag has a value defined.
      Parameters:
      flag - flag to check
      Returns:
      true if a value is present
    • get

      Get the value for a flag.
      Type Parameters:
      T - type of flag
      Parameters:
      flag - flag to retrieve
      map - function to map the string
      Returns:
      flag parsed with the function.
      Throws:
      CommandException
    • get

      @Nullable public @Nullable Input get(String flag)
      Get the value for the flag.
      Parameters:
      flag - flag to retrieve
      Returns:
      flag value
    • getIfPresent

      public Optional<Input> getIfPresent(String flag)
      Get the flag value if the value is present
      Parameters:
      flag - flag to retrieve
      Returns:
      flag value in an optional if present
    • getIfPresent

      public <T> Optional<T> getIfPresent(@NotNull @NotNull String flag, Function<Input,T> map)
      Get the value if present parsed with the mapping function.

      If the value is not present the mapping function will not be applied and a empty optional will be returned.

      Type Parameters:
      T - type of returned optional
      Parameters:
      flag - flag to retrieve
      map - function to map the flag
      Returns:
      flag value parsed and wrapped into an optional
    • lastFlag

      public String lastFlag()
    • lastFlagArgs

      public Input lastFlagArgs()
    • hasLastFlagArg

      public boolean hasLastFlagArg()
    • isEmpty

      public boolean isEmpty()