users@jersey.java.net

[Jersey] Supporting Optional arguments

From: Andreas Lundblad <andreas.lundblad_at_gmail.com>
Date: Sun, 23 Nov 2014 16:39:50 +0100

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?

best regards,
Andreas Lundblad