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 @MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") StringvalidateAlias(@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String alias) Validates an alias.static Set<@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String>validateAliases(Set<@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String> aliases) Validates the aliases of a command.static <C extends Command<?>>
CvalidateCommand(C command) Validates a command.static @MatchesRegex("(?Us)^.{1,100}+$") StringvalidateDescription(@MatchesRegex("(?Us)^.{1,100}+$") String description) Validates the description of a command.static @MatchesRegex("(?U)^[ -_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") StringvalidateDisplayName(@MatchesRegex("(?U)^[ -_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name) Validates the display name of a command.static GroupvalidateGroup(Group group) Validates the required group of a command.static <H extends Handlers>
HvalidateHandlers(H handlers) Validates the handlers of a command.static <H extends InvocationHandler<?>>
HvalidateInvocationHandler(H handler) Validates the invocation handler of a command.static @MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") StringvalidateName(@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name) Validates the name of a command.validateParameters(List<Parameter<?>> parameters) Validates the parameters of a command.static InvocationvalidateParent(Invocation parent) Validates the parent of a command.static <H extends ResultHandler<?>>
List<H>validateResultHandlers(List<? extends H> handlers) Validates the result handlers of a command.
-
Method Details
-
validateParent
Validates the parent of a command.- Parameters:
parent- The parent to validate.- Returns:
- The validated parent.
-
validateName
@Pure @StaticallyExecutable public static @MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String validateName(@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name) throws IllegalArgumentException Validates the name of a command.- Parameters:
name- The name to validate.- Returns:
- The validated name.
- Throws:
IllegalArgumentException- if the name is not valid.
-
validateDisplayName
@Pure @StaticallyExecutable public static @MatchesRegex("(?U)^[ -_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String validateDisplayName(@MatchesRegex("(?U)^[ -_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name) throws IllegalArgumentException Validates the display name of a command.- Parameters:
name- The display name to validate.- Returns:
- The validated display name.
- Throws:
IllegalArgumentException- if the display name is not valid.
-
validateAlias
@Pure @StaticallyExecutable public static @MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String validateAlias(@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String alias) throws IllegalArgumentException Validates an alias.- Parameters:
alias- The alias to validate.- Returns:
- The validated alias.
- Throws:
IllegalArgumentException- if the alias is not valid.
-
validateAliases
@SideEffectFree public static Set<@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String> validateAliases(Set<@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String> aliases) throws IllegalArgumentException Validates the aliases of a command.- Parameters:
aliases- The aliases to validate.- Returns:
- An immutable copy of the validated alias set.
- Throws:
IllegalArgumentException- if the alias set is not valid.
-
validateDescription
@Pure @StaticallyExecutable public static @MatchesRegex("(?Us)^.{1,100}+$") String validateDescription(@MatchesRegex("(?Us)^.{1,100}+$") String description) throws IllegalArgumentException Validates the description of a command.- Parameters:
description- The description to validate.- Returns:
- The validated description.
- Throws:
IllegalArgumentException- if the description is not valid.
-
validateParameters
@SideEffectFree public static List<Parameter<?>> validateParameters(List<Parameter<?>> parameters) throws IllegalArgumentException Validates the parameters of a command.- Parameters:
parameters- The parameters to validate.- Returns:
- An immutable copy of the validated parameter list, in the same order as given.
- Throws:
IllegalArgumentException- if the parameter list is not valid.
-
validateGroup
Validates the required group of a command.- Parameters:
group- The group to validate.- Returns:
- The validated group.
-
validateInvocationHandler
Validates the invocation handler of a command.- Type Parameters:
H- The handler type.- Parameters:
handler- The handler to validate.- Returns:
- The validated handler.
-
validateResultHandlers
@SideEffectFree public static <H extends ResultHandler<?>> List<H> validateResultHandlers(List<? extends H> handlers) Validates the result handlers of a command.- Type Parameters:
H- The handler type.- Parameters:
handlers- The result handlers to validate.- Returns:
- An immutable copy of the validated handler list.
-
validateHandlers
Validates the handlers of a command.- Type Parameters:
H- The handler type.- Parameters:
handlers- The handlers to validate.- Returns:
- The handlers.
-
validateCommand
@Pure public static <C extends Command<?>> C validateCommand(C command) throws IllegalArgumentException Validates a command.- Type Parameters:
C- The command type.- Parameters:
command- The command to validate.- Returns:
- The validated command.
- Throws:
IllegalArgumentException- If one of the components of the command was invalid.
-