Cedric Gatay commented: https://gist.github.com/dashorst/6308833/#comment-891946 > There is nothing regarding the use of optional parameters. How > should we handle this use case, should we use multiple constructors > [1] or should we use a @DefaultValue annotation [2] to stay on par > with Jax-RS API ? > > [1] : > > @Path("/page/{req}/val/{opt}") > public class MyPage extends WebPage{ > public MyPage(@PathParam("req") String req){ > } > > public MyPage(@PathParam("req") String req, > @PathParam("opt") String opt){ > } > } > [2] : > > @Path("/page/{req}/val/{opt}") > public class MyPage extends WebPage{ > public MyPage(@PathParam("req") String req, > @DefaultValue("default") @PathParam("opt") String > opt){ > } > }
I think both options would be legal. Optional can also mean becoming null when not provided in the request. I intend to follow the semantics specified by JAX-RS to minimize the differences between their specification and our use of similar constructs. The @DefaultValue annotation is one that I intend to add to the proposal but haven't gotten around to. Martijn