Package picocli
Class CommandLine.ParseResult.GroupMatchContainer
java.lang.Object
picocli.CommandLine.ParseResult.GroupMatchContainer
- Enclosing class:
CommandLine.ParseResult
Provides information about an
CommandLine.ArgGroup
that was matched on the command line.
The ParseResult
may have more than one GroupMatchContainer
for an ArgGroupSpec
, 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
FieldsModifier and TypeFieldDescriptionprivate final CommandLine.Model.ArgGroupSpec
private final List
<CommandLine.ParseResult.GroupMatch> private final List
<CommandLine.Model.ArgGroupSpec> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
addMatch
(CommandLine commandLine) (package private) boolean
canMatchPositionalParam
(CommandLine.Model.PositionalParamSpec positionalParam) (package private) void
complete
(CommandLine commandLine) private boolean
containsRequiredSubgroups
(CommandLine.Model.ArgGroupSpec argGroupSpec) createGroupMatchContainer
(CommandLine.Model.ArgGroupSpec group, CommandLine.ParseResult.GroupMatchContainer parent, CommandLine commandLine) private void
failGroupMultiplicityExceeded
(List<CommandLine.ParseResult.GroupMatch> groupMatches, CommandLine commandLine) (package private) CommandLine.ParseResult.GroupMatchContainer
(package private) List
<CommandLine.ParseResult.GroupMatchContainer> findMatchContainers
(CommandLine.Model.ArgGroupSpec group, List<CommandLine.ParseResult.GroupMatchContainer> result) findOrCreateMatchingGroup
(CommandLine.Model.ArgSpec argSpec, CommandLine commandLine) group()
Returns theArgGroupSpec
whose matches are captured in thisGroupMatchContainer
.private boolean
isGroupEffectivelyOptional
(CommandLine.Model.ArgGroupSpec argGroupSpec) A group is optional if its minimummultiplicity
is zero otherwise, if the group has at least one required option and all required options have default values Conversely, a group is required if if its minimummultiplicity
is1
or more AND either the group has no required options or the group has at least one required option without a default value(package private) boolean
Returnstrue
if no moreMatchedGroupMultiples
can be added to thisGroupMatchContainer
.(package private) boolean
Returnstrue
if thisGroupMatchContainer
has at least the minimum number ofMatchedGroupMultiples
.(package private) CommandLine.ParseResult.GroupMatch
Returns the "active" multiple of this GroupMatchContainer.private boolean
matchedFully
(boolean allRequired) (package private) boolean
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
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.matches()
Returns the list ofGroupMatch
instances:ArgGroupSpec
s with a multiplicity greater than one may be matched multiple times.private boolean
private boolean
simplifyErrorMessageForSingleGroup
(Map<CommandLine.Model.ArgGroupSpec, List<List<CommandLine.ParseResult.GroupMatch>>> matchesPerGroup, CommandLine commandLine) toString()
private StringBuilder
toString
(StringBuilder result) (package private) CommandLine.ParseResult.GroupMatchContainer
trim()
(package private) void
(package private) void
validate
(CommandLine commandLine) private void
validateGroupMultiplicity
(CommandLine commandLine)
-
Field Details
-
group
-
parentContainer
-
unmatchedSubgroups
-
matches
-
validationResult
-
-
Constructor Details
-
GroupMatchContainer
GroupMatchContainer(CommandLine.Model.ArgGroupSpec group, CommandLine cmd)
-
-
Method Details
-
group
Returns theArgGroupSpec
whose matches are captured in thisGroupMatchContainer
. -
matches
Returns the list ofGroupMatch
instances:ArgGroupSpec
s with a multiplicity greater than one may be matched multiple times. -
addMatch
-
complete
-
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
-
findMatchContainers
List<CommandLine.ParseResult.GroupMatchContainer> findMatchContainers(CommandLine.Model.ArgGroupSpec group, List<CommandLine.ParseResult.GroupMatchContainer> result) -
findLastMatchContainer
CommandLine.ParseResult.GroupMatchContainer findLastMatchContainer(CommandLine.Model.ArgGroupSpec group) -
toString
-
toString
-
updateUnmatchedGroups
-
validate
-
isGroupEffectivelyOptional
A group is optional if- its minimum
multiplicity
is zero - otherwise, if the group has at least one required option and all required options have default values
- if its minimum
multiplicity
is1
or more AND -
- either the group has no required options
- or the group has at least one required option without a default value
- See Also:
- its minimum
-
requiredOptionsExistAndAllHaveDefaultValues
private boolean requiredOptionsExistAndAllHaveDefaultValues(CommandLine.Model.ArgGroupSpec argGroupSpec) -
containsRequiredSubgroups
-
failGroupMultiplicityExceeded
private void failGroupMultiplicityExceeded(List<CommandLine.ParseResult.GroupMatch> groupMatches, CommandLine commandLine) -
simplifyErrorMessageForSingleGroup
private boolean simplifyErrorMessageForSingleGroup(Map<CommandLine.Model.ArgGroupSpec, List<List<CommandLine.ParseResult.GroupMatch>>> matchesPerGroup, CommandLine commandLine) -
validateGroupMultiplicity
-
canMatchPositionalParam
-