Beginning with JDK 11, we can return a boolean if the Optional is empty via Optional#isEmpty():
public boolean bookIsEmpty(long id) { Optional book = // code that fetches the book content return book.isEmpty(); }
Visit the DevX Tip Bank