Refactor: Extract method to check if resource path is root

Change-Id: I87c23449c929bd169daa5fe788e340266392ddbe
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java b/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java
index 7c78a9a..3aa29f6 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java
@@ -93,7 +93,7 @@
      * If there is no parent, empty instance will be returned.
      */
     public Optional<ResourcePath> parent() {
-        if (resources.size() > 0) {
+        if (!isRoot()) {
             return Optional.of(new ResourcePath(resources.subList(0, resources.size() - 1)));
         }
 
@@ -101,6 +101,15 @@
     }
 
     /**
+     * Returns true if the path represents root.
+     *
+     * @return true if the path represents root, false otherwise.
+     */
+    public boolean isRoot() {
+        return resources.size() == 0;
+    }
+
+    /**
      * Returns the last component of this instance.
      *
      * @return the last component of this instance.