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 SummaryModifier 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- 
withTypeParserpublic <TARGET> CommandHandler.Builder<CONTEXT> withTypeParser(Class<TARGET> cl, TypeParser<TARGET> parser)Adds aTypeParserthat will be used by theCommandHandler.- Type Parameters:
- TARGET- The type that the- TypeParseris for.
- Parameters:
- cl- The class representing the type that the- TypeParseris for.
- parser- The- TypeParser.
- Returns:
- The CommandHandler.Builder.
- Throws:
- NullPointerException- when- clis null.
- NullPointerException- when- parseris null.
 
- 
withModuleAdds aCommandModuleusing only the builders and not from a class.- Parameters:
- builderConsumer- A consumer used to modify the state of the- CommandModule.Builder.
- Returns:
- The CommandHandler.Builder.
- Throws:
- NullPointerException- when- builderConsumeris null.
 
- 
withModulepublic <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- when- moduleClassis null.
 
- 
withModulepublic <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 the- CommandModule.Builder.
- Returns:
- The CommandHandler.Builder.
- Throws:
- NullPointerException- when- moduleClassis null.
- NullPointerException- when- builderConsumeris null.
 
- 
withModulespublic <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.
 
- 
withModulespublic <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 the- CommandModule.Builder.
- Returns:
- The CommandHandler.Builder.
- Throws:
- RuntimeIOException- if the attempt to read class path resources (jar files or directories) failed.
 
- 
withBeanProviderAdds theBeanProviderthat will be used to fetch dependencies for singletonCommandModules.- Parameters:
- beanProvider- The- BeanProvider.
- Returns:
- The CommandHandler.Builder.
- Throws:
- NullPointerException- when- beanProvideris null.
 
- 
withArgumentParserSets theArgumentParserthat will be used, if none is specified then the default will be used.- Parameters:
- argumentParser- The- ArgumentParser.
- Returns:
- The CommandHandler.Builder.
- Throws:
- NullPointerException- when- argumentParseris null.
 
- 
withTokeniserSets theTokeniserthat will be used, if none is specified then the default will be used.- Parameters:
- tokeniser- The- Tokeniser.
- Returns:
- The CommandHandler.Builder.
- Throws:
- NullPointerException- when- tokeniseris null.
 
- 
withPreconditionFactoryAdds aPreconditionFactorythat will be used to instantiate preconditions.- Parameters:
- factory- The- PreconditionFactorythat will be used instead of- Preconditionof the given type.
- Returns:
- The CommandHandler.Builder.
- Throws:
- NullPointerException- when- factoryis null.
 
- 
withPrefixHandlerSets thePrefixHandlerthat will be used to supply prefixes.- Parameters:
- prefixHandler- The- PrefixHandlerto use.
- Returns:
- The CommandHandler.Builder.
 
- 
applyConfiguratorApplies the givenCommandHandlerConfiguratorto theCommandHandler.Builder.- Parameters:
- configurator- The- CommandHandlerConfiguratorto apply.
- Returns:
- The CommandHandler.Builder.
 
- 
buildBuilds theCommandHandler.- Returns:
- The built CommandHandler.
 
 
-