Reputation: 44929
I want to create a query param that has an alternative version. For example
/example?lastName=Smith
should be equivalent to
/example?surname=Smith
This is the code:
@GET
@Path("/example")
public Response getExample(@QueryParam(WHAT GOES HERE??) String name) {
}
How do I handle both possibilities?
Upvotes: 3
Views: 360
Reputation: 5215
There is no simple way to do this with Jax-rs annotations; you'll have to do the combination yourself. The simplest way to do this is probably within the implemenation of your endpoint:
@GET
@Path("/example")
public Response getExample(@QueryParam("lastName") String lastName,
@QueryParam("surname") String surname) {
String name = (lastName != null) ? lastName : surname;
}
Upvotes: 2