|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||
@Retention(value=SOURCE) @Target(value=METHOD) public @interface ImmutableValidator
Annotation defining which method is to be used to validate the bean when code generating immutable beans.
Each property in a bean can be independently validated. This annotation allows properties to be cross-checked at the end of the constructor.
The method must be a private void instance method and take no arguments. Private is necessary as it is called from the constructor. For example:
@ImmutableValidator
private void validate() {
if (age != null && age < 0) {
throw new IllegalArgumentException("Age must not be negative if specified")
}
}
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||