Class FlagContainer

java.lang.Object
de.chojo.jdautil.wrapper.FlagContainer

public class FlagContainer extends Object
  • Method Details

    • of

      public static FlagContainer of(String[] args)
      Create a new flag container based on the arguments
      Parameters:
      args - args
      Returns:
      new flag container with parsed args
    • 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

      public <T> T get(@NotNull @NotNull String flag, Function<String,T> map)
      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.
    • get

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

      public Optional<String> 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<String,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