With following code,
@Option(name = "age") // min = "1"
private int age;
How can I validate age
field? Say must be bigger than zero?
You can place Option
annotation on the method of the form void methodName(T value)
.
So you can easily do it in the following way.
private int age;
@Option(name = "age")
void setAge(int age) {
if (age < 1) {
throw new CmdLineException("message");
}
this.age = age;
}