java.lang.Object
org.refcodes.cli.AbstractCondition
- All Implemented Interfaces:
Condition,Constituent,Synopsisable,org.refcodes.mixin.DescriptionAccessor,org.refcodes.mixin.Resetable,org.refcodes.mixin.Schemable<CliSchema>
- Direct Known Subclasses:
AllCondition,AndCondition,AnyCondition,OrCondition,XorCondition
The
AbstractCondition is an abstract implementation of the
Condition interface providing the boiler plate when implementing the
Condition interface as done by the AbstractCondition's
sub-classes.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.DescriptionAccessor
org.refcodes.mixin.DescriptionAccessor.DescriptionBuilder<B extends org.refcodes.mixin.DescriptionAccessor.DescriptionBuilder<B>>, org.refcodes.mixin.DescriptionAccessor.DescriptionMutator, org.refcodes.mixin.DescriptionAccessor.DescriptionProperty -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCondition(String aDescription, Constituent... aElements) Instantiates a new abstract condition. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddChild(Constituent aArgumentizer) Adds the child.protected List<Constituent>Gets the children.protected ConstituentgetFirst()Gets the first child.voidreset()<T extends Operand<?>>
TTraverses the hierarchy ofConditiontree and returns the (first) operand matching the given alias and type.toSchema()toString()toSyntax(CliContext aCliCtx) This method is to be called from inside theConstituenthierarchy; use the methodSynopsisable.toSynopsis(SyntaxNotation)in case you invoke syntax retrieval from the rootConstituent.<V> VSearches for a value being set for the given for given alias in the syntax tree parsing the command line arguments; if a node in the syntax tree has a value for the given alias, then this value is returned.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.refcodes.cli.Constituent
parseArgs, parseArgs, toSynopsis, toSyntax, toSyntax, toSyntax, toSyntaxMethods inherited from interface org.refcodes.mixin.DescriptionAccessor
getDescriptionMethods inherited from interface org.refcodes.cli.Synopsisable
toSynopsis, toSynopsis, toSynopsis, toSynopsis
-
Field Details
-
_description
-
-
Constructor Details
-
AbstractCondition
Instantiates a new abstract condition.- Parameters:
aDescription- The description of thisCondition.aElements- the elements
-
-
Method Details
-
toSyntax
This method is to be called from inside theConstituenthierarchy; use the methodSynopsisable.toSynopsis(SyntaxNotation)in case you invoke syntax retrieval from the rootConstituent. Returns the human readable (verbose) syntax of thisConstituentinstance including, in case of being a node in the syntax tree (such as aCondition, the syntax of the childConstituentinstances. ATTENTION: As of different parenthesis settings for some notations regarding the rootConstituentand the childConstituents, the methodConstituent.toSyntax(CliContext)is called from inside theConstituenthierarchy. In case the syntax is to be retrieved from the rootConstituent, then the applicable method to be called isSynopsisable.toSynopsis(SyntaxNotation), as for some notations it will for example not create the most outer braces.- Specified by:
toSyntaxin interfaceConstituent- Parameters:
aCliCtx- TheCliContextfor which the syntax is being generated.- Returns:
- The human readable (verbose) command line arguments syntax.
-
reset
public void reset()- Specified by:
resetin interfaceorg.refcodes.mixin.Resetable
-
toString
-
toSchema
- Specified by:
toSchemain interfaceorg.refcodes.mixin.Schemable<CliSchema>
-
toOperands
Traverses the hierarchy ofConditions and collects all therein foundOperands and sub-types such as theFlagor theOption. This is most useful when creating a list ofOptions,Flages andOperands when printing out detailed help.- Specified by:
toOperandsin interfaceCondition- Returns:
- The according
Operandelements.
-
getChildren
Gets the children.- Returns:
- the children
-
getFirst
Gets the first child. It is up to the developer to make sure that there actually is(!) a child!- Returns:
- the first child.
-
addChild
Adds the child.- Parameters:
aArgumentizer- the argumentizer
-
toValue
Searches for a value being set for the given for given alias in the syntax tree parsing the command line arguments; if a node in the syntax tree has a value for the given alias, then this value is returned.- Specified by:
toValuein interfaceConstituent- Type Parameters:
V- The type of the value being expected.- Parameters:
aAlias- The alias for which to seek for a value being set.- Returns:
- The according value or null if none has been set for the given alias.
-
toOperand
Traverses the hierarchy ofConditiontree and returns the (first) operand matching the given alias and type. -
getDescription
- Specified by:
getDescriptionin interfaceorg.refcodes.mixin.DescriptionAccessor
-