Monday, August 29, 2022
HomeWordPress DevelopmentThe right way to set default worth to question param in jax-rs

The right way to set default worth to question param in jax-rs


Use the DefaultValue annotation parameter (accepts strings) the place you set the default worth alongside the QueryParam annotation

@GET
@Path("/bookmarks")
@Produces(MediaType.APPLICATION_JSON)
@Operation(
    abstract = "Return bookmarks from repository",
    description = "Return bookmarks from repository")
@ApiResponses({
    @ApiResponse(responseCode = "200", description = "OK"),
    @ApiResponse(responseCode = "403", description = "Forbidden")
})
@RolesAllowed(ADMIN_ROLE)
public void getAllBookmarks(
    @Parameter(description = "max variety of returned bookmarks")
    @DefaultValue(Integer.MAX_VALUE + "")
    @QueryParam("maxResult") Integer maxResult) {
  bookmarksService.getBookmarks(maxResult);
}
Enter fullscreen mode

Exit fullscreen mode


Shared with ❤️ from Codever. Use 👉 copy to mine performance so as to add it to your private snippets assortment.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments