orElse is cleaner
This commit is contained in:
parent
e3fc47dd53
commit
9663cc09a1
|
@ -26,8 +26,8 @@ public class BookController {
|
|||
|
||||
@RequestMapping(value = "/listBooks", method = RequestMethod.GET)
|
||||
public String listBooks(Model model, @RequestParam("page") Optional<Integer> page, @RequestParam("size") Optional<Integer> size) {
|
||||
int currentPage = page.isPresent()?page.get():5;
|
||||
int pageSize = size.isPresent()?size.get():1;
|
||||
int currentPage = page.orElse(1);
|
||||
int pageSize = size.orElse(5);
|
||||
|
||||
Page<Book> bookPage = bookService.findPaginated(PageRequest.of(currentPage - 1, pageSize));
|
||||
|
||||
|
|
Loading…
Reference in New Issue