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.ArgGroupSpecprivate final List<CommandLine.ParseResult.GroupMatch> private final List<CommandLine.Model.ArgGroupSpec> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidaddMatch(CommandLine commandLine) (package private) booleancanMatchPositionalParam(CommandLine.Model.PositionalParamSpec positionalParam) (package private) voidcomplete(CommandLine commandLine) private booleancontainsRequiredSubgroups(CommandLine.Model.ArgGroupSpec argGroupSpec) createGroupMatchContainer(CommandLine.Model.ArgGroupSpec group, CommandLine.ParseResult.GroupMatchContainer parent, CommandLine commandLine) private voidfailGroupMultiplicityExceeded(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 theArgGroupSpecwhose matches are captured in thisGroupMatchContainer.private booleanisGroupEffectivelyOptional(CommandLine.Model.ArgGroupSpec argGroupSpec) A group is optional if its minimummultiplicityis 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 minimummultiplicityis1or more AND either the group has no required options or the group has at least one required option without a default value(package private) booleanReturnstrueif no moreMatchedGroupMultiplescan be added to thisGroupMatchContainer.(package private) booleanReturnstrueif thisGroupMatchContainerhas at least the minimum number ofMatchedGroupMultiples.(package private) CommandLine.ParseResult.GroupMatchReturns the "active" multiple of this GroupMatchContainer.private booleanmatchedFully(boolean allRequired) (package private) booleanReturnstrueif 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) booleanReturnstrueif 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 ofGroupMatchinstances:ArgGroupSpecs with a multiplicity greater than one may be matched multiple times.private booleanprivate booleansimplifyErrorMessageForSingleGroup(Map<CommandLine.Model.ArgGroupSpec, List<List<CommandLine.ParseResult.GroupMatch>>> matchesPerGroup, CommandLine commandLine) toString()private StringBuildertoString(StringBuilder result) (package private) CommandLine.ParseResult.GroupMatchContainertrim()(package private) void(package private) voidvalidate(CommandLine commandLine) private voidvalidateGroupMultiplicity(CommandLine commandLine)
-
Field Details
-
group
-
parentContainer
-
unmatchedSubgroups
-
matches
-
validationResult
-
-
Constructor Details
-
GroupMatchContainer
GroupMatchContainer(CommandLine.Model.ArgGroupSpec group, CommandLine cmd)
-
-
Method Details
-
group
Returns theArgGroupSpecwhose matches are captured in thisGroupMatchContainer. -
matches
Returns the list ofGroupMatchinstances:ArgGroupSpecs 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()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
-
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
multiplicityis zero - otherwise, if the group has at least one required option and all required options have default values
- if its minimum
multiplicityis1or 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
-