[bv-dev] Dependency between constraints and validators
Gunnar Morling
gunnar.morling at googlemail.com
Tue Oct 25 13:36:55 EDT 2011
Ah, I wasn't aware that you had annotation processing in mind.
What I was thinking about was how to make addBinding() type safe in
that way that one can't pass a validator type not appropriate for the
constraint type, which would work using the right type parameters.
--Gunnar
2011/10/25 Emmanuel Bernard <emmanuel at hibernate.org>:
>
> On 24 oct. 2011, at 22:08, Gunnar Morling wrote:
>
>>>
>>> - we would need to list all binding via a programmatic API (that solution does break compile time checking BTW)
>>
>> Why would that break compile-time type-safety?
>
> Imagine the following code
>
> void main(args[] args) {
> ValidatorFactory factory = Validation
> .byDefaultProvider()
> .configure()
> .addBinding(NotNull.class, NumberNotNullValidator.class)
> .createValidatorFactory();
>
> public static class Address {
> @NotNull String getStreet() { ... };
> }
> }
>
> How would an annotation processor know that the factory is configured to bind NotNull with NumberNotNullValidator and thus that Address.getStreet cannot be validated?
>
>
>
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
>
More information about the beanvalidation-dev
mailing list