判断

HeJin小于 1 分钟函数式编程Optional

isPresent

public static void main(String[] args) throws Throwable {
    Optional<Author> author = getAuthor();
    boolean present = author.isPresent();
    System.out.println(present);
}

private static Optional<Author> getAuthor() {
    //数据初始化
    Author author = new Author(1L, "蒙多", 33, "一个从菜刀中明悟哲理的祖安人", null);
    return Optional.ofNullable(null);
}

结果:

false

Process finished with exit code 0