If a value is present and matches the predicate, returns this Optional; otherwise returns an empty Optional.
Example:
var opt = Optional.of<string> ("hello");
var filtered = opt.filter ((s) => { return s == "hello"; });
assert (filtered.isPresent ());
| predicate |
the condition to test. |
|
this Optional if matching, otherwise empty. |