On 2 February 2013 15:29, Minto van der Sluis <[email protected]> wrote:

> Hi Folks,
>
> In the quickstart ToDo application I just noticed the following:
>
>     @RegEx( validation = "\\w[@&:\\-\\,\\.\\+ \\w]*" )
>     // words, spaces and selected punctuation
>     @MemberOrder( sequence = "2" )
>     public String getDescription() {
>     ...
>
> To me it seems like validation is specified on the getter method. Is
> this correct? Shouldn't this be specified on the setter or the member
> field instead?
>

I agree that it might seem a bit confusing, but at the moment all the
FacetFactory's only ever read the getter method for properties.

I don't see anything in principal for extending the FacetFactory's to also
look at fields and setters; in this particular case I could well imagine
that someone might expect the annotation to live on the setter.  The same
is true for annotations such as @MaxLength.

Another benefit of having the FacetFactory's look at the fields is that
then Lombok [1] could be configured.  This would save a lot of boilerplate,
as I know you know.

Making the change is relative straightforward, it's just a matter of doing
a lot "grunt" work to quite a lot of existing FacetFactory's.  I wouldn't
have any objection to applying any patches received, though.

And if you want to raise a ticket for this idea, please go ahead.

Cheers
Dan

[1] http://projectlombok.org/



>
> Regards,
>
> Minto
>

Reply via email to