Class LockableCommandManager<C>

    • Constructor Detail

      • LockableCommandManager

        protected LockableCommandManager​(@NonNull java.util.function.Function<@NonNull CommandTree<C>,​@NonNull CommandExecutionCoordinator<C>> commandExecutionCoordinator,
                                         @NonNull CommandRegistrationHandler commandRegistrationHandler)
        Create a new command manager instance
        Parameters:
        commandExecutionCoordinator - Execution coordinator instance. The coordinator is in charge of executing incoming commands. Some considerations must be made when picking a suitable execution coordinator for your platform. For example, an entirely asynchronous coordinator is not suitable when the parsers used in that particular platform are not thread safe. If you have commands that perform blocking operations, however, it might not be a good idea to use a synchronous execution coordinator. In most cases you will want to pick between CommandExecutionCoordinator.simpleCoordinator() and AsynchronousCommandExecutionCoordinator
        commandRegistrationHandler - Command registration handler. This will get called every time a new command is registered to the command manager. This may be used to forward command registration
    • Method Detail

      • command

        public final @NonNull CommandManager<C> command​(@NonNull Command<C> command)
        Register a new command to the command manager and insert it into the underlying command tree. The command will be forwarded to the CommandRegistrationHandler and will, depending on the platform, be forwarded to the platform.

        Different command manager implementations have different requirements for the command registration. It is possible that a command manager may only allow registration during certain stages of the application lifetime. Read the platform command manager documentation to find out more about your particular platform

        This should only be called when isCommandRegistrationAllowed() is true, else IllegalStateException will be called

        Overrides:
        command in class CommandManager<C>
        Parameters:
        command - Command to register
        Returns:
        The command manager instance
      • isCommandRegistrationAllowed

        public final boolean isCommandRegistrationAllowed()
        Check if command registration is allowed
        Returns:
        true if the registration is allowed, else false