Package pro.johndunlap.getopt.annotation
Annotation Type Arg
-
@Retention(RUNTIME) @Target(FIELD) public @interface Arg
This annotation is used to mark a field as a named option(code/flag).- Author:
- John Dunlap
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description StringcategoryThe category in which the option should appear in the help message.charcodeThe single character code for the option.Class<?>collectionTypeThis is only necessary if the field is a collection.Class<? extends TypeConverter<?>>converterThis is only necessary if the field is a type that is not supported by default.StringdescriptionThe description of the option.intexitStatusIf set to a non-zero value, this is the exit status which will be set if binding fails for this property.StringflagThe name of the option.intmaxThis is ignored for fields which are not collections.intminThis is ignored for fields which are not collections.intorderThe index into the array of ordered arguments(not specified with a code/flag).booleanrequiredTrue if the option requires a value.
-
-
-
-
flag
String flag
The name of the option. This is expected to be two or more characters and hyphen cased. For example, "my-option".- Returns:
- The name of the option.
- Default:
- ""
-
-
-
min
int min
This is ignored for fields which are not collections. For collections, this is the minimum number of values that should be bound. If the number of values is less than this, an exception will be thrown. The default is 0.- Returns:
- The minimum number of values that should be bound.
- Default:
- 0
-
-
-
max
int max
This is ignored for fields which are not collections. For collections, this is the maximum number of values that should be bound. If the number of values is greater than this, an exception will be thrown. The default is 1.- Returns:
- The maximum number of values that should be bound.
- Default:
- 1
-
-
-
exitStatus
int exitStatus
If set to a non-zero value, this is the exit status which will be set if binding fails for this property. The default is 0. Setting this attribute to 0(the default) will have no effect as other properties may fail to bind even if this one succeeds.- Returns:
- The exit status which will be set if binding fails for this property.
- Default:
- 0
-
-
-
category
String category
The category in which the option should appear in the help message. This is used in the help message.- Returns:
- The category of the option.
- Default:
- ""
-
-
-
description
String description
The description of the option. This is used in the help message.- Returns:
- The description of the option.
- Default:
- ""
-
-
-
collectionType
Class<?> collectionType
This is only necessary if the field is a collection. In that case, this is the type of the objects which the collection will contain. This is necessary because of Java type erasure. Generics are not available at runtime.- Returns:
- The type of the objects which the collection will contain.
- Default:
- java.lang.Object.class
-
-
-
converter
Class<? extends TypeConverter<?>> converter
This is only necessary if the field is a type that is not supported by default. In that case, this type is instantiated and used to parse the value.- Returns:
- The class of the ValueParser to use.
- Default:
- pro.johndunlap.getopt.DefaultValueParser.class
-
-