A DESCRIPTION OF THE REQUEST :
Please add the method similar to the following to java.util.Optional:
public void ifNotPresent(Runnable cmd) {
if (value == null)
cmd.run();
}
JUSTIFICATION :
While refactoring my codebases to use Java 8 features, I have encountered situations where, I wanted to execute some code that handles the absent of an Optional value.
Please add the method similar to the following to java.util.Optional:
public void ifNotPresent(Runnable cmd) {
if (value == null)
cmd.run();
}
JUSTIFICATION :
While refactoring my codebases to use Java 8 features, I have encountered situations where, I wanted to execute some code that handles the absent of an Optional value.
- relates to
-
JDK-8071670 java.util.Optional: please add a way to specify if-else behavior
-
- Resolved
-