Class CommandLine.Range
java.lang.Object
org.apache.logging.log4j.core.tools.picocli.CommandLine.Range
- All Implemented Interfaces:
Comparable<CommandLine.Range>
- Enclosing class:
CommandLine
Describes the number of parameters required and accepted by an option or a positional parameter.
- Since:
- 0.9.7
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal booleanfinal intMaximum accepted number of parameters for an option or positional parameter.final intRequired number of parameters for an option or positional parameter. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(CommandLine.Range other) booleancontains(int value) Returnstrueif this Range includes the specified value,falseotherwise.static CommandLine.RangedefaultArity(Class<?> type) Returns the default arityRangeforoptions: booleans have arity 0, other types have arity 1.static CommandLine.RangedefaultArity(Field field) Returns the default arityRange: foroptionsthis is 0 for booleans and 1 for other types, forparametersbooleans have arity 0, arrays or Collections have arity "0..*", and other types have arity 1.booleaninthashCode()max(int newMax) Returns a new Range object with themaxvalue replaced by the specified value.min(int newMin) Returns a new Range object with theminvalue replaced by the specified value.static CommandLine.RangeoptionArity(Field field) Returns a newRangebased on theCommandLine.Option.arity()annotation on the specified field, or the field type's default arity if no arity was specified.static CommandLine.RangeparameterArity(Field field) Returns a newRangebased on theCommandLine.Parameters.arity()annotation on the specified field, or the field type's default arity if no arity was specified.static CommandLine.RangeparameterIndex(Field field) Returns a newRangebased on theCommandLine.Parameters.index()annotation on the specified field.toString()static CommandLine.RangeLeniently parses the specified String as anRangevalue and return the result.
-
Field Details
-
min
public final int minRequired number of parameters for an option or positional parameter. -
max
public final int maxMaximum accepted number of parameters for an option or positional parameter. -
isVariable
public final boolean isVariable
-
-
Constructor Details
-
Range
Constructs a new Range object with the specified parameters.- Parameters:
min- minimum number of required parametersmax- maximum number of allowed parameters (or Integer.MAX_VALUE if variable)variable-trueif any number or parameters is allowed,falseotherwiseunspecified-trueif no arity was specified on the option/parameter (value is based on type)originalValue- the original value that was specified on the option or parameter
-
-
Method Details
-
optionArity
Returns a newRangebased on theCommandLine.Option.arity()annotation on the specified field, or the field type's default arity if no arity was specified.- Parameters:
field- the field whose Option annotation to inspect- Returns:
- a new
Rangebased on the Option arity annotation on the specified field
-
parameterArity
Returns a newRangebased on theCommandLine.Parameters.arity()annotation on the specified field, or the field type's default arity if no arity was specified.- Parameters:
field- the field whose Parameters annotation to inspect- Returns:
- a new
Rangebased on the Parameters arity annotation on the specified field
-
parameterIndex
Returns a newRangebased on theCommandLine.Parameters.index()annotation on the specified field.- Parameters:
field- the field whose Parameters annotation to inspect- Returns:
- a new
Rangebased on the Parameters index annotation on the specified field
-
defaultArity
Returns the default arityRange: foroptionsthis is 0 for booleans and 1 for other types, forparametersbooleans have arity 0, arrays or Collections have arity "0..*", and other types have arity 1.- Parameters:
field- the field whose default arity to return- Returns:
- a new
Rangeindicating the default arity of the specified field - Since:
- 2.0
-
defaultArity
Returns the default arityRangeforoptions: booleans have arity 0, other types have arity 1.- Parameters:
type- the type whose default arity to return- Returns:
- a new
Rangeindicating the default arity of the specified type
-
valueOf
Leniently parses the specified String as anRangevalue and return the result. A range string can be a fixed integer value or a range of the formMIN_VALUE + ".." + MAX_VALUE. If theMIN_VALUEstring is not numeric, the minimum is zero. If theMAX_VALUEis not numeric, the range is taken to be variable and the maximum isInteger.MAX_VALUE.- Parameters:
range- the value range string to parse- Returns:
- a new
Rangevalue
-
min
Returns a new Range object with theminvalue replaced by the specified value. Themaxof the returned Range is guaranteed not to be less than the newminvalue.- Parameters:
newMin- theminvalue of the returned Range object- Returns:
- a new Range object with the specified
minvalue
-
max
Returns a new Range object with themaxvalue replaced by the specified value. Theminof the returned Range is guaranteed not to be greater than the newmaxvalue.- Parameters:
newMax- themaxvalue of the returned Range object- Returns:
- a new Range object with the specified
maxvalue
-
contains
public boolean contains(int value) Returnstrueif this Range includes the specified value,falseotherwise.- Parameters:
value- the value to check- Returns:
trueif the specified value is not less than the minimum and not greater than the maximum of this Range
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<CommandLine.Range>
-