tasanuma commented on a change in pull request #2990:
URL: https://github.com/apache/hadoop/pull/2990#discussion_r630275897



##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java
##########
@@ -420,22 +421,37 @@ public String getName() {
   }
 
   /**
-   * Returns the parent of a path or null if at root.
+   * Returns the parent of a path or null if at root. Better alternative is
+   * {@link #getParentPath()} to handle nullable value for root path.
+   *
    * @return the parent of a path or null if at root
    */
   public Path getParent() {
+    return getParentUtil();
+  }
+
+  /**
+   * Returns the parent of a path as Optional or empty() if at root.
+   *
+   * @return Parent of path wrappen in Optional. empty() if at root.
+   */
+  public Optional<Path> getParentPath() {

Review comment:
       I prefer names like `getOptionalParentPath`.

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java
##########
@@ -420,22 +421,37 @@ public String getName() {
   }
 
   /**
-   * Returns the parent of a path or null if at root.
+   * Returns the parent of a path or null if at root. Better alternative is
+   * {@link #getParentPath()} to handle nullable value for root path.
+   *
    * @return the parent of a path or null if at root
    */
   public Path getParent() {
+    return getParentUtil();
+  }
+
+  /**
+   * Returns the parent of a path as Optional or empty() if at root.
+   *
+   * @return Parent of path wrappen in Optional. empty() if at root.

Review comment:
       I prefer to explain `empty()` in words.
   ```suggestion
      * Returns the parent of a path as Optional or an empty Optional if at 
root.
      *
      * @return Parent of path wrapped in Optional. An empty Optional if at 
root.
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to