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.Object
Provides information about anCommandLine.ArgGroup
that was matched on the command line.The
ParseResult
may have more than oneGroupMatchContainer
for 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.ArgGroupSpec
group
private java.util.List<CommandLine.ParseResult.GroupMatch>
matches
private CommandLine.ParseResult.GroupMatchContainer
parentContainer
private java.util.List<CommandLine.Model.ArgGroupSpec>
unmatchedSubgroups
private CommandLine.ParseResult.GroupValidationResult
validationResult
-
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) void
addMatch(CommandLine commandLine)
(package private) boolean
canMatchPositionalParam(CommandLine.Model.PositionalParamSpec positionalParam)
(package private) void
complete(CommandLine commandLine)
private CommandLine.ParseResult.GroupMatchContainer
createGroupMatchContainer(CommandLine.Model.ArgGroupSpec group, CommandLine.ParseResult.GroupMatchContainer parent, CommandLine commandLine)
private void
failGroupMultiplicityExceeded(java.util.List<CommandLine.ParseResult.GroupMatch> groupMatches, CommandLine commandLine)
(package private) CommandLine.ParseResult.GroupMatchContainer
findLastMatchContainer(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.GroupMatchContainer
findOrCreateMatchingGroup(CommandLine.Model.ArgSpec argSpec, CommandLine commandLine)
CommandLine.Model.ArgGroupSpec
group()
Returns theArgGroupSpec
whose matches are captured in thisGroupMatchContainer
.(package private) boolean
isMaxMultiplicityReached()
Returnstrue
if no moreMatchedGroupMultiples
can be added to thisGroupMatchContainer
.(package private) boolean
isMinMultiplicityReached()
Returnstrue
if thisGroupMatchContainer
has at least the minimum number ofMatchedGroupMultiples
.(package private) CommandLine.ParseResult.GroupMatch
lastMatch()
Returns the "active" multiple of this GroupMatchContainer.private boolean
matchedFully(boolean allRequired)
(package private) boolean
matchedMaxElements()
Returnstrue
if 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) boolean
matchedMinElements()
Returnstrue
if 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 ofGroupMatch
instances:ArgGroupSpec
s with a multiplicity greater than one may be matched multiple times.private boolean
simplifyErrorMessageForSingleGroup(java.util.Map<CommandLine.Model.ArgGroupSpec,java.util.List<java.util.List<CommandLine.ParseResult.GroupMatch>>> matchesPerGroup, CommandLine commandLine)
java.lang.String
toString()
private java.lang.StringBuilder
toString(java.lang.StringBuilder result)
(package private) CommandLine.ParseResult.GroupMatchContainer
trim()
(package private) void
updateUnmatchedGroups(CommandLine.Model.ArgGroupSpec group)
(package private) void
validate(CommandLine commandLine)
private void
validateGroupMultiplicity(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 theArgGroupSpec
whose matches are captured in thisGroupMatchContainer
.
-
matches
public java.util.List<CommandLine.ParseResult.GroupMatch> matches()
Returns the list ofGroupMatch
instances:ArgGroupSpec
s 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()
Returnstrue
if no moreMatchedGroupMultiples
can be added to thisGroupMatchContainer
. Each multiple may be a complete or an incomplete match.
-
isMinMultiplicityReached
boolean isMinMultiplicityReached()
Returnstrue
if thisGroupMatchContainer
has at least the minimum number ofMatchedGroupMultiples
. Each multiple may be a complete or an incomplete match.
-
matchedMinElements
boolean matchedMinElements()
Returnstrue
if 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()
Returnstrue
if 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:
toString
in 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)
-
-