Class CommandBean<C>
- Type Parameters:
C- the command sender type
- All Implemented Interfaces:
CommandFactory<C>,CommandExecutionHandler<C>
The command bean is a CommandExecutionHandler and will be set as the handler of the command by
default. The execute(CommandContext) or CommandExecutionHandler.executeFuture(CommandContext) methods can be overridden
to implement your command handler. You may also provide custom handler when configure(Command.Builder) is invoked.
Information about the command, such as aliases, should be provided by properties(). The command bean may be
registered to the command manager by using CommandManager.command(CommandFactory). This will invoke
configure(Command.Builder)
where you may configure the command. The command meta may be configured by overriding meta().
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.incendo.cloud.execution.CommandExecutionHandler
CommandExecutionHandler.FutureCommandExecutionHandler<C> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract @NonNull Command.Builder<? extends C> configure(@NonNull Command.Builder<C> builder) Configures the command before it's registered to the command manager.createCommands(@NonNull CommandManager<C> commandManager) Constructs a command using the givencommandManager.voidexecute(@NonNull CommandContext<C> commandContext) Default command handler for this command bean.protected @NonNull CommandMetameta()Returns the command meta for the constructed command.protected abstract @NonNull CommandPropertiesReturns the properties of the command.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.incendo.cloud.execution.CommandExecutionHandler
executeFuture
-
Constructor Details
-
CommandBean
protected CommandBean()
-
-
Method Details
-
createCommands
public @NonNull List<@NonNull Command<? extends C>> createCommands(@NonNull CommandManager<C> commandManager) Constructs a command using the givencommandManager.This invokes
configure(Command.Builder)which allows for configuration of the command.- Specified by:
createCommandsin interfaceCommandFactory<C>- Parameters:
commandManager- the command manager- Returns:
- the constructed command
-
meta
Returns the command meta for the constructed command.- Returns:
- the command meta
-
properties
Returns the properties of the command.- Returns:
- the command properties
-
configure
protected abstract @NonNull Command.Builder<? extends C> configure(@NonNull Command.Builder<C> builder) Configures the command before it's registered to the command manager.The command builder has been created by using the
properties()andmeta()of this bean. The builder has been pre-configured to usethisinstance as theCommandExecutionHandler.- Parameters:
builder- the command builder- Returns:
- the updated builder
-
execute
Default command handler for this command bean. Does nothing unless override.- Specified by:
executein interfaceCommandExecutionHandler<C>- Parameters:
commandContext- Command context
-