I do think it's important to know the access strategy that will be used based upon the location of the validation annotation.
In section 3.1.2 "Field and property validation" it states that when the annotation is placed on the field level, the value will be accessed directly using field access. E.g., field.get(instance), but when its on the "read method" level, it'll be accessed by invoking the method. E.g., method.invoke(instance).
Why is this important? If you intend to execute logic within your get/is methods, the validator will invoke this logic when accessing the value. A good practice is to avoid placing logic in your 'read methods' anyhow.
Best Regards,
Richard L. Burton III
|