Positive and Negative Annotations

@Positive

The @Positive annotation is applied to numerically typed fields to indicate that their values must be a positive number e.g.

@Option(name = "-i", title = "Integer", arity = 1)
@Positive
public long i;

Here the -i option must take a positive value.

Treatment of Zero

By default zero is considered a positive number, if you do not want this to be the case you can add includesZero = false to your annotation e.g.

@Option(name = "-i", title = "Integer", arity = 1)
@Positive(includesZero = false)
public long i;

@Negative

@Negative is the opposite of @Positive, it is applied to numeric fields to indicate that their values must be a negative number e.g.

@Option(name = "-i", title = "Integer", arity = 1)
@Negative
public long i;

Here the -i option must take a negative value.

Treatment of Zero

By default zero is considered a positive number, if you want to treat it as a negative number you can add includesZero = true to your annotation e.g.

@Option(name = "-i", title = "Integer", arity = 1)
@Negative(includesZero = true)
public long i;

For more specific value ranges on numeric fields use the various numeric range annotations - @ByteRange, @ShortRange, @IntegerRange, @LongRange, @FloatRange and @DoubleRange - to specify desired minimum and maximum values.

For limiting numeric fields to small sets of values consider the @AllowedValues annotation.


Improving this Documentation

This documentation is itself open source and lives in GitHub under the docs/ directory.

I am not a professional technical writer and as the developer of this software I can often make assumptions of knowledge that you as a user reading this may not have. Improvements to the documentation are always welcome, if you have suggestions for the documentation please submit pull requests to the main branch.