java.lang.Object
org.refcodes.cli.AbstractCondition
- All Implemented Interfaces:
Condition,MatchCountAccessor,Synopsisable,Term,org.refcodes.exception.ExceptionAccessor<ArgsSyntaxException>,org.refcodes.mixin.ChildrenAccessor<Term[]>,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.ChildrenAccessor
org.refcodes.mixin.ChildrenAccessor.ChildrenBuilder<T extends Object,B extends org.refcodes.mixin.ChildrenAccessor.ChildrenBuilder<T, B>>, org.refcodes.mixin.ChildrenAccessor.ChildrenMutator<T extends Object>, org.refcodes.mixin.ChildrenAccessor.ChildrenProperty<T extends Object> 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.DescriptionPropertyNested classes/interfaces inherited from interface org.refcodes.exception.ExceptionAccessor
org.refcodes.exception.ExceptionAccessor.ExceptionBuilder<EXC extends Throwable,B extends org.refcodes.exception.ExceptionAccessor.ExceptionBuilder<EXC, B>>, org.refcodes.exception.ExceptionAccessor.ExceptionMutator<EXC extends Throwable>, org.refcodes.exception.ExceptionAccessor.ExceptionProperty<EXC extends Throwable> Nested classes/interfaces inherited from interface org.refcodes.cli.MatchCountAccessor
MatchCountAccessor.MatchCountBuilder<B extends MatchCountAccessor.MatchCountBuilder<B>>, MatchCountAccessor.MatchCountMutator, MatchCountAccessor.MatchCountProperty -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCondition(String aDescription, Term... aElements) Instantiates anAbstractCondition' s sub-class with the according arguments. -
Method Summary
Modifier and TypeMethodDescriptionTerm[]Retrieves theArgsSyntaxExceptionexception in case invokingTerm.parseArgs(String[], CliContext)failed.intDetermines the number of args being matched by theTerm.parseArgs(String[], CliContext)(and similar) method(s) of the according syntax.voidreset()protected static String[]toArgsDiff(String[] aArgs, String[] aArgsSubset) Creates the difference between the provided set and the provided subset.protected static String[]toArgsDiff(String[] aArgs, List<? extends Operand<?>> aArgsSubset) Creates the difference between the provided set and the providedLists therein found argument arrays subset (as ofOperand.getParsedArgs()).protected static String[]toArgsDiff(String[] aArgs, Operand<?>[] aArgsSubset) Creates the difference between the provided set and the providedLists therein found argument arrays subset (as ofOperand.getParsedArgs()).<T extends Operand<?>>
TTraverses the hierarchy ofConditiontree and returns the (first) operand matching the given alias and type.Operand<?>[]protected static String[]toParsedArgs(Operand<?>[]... aOperands) Takes allOperandinstances found in the providedLists and adds all therein found argument arrays (as ofOperand.getParsedArgs()) to the result.toSchema()toString()toSyntax(CliContext aCliCtx) This method is to be called from inside theTermhierarchy; use the methodSynopsisable.toSynopsis(SyntaxNotation)in case you invoke syntax retrieval from the rootTerm.<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.Condition
hasChild, isChild, toConditions, toOperand, toOperand, toOperandsMethods inherited from interface org.refcodes.mixin.DescriptionAccessor
getDescriptionMethods inherited from interface org.refcodes.cli.Synopsisable
toSynopsis, toSynopsis, toSynopsis, toSynopsisMethods inherited from interface org.refcodes.cli.Term
getException, parseArgs, parseArgs, toSynopsis, toSyntax, toSyntax, toSyntax, toSyntax
-
Field Details
-
_children
-
_description
-
_exception
-
-
Constructor Details
-
AbstractCondition
Instantiates anAbstractCondition' s sub-class with the according arguments.
-
-
Method Details
-
getMatchCount
public int getMatchCount()Determines the number of args being matched by theTerm.parseArgs(String[], CliContext)(and similar) method(s) of the according syntax. This way we can determine which part of the syntax (tree) had most matches.- Specified by:
getMatchCountin interfaceMatchCountAccessor- Specified by:
getMatchCountin interfaceTerm- Returns:
- The number of args matching the according syntax (tree).
-
reset
public void reset()- Specified by:
resetin interfaceorg.refcodes.mixin.Resetable
-
toOperand
Traverses the hierarchy ofConditiontree and returns the (first) operand matching the given alias and type. -
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.
-
toSchema
-
toString
-
toSyntax
This method is to be called from inside theTermhierarchy; use the methodSynopsisable.toSynopsis(SyntaxNotation)in case you invoke syntax retrieval from the rootTerm. Returns the human readable (verbose) syntax of thisTerminstance including, in case of being a node in the syntax tree (such as aCondition, the syntax of the childTerminstances. ATTENTION: As of different parenthesis settings for some notations regarding the rootTermand the childTerms, the methodTerm.toSyntax(CliContext)is called from inside theTermhierarchy. In case the syntax is to be retrieved from the rootTerm, 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 interfaceTerm- Parameters:
aCliCtx- TheCliContextfor which the syntax is being generated.- Returns:
- The human readable (verbose) command line arguments syntax.
-
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. -
getChildren
- Specified by:
getChildrenin interfaceorg.refcodes.mixin.ChildrenAccessor<Term[]>
-
getDescription
- Specified by:
getDescriptionin interfaceorg.refcodes.mixin.DescriptionAccessor
-
getException
Retrieves theArgsSyntaxExceptionexception in case invokingTerm.parseArgs(String[], CliContext)failed. The exception (and the according suppressed ones alongside the causes) does not necessarily have been thrown by theTerm.parseArgs(String[], CliContext)method depending on the semantics of theTermhanding the exception (theAnyConditionprovides any exceptions it caught even though it did not throw them as of its semantics).- Specified by:
getExceptionin interfaceorg.refcodes.exception.ExceptionAccessor<ArgsSyntaxException>- Specified by:
getExceptionin interfaceTerm- Returns:
- The
ArgsSyntaxExceptionexception occurring while parsing the arguments.
-
toArgsDiff
Creates the difference between the provided set and the providedLists therein found argument arrays subset (as ofOperand.getParsedArgs()).- Parameters:
aArgs- The set to be used for the diff operation.aArgsSubset- The subset to be used for the diff operation being the lists containing theOperandinstances whose command line arguments are to be diffed.- Returns:
- The difference between the set and the subset.
-
toArgsDiff
Creates the difference between the provided set and the providedLists therein found argument arrays subset (as ofOperand.getParsedArgs()).- Parameters:
aArgs- The set to be used for the diff operation.aArgsSubset- The subset to be used for the diff operation being the lists containing theOperandinstances whose command line arguments are to be diffed.- Returns:
- The difference between the set and the subset.
-
toArgsDiff
Creates the difference between the provided set and the provided subset.- Parameters:
aArgs- The set to be used for the diff operation.aArgsSubset- The subset to be used for the diff operation.- Returns:
- The difference between the set and the subset.
-
toParsedArgs
Takes allOperandinstances found in the providedLists and adds all therein found argument arrays (as ofOperand.getParsedArgs()) to the result.
-