Interface Registry
- All Known Implementing Classes:
SimpleRegistry
public interface Registry
A registry that stores commands that may be invoked by users.
- Since:
- 1.0
- Version:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionfindCommand(Invocation invocation, Class<H> type) Retrieves the best command known to this registry that has the given parent and name, and is compatible with the given type.getCommand(String id) Retrieves the command with the given ID that is registered to this registry.<H extends Handlers>
Collection<Command<? extends H>>getCommands(Class<H> type) Retrieves all commands known to this registry that are compatible with the given type.booleanregisterCommand(String id, Command<?> command) Registers a command into this registry.removeCommand(String id) Removes a command from this registry that was registered with the given ID.
-
Method Details
-
findCommand
@Pure <H extends Handlers> @Nullable Command<? extends H> findCommand(Invocation invocation, Class<H> type) Retrieves the best command known to this registry that has the given parent and name, and is compatible with the given type.- Type Parameters:
H- The handler type that must be supported.- Parameters:
invocation- The invocation of the command.type- The handler type.- Returns:
- The best matching command known to this registry, or
nullif none were found.
-
getCommands
Retrieves all commands known to this registry that are compatible with the given type.- Type Parameters:
H- The handler type that must be supported.- Parameters:
type- The handler type.- Returns:
- The compatible commands known to this registry.
-
getCommand
Retrieves the command with the given ID that is registered to this registry.- Parameters:
id- The ID of the command to retrieve.- Returns:
- The command that was registered with the given ID, or
nullif there is no such command in this registry.
-
registerCommand
Registers a command into this registry.- Parameters:
id- The ID to register the command under. This is different from the command name and display name in that it is not used for command handling or any user-facing functionality, but rather only as a way to internally identify the command.command- The command to register.- Returns:
trueif the command was registered successfully.falseif there is already a command in this registry with the given ID, or if there is already a command known to this registry with the given signature and this registry does not allow overriding. Iffalse, the registration failed and the call had no effect.- Throws:
IllegalArgumentException- if the given command has an invalid configuration.
-
removeCommand
Removes a command from this registry that was registered with the given ID.- Parameters:
id- The ID of the command to remove.- Returns:
- The removed command, or
nullif there was no command in this registry registered with the given ID.
-