[hibernate-dev] Annotation Processor for HV
Emmanuel Bernard
emmanuel at hibernate.org
Fri Dec 4 03:31:16 EST 2009
On 3 déc. 09, at 23:09, Gunnar Morling wrote:
> 2009/12/3 Emmanuel Bernard <emmanuel at hibernate.org>
> For sole determination of allowed types for constraint annotations
> you wouldn't need any validator implementations (or HV core) on the
> AP classpath when working with the mirror API, just BV API and the
> AP itself.
>
> You do. Otherwise how do you make custom constraint work?
>
> Actually not. From an element annotated with a constraint annotation
> you can
> - get the annotation mirrors
> - filter on those annotated themselves with @Constraint
> - retrieve the element value with name "validatedBy"
> - retrieve the type mirrors contained
> - retrieve the value of the 2nd type argument and check the type of
> the annotated element against it
The classes referenced by the validatedBy *are* the validator classes
at least if by validator you mean ConstraintVaildator implementation
of the custom constraint, so they have to be in the classpath to be
mirrored by the AP machinery :)
For built-in types it's a bit different as the @Constraint is not
filled up and has to be simulated.
More information about the hibernate-dev
mailing list