Promote Absolute.{last,first}NodeIdentifier
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / stmt / SchemaNodeIdentifier.java
index 0801729c51ce1c667bceb4128a5de532d0986684..dd4c0cb624f3bb2f01c7c74c9a9b7e3fe9e9fb61 100644 (file)
@@ -86,22 +86,6 @@ public abstract class SchemaNodeIdentifier implements Immutable {
             return INTERNER.intern(this);
         }
 
-        /**
-         * Return the first node identifier. This method is equivalent to {@code getNodeIdentifiers().get(0)}, but is
-         * potentially more efficient.
-         *
-         * @return The first node identifier
-         */
-        public abstract @NonNull QName firstNodeIdentifier();
-
-        /**
-         * Return the last node identifier. This method is equivalent to {@code getNodeIdentifiers().get(size - 1)}, but
-         * is potentially more efficient.
-         *
-         * @return The last node identifier
-         */
-        public abstract @NonNull QName lastNodeIdentifier();
-
         @Override
         final SchemaPath implicitSchemaPathParent() {
             return SchemaPath.ROOT;
@@ -208,16 +192,6 @@ public abstract class SchemaNodeIdentifier implements Immutable {
             return qnames;
         }
 
-        @Override
-        public @NonNull QName firstNodeIdentifier() {
-            return qnames.get(0);
-        }
-
-        @Override
-        public @NonNull QName lastNodeIdentifier() {
-            return qnames.get(qnames.size() - 1);
-        }
-
         @Override
         Object pathObject() {
             return qnames;
@@ -236,6 +210,16 @@ public abstract class SchemaNodeIdentifier implements Immutable {
             return ImmutableList.of(qname);
         }
 
+        @Override
+        public QName firstNodeIdentifier() {
+            return qname;
+        }
+
+        @Override
+        public QName lastNodeIdentifier() {
+            return qname;
+        }
+
         @Override
         Object pathObject() {
             return qname;
@@ -279,6 +263,27 @@ public abstract class SchemaNodeIdentifier implements Immutable {
      */
     public abstract @NonNull List<QName> getNodeIdentifiers();
 
+    /**
+     * Return the first node identifier. This method is equivalent to {@code getNodeIdentifiers().get(0)}, but is
+     * potentially more efficient.
+     *
+     * @return The first node identifier
+     */
+    public @NonNull QName firstNodeIdentifier() {
+        return getNodeIdentifiers().get(0);
+    }
+
+    /**
+     * Return the last node identifier. This method is equivalent to {@code getNodeIdentifiers().get(size - 1)}, but
+     * is potentially more efficient.
+     *
+     * @return The last node identifier
+     */
+    public @NonNull QName lastNodeIdentifier() {
+        final List<QName> local = getNodeIdentifiers();
+        return local.get(local.size() - 1);
+    }
+
     /**
      * Create the {@link SchemaPath} equivalent of this identifier.
      *