public <U> Optional<U> map(Function<? super T, ? extends U> mapper) {
        Objects.requireNonNull(mapper);
        if (!isPresent())
            return empty();
        else {
            return Optional.ofNullable(mapper.apply(value));
        }
    }
If a value is present, apply the provided mapping function to it,
and if the result is non-null, return an {@code Optional} describing the
result.  Otherwise return an empty {@code Optional}.

@param <U>    The type of the result of the mapping function
@param mapper a mapping function to apply to the value, if present
@return an {@code Optional} describing the result of applying a mapping
function to the value of this {@code Optional}, if a value is present,
otherwise an empty {@code Optional}
@throws NullPointerException if the mapping function is null
@apiNote This method supports post-processing on optional values, without
the need to explicitly check for a return status.  For example, the
following code traverses a stream of file names, selects one that has
not yet been processed, and then opens that file, returning an
{@code Optional<FileInputStream>}:

<pre>{@code
    Optional<FileInputStream> fis =
        names.stream().filter(name -> !isProcessedYet(name))
                      .findFirst()
                      .map(name -> new FileInputStream(name));
}</pre>
<p>
Here, {@code findFirst} returns an {@code Optional<String>}, and then
{@code map} returns an {@code Optional<FileInputStream>} for the desired
file if one exists.
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/util/Optional.java