public static class CommandLine.Range extends Object implements Comparable<CommandLine.Range>
Modifier and Type | Field and Description |
---|---|
boolean |
isVariable |
int |
max
Maximum accepted number of parameters for an option or positional parameter.
|
int |
min
Required number of parameters for an option or positional parameter.
|
Constructor and Description |
---|
Range(int min,
int max,
boolean variable,
boolean unspecified,
String originalValue)
Constructs a new Range object with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(CommandLine.Range other) |
boolean |
contains(int value)
Returns
true if this Range includes the specified value, false otherwise. |
static CommandLine.Range |
defaultArity(Class<?> type)
Returns the default arity
Range for options : booleans have arity 0, other types have arity 1. |
static CommandLine.Range |
defaultArity(Field field)
Returns the default arity
Range : for options this is 0 for booleans and 1 for
other types, for parameters booleans have arity 0, arrays or Collections have
arity "0..*", and other types have arity 1. |
boolean |
equals(Object object) |
int |
hashCode() |
CommandLine.Range |
max(int newMax)
Returns a new Range object with the
max value replaced by the specified value. |
CommandLine.Range |
min(int newMin)
Returns a new Range object with the
min value replaced by the specified value. |
static CommandLine.Range |
optionArity(Field field)
Returns a new
Range based on the CommandLine.Option.arity() annotation on the specified field,
or the field type's default arity if no arity was specified. |
static CommandLine.Range |
parameterArity(Field field)
Returns a new
Range based on the CommandLine.Parameters.arity() annotation on the specified field,
or the field type's default arity if no arity was specified. |
static CommandLine.Range |
parameterIndex(Field field)
Returns a new
Range based on the CommandLine.Parameters.index() annotation on the specified field. |
String |
toString() |
static CommandLine.Range |
valueOf(String range)
Leniently parses the specified String as an
Range value and return the result. |
public final int min
public final int max
public final boolean isVariable
public Range(int min, int max, boolean variable, boolean unspecified, String originalValue)
min
- minimum number of required parametersmax
- maximum number of allowed parameters (or Integer.MAX_VALUE if variable)variable
- true
if any number or parameters is allowed, false
otherwiseunspecified
- true
if no arity was specified on the option/parameter (value is based on type)originalValue
- the original value that was specified on the option or parameterpublic static CommandLine.Range optionArity(Field field)
Range
based on the CommandLine.Option.arity()
annotation on the specified field,
or the field type's default arity if no arity was specified.field
- the field whose Option annotation to inspectRange
based on the Option arity annotation on the specified fieldpublic static CommandLine.Range parameterArity(Field field)
Range
based on the CommandLine.Parameters.arity()
annotation on the specified field,
or the field type's default arity if no arity was specified.field
- the field whose Parameters annotation to inspectRange
based on the Parameters arity annotation on the specified fieldpublic static CommandLine.Range parameterIndex(Field field)
Range
based on the CommandLine.Parameters.index()
annotation on the specified field.field
- the field whose Parameters annotation to inspectRange
based on the Parameters index annotation on the specified fieldpublic static CommandLine.Range defaultArity(Field field)
Range
: for options
this is 0 for booleans and 1 for
other types, for parameters
booleans have arity 0, arrays or Collections have
arity "0..*", and other types have arity 1.field
- the field whose default arity to returnRange
indicating the default arity of the specified fieldpublic static CommandLine.Range defaultArity(Class<?> type)
Range
for options
: booleans have arity 0, other types have arity 1.type
- the type whose default arity to returnRange
indicating the default arity of the specified typepublic static CommandLine.Range valueOf(String range)
Range
value and return the result. A range string can
be a fixed integer value or a range of the form MIN_VALUE + ".." + MAX_VALUE
. If the
MIN_VALUE
string is not numeric, the minimum is zero. If the MAX_VALUE
is not numeric, the
range is taken to be variable and the maximum is Integer.MAX_VALUE
.range
- the value range string to parseRange
valuepublic CommandLine.Range min(int newMin)
min
value replaced by the specified value.
The max
of the returned Range is guaranteed not to be less than the new min
value.newMin
- the min
value of the returned Range objectmin
valuepublic CommandLine.Range max(int newMax)
max
value replaced by the specified value.
The min
of the returned Range is guaranteed not to be greater than the new max
value.newMax
- the max
value of the returned Range objectmax
valuepublic boolean contains(int value)
true
if this Range includes the specified value, false
otherwise.value
- the value to checktrue
if the specified value is not less than the minimum and not greater than the maximum of this Rangepublic int compareTo(CommandLine.Range other)
compareTo
in interface Comparable<CommandLine.Range>
Copyright © 1999-2020 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.