virajjasani commented on a change in pull request #2990:
URL: https://github.com/apache/hadoop/pull/2990#discussion_r630302485
##########
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 think this is nice, perhaps I can directly give link to Optional and
Optional#empty() as well.
##########
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:
Sounds good. Let me update.
--
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]