Package de.eldoria.eldoutilities.utils
Class FlagContainer
java.lang.Object
de.eldoria.eldoutilities.utils.FlagContainer
-
Method Summary
Modifier and TypeMethodDescription<T> T
get
(@NotNull String flag, ThrowingFunction<@Nullable Input, T, CommandException> map) Get the value for a flag.Get the value for the flag.<T> Optional<T>
getIfPresent
(@NotNull String flag, Function<Input, T> map) Get the value if present parsed with the mapping function.getIfPresent
(String flag) Get the flag value if the value is presentboolean
Check if a flag is present in the container.boolean
boolean
Check if the flag has a value defined.boolean
isEmpty()
static boolean
lastFlag()
static FlagContainer
Create a new flag container based on the arguments
-
Method Details
-
of
Create a new flag container based on the arguments- Parameters:
args
- args- Returns:
- new flag container with parsed args
-
isFlag
-
has
Check if a flag is present in the container.- Parameters:
flag
- flag to check- Returns:
- true if flag is present
-
hasValue
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, ThrowingFunction<@Nullable Input, T, throws CommandExceptionCommandException> map) Get the value for a flag.- Type Parameters:
T
- type of flag- Parameters:
flag
- flag to retrievemap
- function to map the string- Returns:
- flag parsed with the function.
- Throws:
CommandException
-
get
Get the value for the flag.- Parameters:
flag
- flag to retrieve- Returns:
- flag value
-
getIfPresent
Get the flag value if the value is present- Parameters:
flag
- flag to retrieve- Returns:
- flag value in an optional if present
-
getIfPresent
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 retrievemap
- function to map the flag- Returns:
- flag value parsed and wrapped into an optional
-
lastFlag
-
lastFlagArgs
-
hasLastFlagArg
public boolean hasLastFlagArg() -
isEmpty
public boolean isEmpty()
-