java.lang.Object
org.refcodes.cli.AbstractCondition
- All Implemented Interfaces:
Condition,Syntaxable,SyntaxUsage,org.refcodes.component.Resetable
- Direct Known Subclasses:
AndCondition,OptionalCondition,OptionConditionFacade,OrCondition,XorCondition
public abstract class AbstractCondition extends Object implements Condition
The
AbstractCondition is an abstract implementation of an
Condition providing the boiler plate when implementing the
Condition interface.-
Constructor Summary
Constructors Constructor Description AbstractCondition(Syntaxable... aElements)Instantiates a new abstract condition. -
Method Summary
Modifier and Type Method Description protected voidaddChild(Syntaxable aArgumentizer)Adds the child.<V> Vget(String aAlias)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.protected List<Syntaxable>getChildren()Gets the children.voidreset()List<Operand<?>>toOperands()StringtoString()StringtoSyntax(SyntaxNotation aSyntaxNotation, String aOptionEscCode, String aResetEscCode)This method is to be called from inside theSyntaxablehierarchy; use the methodSyntaxUsage.toUsage(SyntaxNotation)in case you invoke syntax retrieval from the rootSyntaxable.StringtoUsage(SyntaxNotation aSyntaxNotation, String aOptionEscCode, String aResetEscCode)Returns the human readable (verbose) syntax of implementing class ATTENTION: As of different parenthesis settings for some notations regarding the rootSyntaxableand the childSyntaxables, the methodSyntaxable.toSyntax(SyntaxNotation, String, String)is called from inside aSyntaxablehierarchy.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.refcodes.cli.Syntaxable
parseArgs, parseArgs, toState, toSyntaxMethods inherited from interface org.refcodes.cli.SyntaxUsage
toUsage, toUsage, toUsage
-
Constructor Details
-
AbstractCondition
Instantiates a new abstract condition.- Parameters:
aElements- the elements
-
-
Method Details
-
toSyntax
public String toSyntax(SyntaxNotation aSyntaxNotation, String aOptionEscCode, String aResetEscCode)This method is to be called from inside theSyntaxablehierarchy; use the methodSyntaxUsage.toUsage(SyntaxNotation)in case you invoke syntax retrieval from the rootSyntaxable. Returns the human readable (verbose) syntax of thisSyntaxableinstance including, in case of being a node in the syntax tree (such as aCondition, the syntax of the childSyntaxableinstances. ATTENTION: As of different parenthesis settings for some notations regarding the rootSyntaxableand the childSyntaxables, the methodSyntaxable.toSyntax(SyntaxNotation, String, String)is called from inside theSyntaxablehierarchy. In case the syntax is to be retrieved from the rootSyntaxable, then the applicable method to be called isSyntaxUsage.toUsage(SyntaxNotation), as for some notations it will for example not create the most outer braces.- Specified by:
toSyntaxin interfaceSyntaxable- Parameters:
aSyntaxNotation- The syntax notation used for generating the command line arguments syntax.aOptionEscCode- The escape code to be used when processing an option, e.g. this can be an ANSI Escape-Code to highlight the option parameters.aResetEscCode- The escape code to close (reset) any Escape-Code being set before.- Returns:
- The human readable (verbose) command line arguments syntax.
-
reset
public void reset()- Specified by:
resetin interfaceorg.refcodes.component.Resetable
-
toString
-
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
-
addChild
Adds the child.- Parameters:
aArgumentizer- the argumentizer
-
get
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:
getin interfaceSyntaxable- 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.
-
toUsage
Returns the human readable (verbose) syntax of implementing class ATTENTION: As of different parenthesis settings for some notations regarding the rootSyntaxableand the childSyntaxables, the methodSyntaxable.toSyntax(SyntaxNotation, String, String)is called from inside aSyntaxablehierarchy. In case the syntax is to be retrieved from the rootSyntaxableor an encapsulating and different type, then the applicable method to be called isSyntaxUsage.toUsage(SyntaxNotation), as for some notations it will for example not create the most outer braces.- Specified by:
toUsagein interfaceSyntaxUsage- Parameters:
aSyntaxNotation- The syntax notation used for generating the command line arguments syntax.aOptionEscCode- The escape code to be used when processing an option, e.g. this can be an ANSI Escape-Code to highlight the option parameters (for example "--help", "-q" and so on).aResetEscCode- The escape code to close (reset) any Escape-Code being set before.- Returns:
- The human readable (verbose) command line arguments syntax.
-