Class CommandUtils
java.lang.Object
dev.sympho.modular_commands.utils.CommandUtils
Utility functions for Commands.
- Since:
- 1.0
- Version:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidvalidateAlias(@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String alias) Validates an alias.static voidvalidateAliases(Set<@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String> aliases) Validates the aliases of a command.static voidvalidateCommand(Command<?> command) Validates a command.static voidvalidateDescription(@MatchesRegex("(?Us)^.{1,100}+$") String description) Validates the description of a command.static voidvalidateDisplayName(@MatchesRegex("(?U)^[ -_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name) Validates the display name of a command.static voidvalidateGroup(Group group) Validates the required group of a command.static voidvalidateHandlers(Handlers handlers) Validates the handlers of a command.static voidvalidateId(String id) Validates the ID of a command.static voidvalidateInvocationHandler(InvocationHandler<?> handler) Validates the invocation handler of a command.static voidvalidateName(@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name) Validates the name of a command.static voidvalidateParameters(List<Parameter<?>> parameters) Validates the parameters of a command.static voidvalidateParent(Invocation parent) Validates the parent of a command.static voidvalidateResultHandlers(List<? extends ResultHandler<?>> handlers) Validates the result handlers of a command.
-
Method Details
-
validateId
Validates the ID of a command.- Parameters:
id- The ID to validate.- Throws:
NullPointerException- if anullvalue was found where not allowed.
-
validateParent
@SideEffectFree public static void validateParent(Invocation parent) throws IllegalArgumentException, NullPointerException Validates the parent of a command.- Parameters:
parent- The parent to validate.- Throws:
IllegalArgumentException- if the parent is not valid.NullPointerException- if anullvalue was found where not allowed.
-
validateName
@SideEffectFree public static void validateName(@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name) throws IllegalArgumentException, NullPointerException Validates the name of a command.- Parameters:
name- The name to validate.- Throws:
IllegalArgumentException- if the name is not valid.NullPointerException- if anullvalue was found where not allowed.
-
validateDisplayName
@SideEffectFree public static void validateDisplayName(@MatchesRegex("(?U)^[ -_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name) throws IllegalArgumentException, NullPointerException Validates the display name of a command.- Parameters:
name- The display name to validate.- Throws:
IllegalArgumentException- if the display name is not valid.NullPointerException- if anullvalue was found where not allowed.
-
validateAlias
@SideEffectFree public static void validateAlias(@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String alias) throws IllegalArgumentException, NullPointerException Validates an alias.- Parameters:
alias- The alias to validate.- Throws:
IllegalArgumentException- if the alias is not valid.NullPointerException- if anullvalue was found where not allowed.
-
validateAliases
@SideEffectFree public static void validateAliases(Set<@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String> aliases) throws IllegalArgumentException, NullPointerException Validates the aliases of a command.- Parameters:
aliases- The aliases to validate.- Throws:
IllegalArgumentException- if the alias set is not valid.NullPointerException- if anullvalue was found where not allowed.
-
validateDescription
@SideEffectFree public static void validateDescription(@MatchesRegex("(?Us)^.{1,100}+$") String description) throws IllegalArgumentException, NullPointerException Validates the description of a command.- Parameters:
description- The description to validate.- Throws:
IllegalArgumentException- if the description is not valid.NullPointerException- if anullvalue was found where not allowed.
-
validateParameters
@SideEffectFree public static void validateParameters(List<Parameter<?>> parameters) throws IllegalArgumentException, NullPointerException Validates the parameters of a command.- Parameters:
parameters- The parameters to validate.- Throws:
IllegalArgumentException- if the parameter list is not valid.NullPointerException- if anullvalue was found where not allowed.
-
validateGroup
Validates the required group of a command.- Parameters:
group- The group to validate.- Throws:
NullPointerException- if anullvalue was found where not allowed.
-
validateInvocationHandler
@SideEffectFree public static void validateInvocationHandler(InvocationHandler<?> handler) throws NullPointerException Validates the invocation handler of a command.- Parameters:
handler- The handler to validate.- Throws:
NullPointerException- if anullvalue was found where not allowed.
-
validateResultHandlers
@SideEffectFree public static void validateResultHandlers(List<? extends ResultHandler<?>> handlers) throws NullPointerException Validates the result handlers of a command.- Parameters:
handlers- The result handlers to validate.- Throws:
NullPointerException- if anullvalue was found where not allowed.
-
validateHandlers
Validates the handlers of a command.- Parameters:
handlers- The handlers to validate.- Throws:
NullPointerException- if anullvalue was found where not allowed.
-
validateCommand
@SideEffectFree public static void validateCommand(Command<?> command) throws IllegalArgumentException Validates a command.- Parameters:
command- The command to validate.- Throws:
IllegalArgumentException- if any of the components of the command was invalid.NullPointerException- if anullvalue was found where not allowed.
-