Package picocli
Class CommandLine.ParseResult.GroupMatchContainer
- java.lang.Object
-
- picocli.CommandLine.ParseResult.GroupMatchContainer
-
- Enclosing class:
- CommandLine.ParseResult
public static class CommandLine.ParseResult.GroupMatchContainer extends java.lang.ObjectProvides information about anCommandLine.ArgGroupthat was matched on the command line.The
ParseResultmay have more than oneGroupMatchContainerfor anArgGroupSpec, when the group was matched more often than its maximum multiplicity. This is not necessarily a problem: the parser will add a match to the parent matched group until the maximum multiplicity of the parent group is exceeded, in which case parser will add a match to the parent's parent group, etc.Ultimately, as long as the
CommandLine.ParseResult.getGroupMatches()method does not return more than one match, the maximum number of elements is not exceeded.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description private CommandLine.Model.ArgGroupSpecgroupprivate java.util.List<CommandLine.ParseResult.GroupMatch>matchesprivate CommandLine.ParseResult.GroupMatchContainerparentContainerprivate java.util.List<CommandLine.Model.ArgGroupSpec>unmatchedSubgroupsprivate CommandLine.ParseResult.GroupValidationResultvalidationResult
-
Constructor Summary
Constructors Constructor Description GroupMatchContainer(CommandLine.Model.ArgGroupSpec group, CommandLine cmd)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddMatch(CommandLine commandLine)(package private) booleancanMatchPositionalParam(CommandLine.Model.PositionalParamSpec positionalParam)(package private) voidcomplete(CommandLine commandLine)private CommandLine.ParseResult.GroupMatchContainercreateGroupMatchContainer(CommandLine.Model.ArgGroupSpec group, CommandLine.ParseResult.GroupMatchContainer parent, CommandLine commandLine)private voidfailGroupMultiplicityExceeded(java.util.List<CommandLine.ParseResult.GroupMatch> groupMatches, CommandLine commandLine)(package private) CommandLine.ParseResult.GroupMatchContainerfindLastMatchContainer(CommandLine.Model.ArgGroupSpec group)(package private) java.util.List<CommandLine.ParseResult.GroupMatchContainer>findMatchContainers(CommandLine.Model.ArgGroupSpec group, java.util.List<CommandLine.ParseResult.GroupMatchContainer> result)private CommandLine.ParseResult.GroupMatchContainerfindOrCreateMatchingGroup(CommandLine.Model.ArgSpec argSpec, CommandLine commandLine)CommandLine.Model.ArgGroupSpecgroup()Returns theArgGroupSpecwhose matches are captured in thisGroupMatchContainer.(package private) booleanisMaxMultiplicityReached()Returnstrueif no moreMatchedGroupMultiplescan be added to thisGroupMatchContainer.(package private) booleanisMinMultiplicityReached()Returnstrueif thisGroupMatchContainerhas at least the minimum number ofMatchedGroupMultiples.(package private) CommandLine.ParseResult.GroupMatchlastMatch()Returns the "active" multiple of this GroupMatchContainer.private booleanmatchedFully(boolean allRequired)(package private) booleanmatchedMaxElements()Returnstrueif the maximum number of multiples has been matched for the multiplicity of this group, and the last multiple has matched the maximum number of elements, while all other multiples have matched at least the minimum number of elements.(package private) booleanmatchedMinElements()Returnstrueif the minimum number of multiples has been matched for the multiplicity of this group, and each multiple has matched at least the minimum number of elements.java.util.List<CommandLine.ParseResult.GroupMatch>matches()Returns the list ofGroupMatchinstances:ArgGroupSpecs with a multiplicity greater than one may be matched multiple times.private booleansimplifyErrorMessageForSingleGroup(java.util.Map<CommandLine.Model.ArgGroupSpec,java.util.List<java.util.List<CommandLine.ParseResult.GroupMatch>>> matchesPerGroup, CommandLine commandLine)java.lang.StringtoString()private java.lang.StringBuildertoString(java.lang.StringBuilder result)(package private) CommandLine.ParseResult.GroupMatchContainertrim()(package private) voidupdateUnmatchedGroups(CommandLine.Model.ArgGroupSpec group)(package private) voidvalidate(CommandLine commandLine)private voidvalidateGroupMultiplicity(CommandLine commandLine)
-
-
-
Field Detail
-
group
private final CommandLine.Model.ArgGroupSpec group
-
parentContainer
private CommandLine.ParseResult.GroupMatchContainer parentContainer
-
unmatchedSubgroups
private final java.util.List<CommandLine.Model.ArgGroupSpec> unmatchedSubgroups
-
matches
private final java.util.List<CommandLine.ParseResult.GroupMatch> matches
-
validationResult
private CommandLine.ParseResult.GroupValidationResult validationResult
-
-
Constructor Detail
-
GroupMatchContainer
GroupMatchContainer(CommandLine.Model.ArgGroupSpec group, CommandLine cmd)
-
-
Method Detail
-
group
public CommandLine.Model.ArgGroupSpec group()
Returns theArgGroupSpecwhose matches are captured in thisGroupMatchContainer.
-
matches
public java.util.List<CommandLine.ParseResult.GroupMatch> matches()
Returns the list ofGroupMatchinstances:ArgGroupSpecs with a multiplicity greater than one may be matched multiple times.
-
addMatch
void addMatch(CommandLine commandLine)
-
complete
void complete(CommandLine commandLine)
-
lastMatch
CommandLine.ParseResult.GroupMatch lastMatch()
Returns the "active" multiple of this GroupMatchContainer.
-
isMaxMultiplicityReached
boolean isMaxMultiplicityReached()
Returnstrueif no moreMatchedGroupMultiplescan be added to thisGroupMatchContainer. Each multiple may be a complete or an incomplete match.
-
isMinMultiplicityReached
boolean isMinMultiplicityReached()
Returnstrueif thisGroupMatchContainerhas at least the minimum number ofMatchedGroupMultiples. Each multiple may be a complete or an incomplete match.
-
matchedMinElements
boolean matchedMinElements()
Returnstrueif the minimum number of multiples has been matched for the multiplicity of this group, and each multiple has matched at least the minimum number of elements.
-
matchedMaxElements
boolean matchedMaxElements()
Returnstrueif the maximum number of multiples has been matched for the multiplicity of this group, and the last multiple has matched the maximum number of elements, while all other multiples have matched at least the minimum number of elements.
-
matchedFully
private boolean matchedFully(boolean allRequired)
-
findOrCreateMatchingGroup
private CommandLine.ParseResult.GroupMatchContainer findOrCreateMatchingGroup(CommandLine.Model.ArgSpec argSpec, CommandLine commandLine)
-
createGroupMatchContainer
private CommandLine.ParseResult.GroupMatchContainer createGroupMatchContainer(CommandLine.Model.ArgGroupSpec group, CommandLine.ParseResult.GroupMatchContainer parent, CommandLine commandLine)
-
trim
CommandLine.ParseResult.GroupMatchContainer trim()
-
findMatchContainers
java.util.List<CommandLine.ParseResult.GroupMatchContainer> findMatchContainers(CommandLine.Model.ArgGroupSpec group, java.util.List<CommandLine.ParseResult.GroupMatchContainer> result)
-
findLastMatchContainer
CommandLine.ParseResult.GroupMatchContainer findLastMatchContainer(CommandLine.Model.ArgGroupSpec group)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toString
private java.lang.StringBuilder toString(java.lang.StringBuilder result)
-
updateUnmatchedGroups
void updateUnmatchedGroups(CommandLine.Model.ArgGroupSpec group)
-
validate
void validate(CommandLine commandLine)
-
failGroupMultiplicityExceeded
private void failGroupMultiplicityExceeded(java.util.List<CommandLine.ParseResult.GroupMatch> groupMatches, CommandLine commandLine)
-
simplifyErrorMessageForSingleGroup
private boolean simplifyErrorMessageForSingleGroup(java.util.Map<CommandLine.Model.ArgGroupSpec,java.util.List<java.util.List<CommandLine.ParseResult.GroupMatch>>> matchesPerGroup, CommandLine commandLine)
-
validateGroupMultiplicity
private void validateGroupMultiplicity(CommandLine commandLine)
-
canMatchPositionalParam
boolean canMatchPositionalParam(CommandLine.Model.PositionalParamSpec positionalParam)
-
-