Bug 6873: [YANG 1.1] Support for "require-instance" in leafref 83/47983/3
authorIgor Foltin <ifoltin@cisco.com>
Wed, 2 Nov 2016 12:35:38 +0000 (13:35 +0100)
committerRobert Varga <nite@hq.sk>
Mon, 14 Nov 2016 07:41:54 +0000 (07:41 +0000)
API changes in yang-model-api.

Change-Id: I1144726d2039137335a955555890dbff5e0c6b45
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/TypeStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/LeafrefTypeDefinition.java

index 4f4c236ab81a161be24b11e3ff02890f91ed24b2..9d44a6bd684d1365213f15e58fc472eadf2acdc4 100644 (file)
@@ -49,6 +49,19 @@ public interface TypeStatement extends DeclaredStatement<String> {
     interface LeafrefSpecification extends TypeStatement {
 
         @Nonnull PathStatement getPath();
+
+        /**
+         * All implementations should override this method.
+         * The default definition of this method is used only in YANG 1.0 (RFC6020) implementation of
+         * LeafrefSpecification which does not support require-instance statement.
+         * YANG leafref type has been changed in YANG 1.1 (RFC7950) and now allows require-instance statement.
+         *
+         * @return require-instance statement
+         */
+         // FIXME: version 2.0.0: make this method non-default
+        @Nullable default RequireInstanceStatement getRequireInstance() {
+            return null;
+        }
     }
 
     @Rfc6020AbnfRule("instanceidentifier-specification")
index 1a89ff16151e1006883690834f3983cdea6aefa1..587ade58eb7efdbc6d13efa755db7f0b5d0c49ca 100644 (file)
@@ -13,4 +13,17 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 public interface LeafrefTypeDefinition extends TypeDefinition<LeafrefTypeDefinition> {
 
     RevisionAwareXPath getPathStatement();
+
+    /**
+     * All implementations should override this method.
+     * The default definition of this method is used only in YANG 1.0 (RFC6020) implementation of
+     * LeafrefTypeDefinition which does not support require-instance statement.
+     * YANG leafref type has been changed in YANG 1.1 (RFC7950) and now allows require-instance statement.
+     *
+     * @return boolean value which is true if the <code>require-instance</code> statement is true and vice versa
+     */
+     // FIXME: version 2.0.0: make this method non-default
+    default boolean requireInstance() {
+        return true;
+    }
 }