users@jersey.java.net

[Jersey] Re: Bean Validation Oddity

From: Ted M. Young [_at_jitterted] <tedyoung_at_gmail.com>
Date: Tue, 18 Mar 2014 13:12:51 -0700

On Tue, Mar 18, 2014 at 12:23 PM, Robert DiFalco
<robert.difalco_at_gmail.com>wrote:

> Pretty much every where else I use Bean Validation it is smart enough to
> use the name of the argument as "emailAddress".



This is because Java stores (in the class files) the name of fields (the
likely "every where else" to which you refer), but parameters' names are
not saved (though in Java 8 this is possible[1]). That's why the
@QueryParam, and other parameter annotations, require a String so that they
can have a name. The arg1 comes from the standard implementation of bean
validation[2].

An alternative would be to put the email/password into, say, a User object,
which itself would have the validation annotations on it, and that would
provide you with names. Other than that, I'm not sure what else you can do
other than do the null-checking "manually" in your delete method.

[1]
http://docs.oracle.com/javase/tutorial/reflect/member/methodparameterreflection.html
[2] http://beanvalidation.org/proposals/BVAL-241/#naming


;ted
--
http://about.me/tedmyoung