public static class CommandLine.Arity
extends java.lang.Object
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 |
---|
Arity(int min,
int max,
boolean variable,
boolean unspecified,
java.lang.String originalValue)
Constructs a new Arity object with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object object) |
static CommandLine.Arity |
forOption(java.lang.reflect.Field field)
Returns a new
Arity based on the Option annotation on the specified field, or the field type if no
arity was specified. |
static CommandLine.Arity |
forParameters(java.lang.reflect.Field field)
Returns a new
Arity based on the Parameters annotation on the specified field, or the field type
if no arity was specified. |
static CommandLine.Arity |
forType(java.lang.Class<?> type)
Returns a new
Arity based on the specified type: booleans have arity 0, arrays or Collections have
arity "0..*", and other types have arity 1. |
int |
hashCode() |
CommandLine.Arity |
max(int newMax)
Returns a new Arity object with the
max value replaced by the specified value. |
CommandLine.Arity |
min(int newMin)
Returns a new Arity object with the
min value replaced by the specified value. |
java.lang.String |
toString() |
static CommandLine.Arity |
valueOf(java.lang.String arity)
Leniently parses the specified String as an
Arity value and return the result. |
public final int min
public final int max
public final boolean isVariable
public Arity(int min, int max, boolean variable, boolean unspecified, java.lang.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.Arity forOption(java.lang.reflect.Field field)
Arity
based on the Option annotation on the specified field, or the field type if no
arity was specified.field
- the field whose Option annotation to inspectArity
based on the Option annotation on the specified fieldpublic static CommandLine.Arity forParameters(java.lang.reflect.Field field)
Arity
based on the Parameters annotation on the specified field, or the field type
if no arity was specified.field
- the field whose Parameters annotation to inspectArity
based on the Parameters annotation on the specified fieldpublic static CommandLine.Arity forType(java.lang.Class<?> type)
Arity
based on the specified type: booleans have arity 0, arrays or Collections have
arity "0..*", and other types have arity 1.type
- the type whose default arity to returnArity
based on the specified typepublic static CommandLine.Arity valueOf(java.lang.String arity)
Arity
value and return the result. An arity 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
arity is taken to be variable and the maximum is Integer.MAX_VALUE
.arity
- the arity string to parseArity
valuepublic CommandLine.Arity min(int newMin)
min
value replaced by the specified value.newMin
- the min
value of the returned Arity objectmin
value, all other values are keptpublic CommandLine.Arity max(int newMax)
max
value replaced by the specified value.newMax
- the max
value of the returned Arity objectmax
value, all other values are keptpublic boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object