mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-09 17:57:36 +01:00
Add javadocs to new command flag methods
This commit is contained in:
parent
3cdf9736ec
commit
b70960d39c
@ -15,7 +15,7 @@ public class ParsedCommandFlags
|
||||
|
||||
private final Map<String, Object> flagValues;
|
||||
|
||||
public ParsedCommandFlags() {
|
||||
ParsedCommandFlags() {
|
||||
flagValues = new HashMap<>();
|
||||
}
|
||||
|
||||
@ -29,6 +29,12 @@ public class ParsedCommandFlags
|
||||
flagValues.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a flag is present.
|
||||
*
|
||||
* @param flag The flag to check.
|
||||
* @return True if the flag is present, false otherwise.
|
||||
*/
|
||||
public boolean hasFlag(@NotNull CommandFlag flag) {
|
||||
return hasFlag(flag.getKey());
|
||||
}
|
||||
@ -43,10 +49,24 @@ public class ParsedCommandFlags
|
||||
return this.flagValues.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a flag is present and has a value.
|
||||
*
|
||||
* @param key The key of the flag.
|
||||
* @return True if the flag is present and has a value, false otherwise.
|
||||
*/
|
||||
public boolean hasFlagValue(@Nullable String key) {
|
||||
return flagValue(key, Object.class) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a flag.
|
||||
*
|
||||
* @param <T> The type of the value.
|
||||
* @param flag The flag to get the value of.
|
||||
* @param type The type of the value.
|
||||
* @return The value of the flag, null if flag does not exist or no value.
|
||||
*/
|
||||
public @Nullable <T> T flagValue(@NotNull CommandFlag flag, @NotNull Class<T> type) {
|
||||
return flagValue(flag.getKey(), type);
|
||||
}
|
||||
@ -54,7 +74,8 @@ public class ParsedCommandFlags
|
||||
/**
|
||||
* Get the value of a flag.
|
||||
*
|
||||
* @param key The key of the flag.
|
||||
* @param key The key of the flag to get the value of.
|
||||
* @param type The type of the value.
|
||||
* @return The value of the flag, null if flag does not exist or no value.
|
||||
*/
|
||||
public @Nullable <T> T flagValue(@Nullable String key, @NotNull Class<T> type) {
|
||||
@ -62,10 +83,27 @@ public class ParsedCommandFlags
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
public @Nullable <T> T flagValue(@NotNull CommandFlag flag, @NotNull T defaultValue, @NotNull Class<T> type) {
|
||||
return flagValue(flag.getKey(), defaultValue, type);
|
||||
/**
|
||||
* Get the value of a flag.
|
||||
*
|
||||
* @param <T> The type of the value.
|
||||
* @param flag The flag to get the value of.
|
||||
* @param defaultValue The default value if flag does not exist or no value.
|
||||
* @return The value of the flag, default value if flag does not exist or no value.
|
||||
*/
|
||||
public @NotNull <T> T flagValue(@NotNull CommandValueFlag<T> flag, @NotNull T defaultValue) {
|
||||
return flagValue(flag.getKey(), defaultValue, flag.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a flag.
|
||||
*
|
||||
* @param <T> The type of the value.
|
||||
* @param key The key of the flag to get the value of.
|
||||
* @param defaultValue The default value if flag does not exist or no value.
|
||||
* @param type The type of the value.
|
||||
* @return The value of the flag, default value if flag does not exist or no value.
|
||||
*/
|
||||
public @NotNull <T> T flagValue(@Nullable String key, @NotNull T defaultValue, @NotNull Class<T> type) {
|
||||
T value = flagValue(key, type);
|
||||
return value != null ? value : defaultValue;
|
||||
|
Loading…
Reference in New Issue
Block a user