If a value is present, returns the value, otherwise throws NoSuchElementException.
If a value is present, performs the given action with the value, otherwise does nothing.
If a value is present, performs the given action with the value, otherwise performs the given empty-based action.
If a value is not present, returns true, otherwise false.
If a value is present, returns true, otherwise false.
If a value is present, returns an Optional describing (as if by [[Optional.ofNullable]]) the result of applying the given mapping function to the value, otherwise returns an empty Optional.
If you're familiar with JavaScript, you know that Array.prototype.map()
works like a factory. You supply it with an input set, it applies the same process to each item, then it outputs them as an array.
Optional.map()
is the same concept, except instead of taking and returning arrays, it takes and returns single items.
If a value is present, returns the value, otherwise throws NoSuchElementException.
Static
emptyStatic
ofStatic
of
A container object which may or may not contain a non-null value. If a value is present, isPresent() returns true. If no value is present, the object is considered empty and isPresent() returns false.
See
async-optional
for a JavaScript implementation of Java Optional.See java.util.Optional for full documentation