public class CliState extends CliClassContainer
state-class. It determines and holds the CLI-informations of
that state-class. In advance to CliClassContainer it also handles the CLI specific
property annotations.| Modifier and Type | Class and Description |
|---|---|
protected static class |
CliState.CliArgumentFormatter
This inner class converts a
CliArgumentContainer to a String. |
CliClassContainer.CliModeFormatter| Modifier and Type | Field and Description |
|---|---|
private AnnotationUtil |
annotationUtil |
private List<CliArgumentContainer> |
arguments |
private Map<String,CliOptionContainer> |
name2OptionMap |
private List<CliOptionContainer> |
optionList |
private ReflectionUtil |
reflectionUtil |
private ValidatorBuilder |
validatorBuilder |
| Constructor and Description |
|---|
CliState(Class<?> stateClass,
PojoDescriptorBuilderFactory descriptorBuilderFactory,
org.slf4j.Logger logger,
ReflectionUtil reflectionUtil,
AnnotationUtil annotationUtil)
The constructor.
|
addMode, getCliClass, getCliStyle, getLogger, getMode, getModeIds, getName, getStateClass, initializeModeRecursiveprivate final ReflectionUtil reflectionUtil
private final AnnotationUtil annotationUtil
private final Map<String,CliOptionContainer> name2OptionMap
private final List<CliOptionContainer> optionList
private final List<CliArgumentContainer> arguments
private final ValidatorBuilder validatorBuilder
public CliState(Class<?> stateClass, PojoDescriptorBuilderFactory descriptorBuilderFactory, org.slf4j.Logger logger, ReflectionUtil reflectionUtil, AnnotationUtil annotationUtil)
stateClass - is the state-class.descriptorBuilderFactory - is the PojoDescriptorBuilderFactory used to introspect the
properties of the stateClass.logger - is the Logger to use (e.g. for CliStyleHandling).reflectionUtil - is the ReflectionUtil instance to use.annotationUtil - is the AnnotationUtil instance to use.private ValidatorBuilder createValidatorBuilder()
ValidatorBuilder instance.protected AnnotationUtil getAnnotationUtil()
protected ReflectionUtil getReflectionUtil()
protected void initializeArguments()
CliArgument.addCloseTo(),
CliArgument.addAfter()protected NodeCycle<CliArgumentContainer> initializeArgumentRecursive(BasicDoubleLinkedNode<CliArgumentContainer> node, Map<String,BasicDoubleLinkedNode<CliArgumentContainer>> argumentMap) throws NodeCycleException
node containing
an CliArgumentContainer in order to determine the appropriate order of the CliArguments.node - is the node to initialize (link into the node-list).argumentMap - maps the id to the according argument-node.NodeCycle if a cyclic dependency has been detected but is NOT yet complete or null if the
initialization was successful.NodeCycleException - if a cyclic dependency was detected and completed.protected boolean findPropertyAnnotations(PojoDescriptorBuilder descriptorBuilder)
CliOption or CliArgument.descriptorBuilder - is the PojoDescriptorBuilder to use (determines if fields or setters are used).true if at least one annotated property has been found, false otherwise.protected CliModeObject requireMode(String id, Object annotationContainer)
CliClassContainer.getMode(String) but also handles the case that a CliMode may be undefined.id - is the ID of the requested
CliMode.annotationContainer - is the CliArgumentContainer or CliOptionContainer.CliModeObject.private void addArgument(CliArgumentContainer argumentContainer)
argumentContainer - is the argument to register.private void addOption(CliOptionContainer optionContainer)
optionContainer - is the option to register.private void addOption(String nameOrAlias, CliOptionContainer option)
nameOrAlias - is the CliOption.name() or alias of the option.option - is the option to register.public CliOptionContainer getOption(String nameOrAlias)
option associated with the given nameOrAlias .nameOrAlias - is the CliOption.name() or alias of the requested
option.option or null if no such option exists.public List<CliOptionContainer> getOptions()
List of CLI-options .public Collection<CliArgumentContainer> getArguments()
List of all CLI-arguments.public List<CliArgumentContainer> getArguments(CliModeObject mode)
mode - is the according mode.public Collection<CliOptionContainer> getOptions(CliModeObject mode)
mode - is the CliModeObject for which the options are required.Collection with all options that are compatible with
the given mode.Copyright © 2001–2016 mmm-Team. All rights reserved.