diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/flags/ParsedCommandFlags.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/flags/ParsedCommandFlags.java index be45a877..605237bd 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandtools/flags/ParsedCommandFlags.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/flags/ParsedCommandFlags.java @@ -15,7 +15,7 @@ public class ParsedCommandFlags private final Map 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 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 flagValue(@NotNull CommandFlag flag, @NotNull Class 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 flagValue(@Nullable String key, @NotNull Class type) { @@ -62,10 +83,27 @@ public class ParsedCommandFlags return (T) value; } - public @Nullable T flagValue(@NotNull CommandFlag flag, @NotNull T defaultValue, @NotNull Class type) { - return flagValue(flag.getKey(), defaultValue, type); + /** + * Get the value of a flag. + * + * @param 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 flagValue(@NotNull CommandValueFlag flag, @NotNull T defaultValue) { + return flagValue(flag.getKey(), defaultValue, flag.getType()); } + /** + * Get the value of a flag. + * + * @param 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 flagValue(@Nullable String key, @NotNull T defaultValue, @NotNull Class type) { T value = flagValue(key, type); return value != null ? value : defaultValue;