8164934: Optional.map() javadoc code example
authorpsandoz
Wed, 09 Nov 2016 10:36:32 -0800
changeset 41963 1bcc32e6e324
parent 41962 a52f798399ca
child 41964 46494c43f5e6
8164934: Optional.map() javadoc code example Reviewed-by: forax, chegar
jdk/src/java.base/share/classes/java/util/Optional.java
--- a/jdk/src/java.base/share/classes/java/util/Optional.java	Tue Nov 08 18:02:50 2016 +0530
+++ b/jdk/src/java.base/share/classes/java/util/Optional.java	Wed Nov 09 10:36:32 2016 -0800
@@ -214,20 +214,20 @@
      * @apiNote
      * This method supports post-processing on {@code 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>}:
+     * following code traverses a stream of URIs, selects one that has not
+     * yet been processed, and creates a path from that URI, returning
+     * an {@code Optional<Path>}:
      *
      * <pre>{@code
-     *     Optional<FileInputStream> fis =
-     *         names.stream().filter(name -> !isProcessedYet(name))
+     *     Optional<Path> p =
+     *         uris.stream().filter(uri -> !isProcessedYet(uri))
      *                       .findFirst()
-     *                       .map(name -> new FileInputStream(name));
+     *                       .map(Paths::get);
      * }</pre>
      *
-     * Here, {@code findFirst} returns an {@code Optional<String>}, and then
-     * {@code map} returns an {@code Optional<FileInputStream>} for the desired
-     * file if one exists.
+     * Here, {@code findFirst} returns an {@code Optional<URI>}, and then
+     * {@code map} returns an {@code Optional<Path>} for the desired
+     * URI if one exists.
      *
      * @param mapper the mapping function to apply to a value, if present
      * @param <U> The type of the value returned from the mapping function