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
- 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 void
addChild
(Constituent aArgumentizer) Adds the child.protected List<Constituent>
Gets the children.protected Constituent
getFirst()
Gets the first child.void
reset()
<T extends Operand<?>>
TTraverses the hierarchy ofCondition
tree and returns the (first) operand matching the given alias and type.toSchema()
toString()
toSyntax
(CliContext aCliCtx) This method is to be called from inside theConstituent
hierarchy; use the methodSynopsisable.toSynopsis(SyntaxNotation)
in case you invoke syntax retrieval from the rootConstituent
.<V> V
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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.refcodes.cli.Constituent
parseArgs, parseArgs, toSynopsis, toSyntax, toSyntax, toSyntax, toSyntax
Methods inherited from interface org.refcodes.mixin.DescriptionAccessor
getDescription
Methods 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 theConstituent
hierarchy; use the methodSynopsisable.toSynopsis(SyntaxNotation)
in case you invoke syntax retrieval from the rootConstituent
. Returns the human readable (verbose) syntax of thisConstituent
instance including, in case of being a node in the syntax tree (such as aCondition
, the syntax of the childConstituent
instances. ATTENTION: As of different parenthesis settings for some notations regarding the rootConstituent
and the childConstituent
s, the methodConstituent.toSyntax(CliContext)
is called from inside theConstituent
hierarchy. 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:
toSyntax
in interfaceConstituent
- Parameters:
aCliCtx
- TheCliContext
for which the syntax is being generated.- Returns:
- The human readable (verbose) command line arguments syntax.
-
reset
public void reset()- Specified by:
reset
in interfaceorg.refcodes.mixin.Resetable
-
toString
-
toSchema
- Specified by:
toSchema
in interfaceConstituent
- Specified by:
toSchema
in interfaceorg.refcodes.mixin.Schemable
-
toOperands
Traverses the hierarchy ofCondition
s and collects all therein foundOperand
s and sub-types such as theFlag
or theOption
. This is most useful when creating a list ofOption
s,Flag
es andOperand
s when printing out detailed help.- Specified by:
toOperands
in interfaceCondition
- Returns:
- The according
Operand
elements.
-
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:
toValue
in 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 ofCondition
tree and returns the (first) operand matching the given alias and type. -
getDescription
- Specified by:
getDescription
in interfaceorg.refcodes.mixin.DescriptionAccessor
-