Package org.refcodes.console
Class AbstractCondition
- java.lang.Object
-
- org.refcodes.console.AbstractCondition
-
- All Implemented Interfaces:
org.refcodes.component.Resetable
,Condition
,Syntaxable
,SyntaxUsage
- Direct Known Subclasses:
AndConditionImpl
,OptionalConditionImpl
,OrConditionImpl
,XorConditionImpl
public abstract class AbstractCondition extends java.lang.Object implements Condition
TheAbstractCondition
is an abstract implementation of anCondition
providing the boiler plate when implementing theCondition
interface.
-
-
Constructor Summary
Constructors Constructor Description AbstractCondition(Syntaxable... aElements)
Instantiates a new abstract condition.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addChild(Syntaxable aArgumentizer)
Adds the child.<V> V
get(java.lang.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 java.util.List<Syntaxable>
getChildren()
Gets the children.void
reset()
java.util.List<? extends Operand<?>>
toOperands()
java.lang.String
toString()
java.lang.String
toSyntax(SyntaxNotation aSyntaxNotation)
This method is to be called from inside theSyntaxable
hierarchy; use the methodSyntaxUsage.toUsage(SyntaxNotation)
in case you invoke syntax retrieval from the rootSyntaxable
.java.lang.String
toUsage(SyntaxNotation aSyntaxNotation)
Returns the human readable (verbose) syntax of implementing class ATTENTION: As of different parenthesis settings for some notations regarding the rootSyntaxable
and the childSyntaxable
s, the methodSyntaxable.toSyntax(SyntaxNotation)
is called from inside aSyntaxable
hierarchy.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.console.Syntaxable
parseArgs, toState
-
Methods inherited from interface org.refcodes.console.SyntaxUsage
toUsage, toUsage
-
-
-
-
Constructor Detail
-
AbstractCondition
public AbstractCondition(Syntaxable... aElements)
Instantiates a new abstract condition.- Parameters:
aElements
- the elements
-
-
Method Detail
-
toSyntax
public java.lang.String toSyntax(SyntaxNotation aSyntaxNotation)
This method is to be called from inside theSyntaxable
hierarchy; use the methodSyntaxUsage.toUsage(SyntaxNotation)
in case you invoke syntax retrieval from the rootSyntaxable
. Returns the human readable (verbose) syntax of thisSyntaxable
instance including, in case of being a node in the syntax tree (such as aCondition
, the syntax of the childSyntaxable
instances. ATTENTION: As of different parenthesis settings for some notations regarding the rootSyntaxable
and the childSyntaxable
s, the methodSyntaxable.toSyntax(SyntaxNotation)
is called from inside theSyntaxable
hierarchy. 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:
toSyntax
in interfaceSyntaxable
- Parameters:
aSyntaxNotation
- The syntax notation used for generating the command line arguments syntax.- Returns:
- The human readable (verbose) command line arguments syntax.
-
reset
public void reset()
- Specified by:
reset
in interfaceorg.refcodes.component.Resetable
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toOperands
public java.util.List<? extends Operand<?>> 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
protected java.util.List<Syntaxable> getChildren()
Gets the children.- Returns:
- the children
-
addChild
protected void addChild(Syntaxable aArgumentizer)
Adds the child.- Parameters:
aArgumentizer
- the argumentizer
-
get
public <V> V get(java.lang.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.- Specified by:
get
in 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
public java.lang.String toUsage(SyntaxNotation aSyntaxNotation)
Description copied from interface:SyntaxUsage
Returns the human readable (verbose) syntax of implementing class ATTENTION: As of different parenthesis settings for some notations regarding the rootSyntaxable
and the childSyntaxable
s, the methodSyntaxable.toSyntax(SyntaxNotation)
is called from inside aSyntaxable
hierarchy. In case the syntax is to be retrieved from the rootSyntaxable
or 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:
toUsage
in interfaceSyntaxUsage
- Parameters:
aSyntaxNotation
- The syntax notation used for generating the command line arguments syntax.- Returns:
- The human readable (verbose) command line arguments syntax.
-
-