Class OptionalIsEmptyExamples
java.lang.Object
net.jrodolfo.java_evolution.java11.OptionalIsEmptyExamples
Demonstrates
Optional.isEmpty(), introduced in Java 11.
Before Java 11, checking for absence usually meant writing
!optional.isPresent(). That works, but it expresses the idea through
negation.
isEmpty() solves this readability problem by naming the empty case
directly.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanUsesOptional.isEmpty()as the direct opposite ofOptional.isPresent().
-
Constructor Details
-
OptionalIsEmptyExamples
public OptionalIsEmptyExamples()
-
-
Method Details
-
isMissing
UsesOptional.isEmpty()as the direct opposite ofOptional.isPresent().- Parameters:
value- the Optional to inspect- Returns:
- whether the Optional has no value
-