Enforce SchemaPath correctness 03/27203/4
authorRobert Varga <rovarga@cisco.com>
Thu, 28 May 2015 11:43:12 +0000 (13:43 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 1 Oct 2015 10:19:13 +0000 (10:19 +0000)
SchemaPath must never contain a null element unless it is ROOT or SAME.
Current implementation allows that to happen by checking for null items
in the collections/lists it gets from the user.

Change-Id: Ibb85f84f54ad9c9049ac2ce8bb88371942b16880
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaPath.java

index 04975deefafc9a6936a2bd9bacd29610bace8980..9601a3910fa265b26d2023b3010981107b335242 100644 (file)
@@ -42,7 +42,7 @@ public abstract class SchemaPath implements Immutable {
 
         @Override
         protected SchemaPath createInstance(final SchemaPath parent, final QName qname) {
-            return new AbsoluteSchemaPath(parent, qname);
+            return new AbsoluteSchemaPath(parent, Preconditions.checkNotNull(qname));
         }
     }
 
@@ -61,7 +61,7 @@ public abstract class SchemaPath implements Immutable {
 
         @Override
         protected SchemaPath createInstance(final SchemaPath parent, final QName qname) {
-            return new RelativeSchemaPath(parent, qname);
+            return new RelativeSchemaPath(parent, Preconditions.checkNotNull(qname));
         }
     }
 
@@ -100,6 +100,12 @@ public abstract class SchemaPath implements Immutable {
      */
     private volatile ImmutableList<QName> legacyPath;
 
+    /**
+     * @deprecated This constructor will be hidden in a future release.
+     * @param parent
+     * @param qname
+     */
+    @Deprecated
     protected SchemaPath(final SchemaPath parent, final QName qname) {
         this.parent = parent;
         this.qname = qname;