Package kboyle.oktane.core
Class CommandHandler.Builder<CONTEXT extends CommandContext>
java.lang.Object
kboyle.oktane.core.CommandHandler.Builder<CONTEXT>
- Type Parameters:
CONTEXT- The type of context that's used in commands.
- Enclosing class:
- CommandHandler<CONTEXT extends CommandContext>
A builder for the
CommandHandler.-
Method Summary
Modifier and TypeMethodDescriptionapplyConfigurator(CommandHandlerConfigurator configurator)Applies the givenCommandHandlerConfiguratorto theCommandHandler.Builder.build()Builds theCommandHandler.withArgumentParser(ArgumentParser argumentParser)Sets theArgumentParserthat will be used, if none is specified then the default will be used.withBeanProvider(BeanProvider beanProvider)Adds theBeanProviderthat will be used to fetch dependencies for singletonCommandModules.<MODULE extends ModuleBase<CONTEXT>>
CommandHandler.Builder<CONTEXT>withModule(Class<MODULE> moduleClass)Adds aCommandModulethat will be used by theCommandHandler.<MODULE extends ModuleBase<CONTEXT>>
CommandHandler.Builder<CONTEXT>withModule(Class<MODULE> moduleClass, Consumer<CommandModule.Builder> builderConsumer)Adds aCommandModulethat will be used by theCommandHandler.withModule(Consumer<CommandModule.Builder> builderConsumer)Adds aCommandModuleusing only the builders and not from a class.<MODULE extends ModuleBase<CONTEXT>>
CommandHandler.Builder<CONTEXT>withModules(Class<MODULE> moduleClass)Adds all theCommandModule's that link in the same package as themoduleClass.<MODULE extends ModuleBase<CONTEXT>>
CommandHandler.Builder<CONTEXT>withModules(Class<MODULE> moduleClass, Consumer<CommandModule.Builder> builderConsumer)Adds all theCommandModule's that link in the same package as themoduleClass.withPreconditionFactory(PreconditionFactory<?> factory)Adds aPreconditionFactorythat will be used to instantiate preconditions.withPrefixHandler(PrefixHandler prefixHandler)Sets thePrefixHandlerthat will be used to supply prefixes.withTokeniser(Tokeniser tokeniser)Sets theTokeniserthat will be used, if none is specified then the default will be used.<TARGET> CommandHandler.Builder<CONTEXT>withTypeParser(Class<TARGET> cl, TypeParser<TARGET> parser)Adds aTypeParserthat will be used by theCommandHandler.
-
Method Details
-
withTypeParser
public <TARGET> CommandHandler.Builder<CONTEXT> withTypeParser(Class<TARGET> cl, TypeParser<TARGET> parser)Adds aTypeParserthat will be used by theCommandHandler.- Type Parameters:
TARGET- The type that theTypeParseris for.- Parameters:
cl- The class representing the type that theTypeParseris for.parser- TheTypeParser.- Returns:
- The
CommandHandler.Builder. - Throws:
NullPointerException- whenclis null.NullPointerException- whenparseris null.
-
withModule
Adds aCommandModuleusing only the builders and not from a class.- Parameters:
builderConsumer- A consumer used to modify the state of theCommandModule.Builder.- Returns:
- The
CommandHandler.Builder. - Throws:
NullPointerException- whenbuilderConsumeris null.
-
withModule
public <MODULE extends ModuleBase<CONTEXT>> CommandHandler.Builder<CONTEXT> withModule(Class<MODULE> moduleClass)Adds aCommandModulethat will be used by theCommandHandler.- Type Parameters:
MODULE- The type of module you want to add.- Parameters:
moduleClass- The class representing the type of module that you want to add.- Returns:
- The
CommandHandler.Builder. - Throws:
NullPointerException- whenmoduleClassis null.
-
withModule
public <MODULE extends ModuleBase<CONTEXT>> CommandHandler.Builder<CONTEXT> withModule(Class<MODULE> moduleClass, Consumer<CommandModule.Builder> builderConsumer)Adds aCommandModulethat will be used by theCommandHandler.- Type Parameters:
MODULE- The type of module you want to add.- Parameters:
moduleClass- The class representing the type of module that you want to add.builderConsumer- A consumer used to modify the state of theCommandModule.Builder.- Returns:
- The
CommandHandler.Builder. - Throws:
NullPointerException- whenmoduleClassis null.NullPointerException- whenbuilderConsumeris null.
-
withModules
public <MODULE extends ModuleBase<CONTEXT>> CommandHandler.Builder<CONTEXT> withModules(Class<MODULE> moduleClass)Adds all theCommandModule's that link in the same package as themoduleClass. This method is not type safe and will add modules that don't inherit fromModuleBase<CONTEXT>- Parameters:
moduleClass- The module that lives in the same package as your other modules.- Returns:
- The
CommandHandler.Builder. - Throws:
RuntimeIOException- if the attempt to read class path resources (jar files or directories) failed.
-
withModules
public <MODULE extends ModuleBase<CONTEXT>> CommandHandler.Builder<CONTEXT> withModules(Class<MODULE> moduleClass, Consumer<CommandModule.Builder> builderConsumer)Adds all theCommandModule's that link in the same package as themoduleClass. This method is not type safe and will add modules that don't inherit fromModuleBase<CONTEXT>- Parameters:
moduleClass- The module that lives in the same package as your other modules.builderConsumer- A consumer used to modify the state of theCommandModule.Builder.- Returns:
- The
CommandHandler.Builder. - Throws:
RuntimeIOException- if the attempt to read class path resources (jar files or directories) failed.
-
withBeanProvider
Adds theBeanProviderthat will be used to fetch dependencies for singletonCommandModules.- Parameters:
beanProvider- TheBeanProvider.- Returns:
- The
CommandHandler.Builder. - Throws:
NullPointerException- whenbeanProvideris null.
-
withArgumentParser
Sets theArgumentParserthat will be used, if none is specified then the default will be used.- Parameters:
argumentParser- TheArgumentParser.- Returns:
- The
CommandHandler.Builder. - Throws:
NullPointerException- whenargumentParseris null.
-
withTokeniser
Sets theTokeniserthat will be used, if none is specified then the default will be used.- Parameters:
tokeniser- TheTokeniser.- Returns:
- The
CommandHandler.Builder. - Throws:
NullPointerException- whentokeniseris null.
-
withPreconditionFactory
Adds aPreconditionFactorythat will be used to instantiate preconditions.- Parameters:
factory- ThePreconditionFactorythat will be used instead ofPreconditionof the given type.- Returns:
- The
CommandHandler.Builder. - Throws:
NullPointerException- whenfactoryis null.
-
withPrefixHandler
Sets thePrefixHandlerthat will be used to supply prefixes.- Parameters:
prefixHandler- ThePrefixHandlerto use.- Returns:
- The
CommandHandler.Builder.
-
applyConfigurator
Applies the givenCommandHandlerConfiguratorto theCommandHandler.Builder.- Parameters:
configurator- TheCommandHandlerConfiguratorto apply.- Returns:
- The
CommandHandler.Builder.
-
build
Builds theCommandHandler.- Returns:
- The built
CommandHandler.
-