users@jersey.java.net

[Jersey] Re: Supporting Optional arguments

From: Andreas Lundblad <andreas.lundblad_at_gmail.com>
Date: Mon, 24 Nov 2014 16:04:22 +0100

Seems to be some problem with the Jira / Java.net login. My old username /
password doesn't work. When trying to reset password, I don't get any
email. I created a new user and tried to log in, but firefox says "The page
isn't redirecting properly".

I'll give it a shot in a day or two.

-- Andreas

On Mon, Nov 24, 2014 at 3:29 PM, Santiago Pericas-Geertsen <
Santiago.PericasGeertsen_at_oracle.com> wrote:

>
> On Nov 23, 2014, at 10:39 AM, Andreas Lundblad <andreas.lundblad_at_gmail.com>
> wrote:
>
> If a request is made to a resource method, but one of its arguments is
> missing, Jersey accepts the request (if the parameter is of a reference
> type) and calls the method and fills in the missing arguments with 'null'.
>
> I often find it frustrating to deal with null values so I've come to do a
> lot of
>
> Optional<String> optArg1 = Optional.ofNullable(arg1);
> Optional<String> optArg2 = Optional.ofNullable(arg2);
> ...
>
> at the top of my resource methods.
>
> Has there been any discussion on adding support for Optional as argument
> type directly in Jersey?
>
>
> Not that I'm aware of. Note that Optional is a JDK 8 class. You may want
> to file an RFE for JAX-RS 2.1 which will depend on that version of the JDK.
>
> https://java.net/jira/browse/JAX_RS_SPEC/
>
> -- Santiago
>
>