Bug 6874: [YANG 1.1] Allow "description" and "reference" in "import" and "include" 46/48246/3
authorIgor Foltin <ifoltin@cisco.com>
Wed, 9 Nov 2016 14:31:08 +0000 (15:31 +0100)
committerRobert Varga <nite@hq.sk>
Fri, 18 Nov 2016 10:17:47 +0000 (10:17 +0000)
API changes in yang-model-api.

Change-Id: Id8e2c294374b61e254fd0d023cda4e8071cc86d1
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DocumentedNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ModuleImport.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/UsesNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/DocumentationGroup.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/ImportStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/IncludeStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/EnumTypeDefinition.java
yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/SchemaContextEmitter.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedNode.java

index 876645f9654b872044f17467430e41fb483bb5c1..a3b031a08cc454e010c80e22038aacd930c43ded 100644 (file)
@@ -20,32 +20,30 @@ import javax.annotation.Nullable;
 public interface DocumentedNode {
 
     /**
-     * Returns description of the instance of the type <code>SchemaNode</code>
+     * All implementations should override this method.
+     * The default definition of this method is used only in YANG 1.0 (RFC6020) implementations of
+     * ModuleImport which do not allow a description statement.
+     * YANG import statement has been changed in YANG 1.1 (RFC7950) and can now contain a description statement.
      *
-     * @return string with textual description the node which represents the
-     *         argument of the YANG <code>description</code> substatement
+     * @return string that represents the argument of description statement
      */
-    @Nullable String getDescription();
-
-    /**
-     * Returns reference of the instance of the type <code>SchemaNode</code>
-     *
-     * The reference refers to external document that provides additional
-     * information relevant for the instance of this type.
-     *
-     * @return string with the reference to some external document which
-     *         represents the argument of the YANG <code>reference</code>
-     *         substatement
-     */
-    @Nullable String getReference();
+    // FIXME: version 2.0.0: make this method non-default
+    @Nullable default String getDescription() {
+        return null;
+    }
 
     /**
-     * Returns status of the instance of the type <code>SchemaNode</code>
+     * All implementations should override this method.
+     * The default definition of this method is used only in YANG 1.0 (RFC6020) implementations of
+     * ModuleImport which do not allow a reference statement.
+     * YANG import statement has been changed in YANG 1.1 (RFC7950) and can now contain a reference statement.
      *
-     * @return status of this node which represents the argument of the YANG
-     *         <code>status</code> substatement
+     * @return string that represents the argument of reference statement
      */
-    @Nonnull Status getStatus();
+    // FIXME: version 2.0.0: make this method non-default
+    @Nullable default String getReference() {
+        return null;
+    }
 
     /**
      * Returns unknown schema nodes which belongs to this instance.
@@ -55,4 +53,15 @@ public interface DocumentedNode {
     default @Nonnull List<UnknownSchemaNode> getUnknownSchemaNodes() {
         return ImmutableList.of();
     }
+
+    interface WithStatus extends DocumentedNode {
+
+        /**
+         * Returns status of the instance of the type <code>SchemaNode</code>
+         *
+         * @return status of this node which represents the argument of the YANG
+         *         <code>status</code> substatement
+         */
+        @Nonnull Status getStatus();
+    }
 }
index 0ef81046e37c56eb033e9e3435b9abfcb7ad2bc4..d352aeacbe866dc19ccf71b860d9f8b90f6df112 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.yangtools.concepts.SemVer;
  * another module or submodule.
  * </p>
  */
-public interface ModuleImport {
+public interface ModuleImport extends DocumentedNode {
 
     /**
      * @return Name of the module to import
@@ -40,5 +40,4 @@ public interface ModuleImport {
      * @return Prefix used to point to imported module
      */
     String getPrefix();
-
 }
index ea4f80d02dca913c25fd82ea9beda2727bf2a8a6..75df5a316fbf02c7fc9e55ce2590cb11ab0405ce 100644 (file)
@@ -13,7 +13,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 /**
  * SchemaNode represents a node in schema tree.
  */
-public interface SchemaNode extends DocumentedNode {
+public interface SchemaNode extends DocumentedNode.WithStatus {
     /**
      * Returns QName of the instance of the type <code>SchemaNode</code>.
      *
index 5979333156f8a17e1dbcc54391a6b57c84b33812..d0106cff66bf8e3f7da0740331a0196120149dd9 100644 (file)
@@ -17,7 +17,7 @@ import javax.annotation.Nonnull;
  * <code>uses</code> substatement.
  *
  */
-public interface UsesNode extends DocumentedNode {
+public interface UsesNode extends DocumentedNode.WithStatus {
 
     /**
      * Returns the schema path to used grouping.
index a6746f22c4fad0f3d0c9bc56162b55e9c32de427..ba49a849176b79e23032d5e65a1547aad890ff01 100644 (file)
@@ -11,9 +11,31 @@ import javax.annotation.Nullable;
 
 public interface DocumentationGroup {
 
-    @Nullable DescriptionStatement getDescription();
+    /**
+     * All implementations should override this method.
+     * The default definition of this method is used only in YANG 1.0 (RFC6020) implementations of
+     * ImportStatement and IncludeStatement which do not allow a description statement.
+     * These YANG statements have been changed in YANG 1.1 (RFC7950) and can now contain a description statement.
+     *
+     * @return description statement
+     */
+    // FIXME: version 2.0.0: make this method non-default
+    @Nullable default DescriptionStatement getDescription() {
+        return null;
+    }
 
-    @Nullable ReferenceStatement getReference();
+    /**
+     * All implementations should override this method.
+     * The default definition of this method is used only in YANG 1.0 (RFC6020) implementations of
+     * ImportStatement and IncludeStatement which do not allow a reference statement.
+     * These YANG statements have been changed in YANG 1.1 (RFC7950) and can now contain a reference statement.
+     *
+     * @return reference statement
+     */
+    // FIXME: version 2.0.0: make this method non-default
+    @Nullable default ReferenceStatement getReference() {
+        return null;
+    }
 
     interface WithStatus extends DocumentationGroup {
 
index 5d1550fc6dd9cee1ea57df77e520f29d6787aba7..53781bffd32b0fd53a67d39114302cb1180434a1 100644 (file)
@@ -11,7 +11,7 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
-public interface ImportStatement extends DeclaredStatement<String> {
+public interface ImportStatement extends DeclaredStatement<String>, DocumentationGroup {
 
     @Nonnull String getModule();
 
index eeead852336131e2d0377c6678cb717d85c7ff3c..2a5bda1b292c43294470e305200fa7e8d7a3ac70 100644 (file)
@@ -11,7 +11,7 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
-public interface IncludeStatement extends DeclaredStatement<String> {
+public interface IncludeStatement extends DeclaredStatement<String>, DocumentationGroup {
 
     @Nonnull String getModule();
 
index 770b5de84a5aff78a53d3622b3c1f09a97b5fa61..d27e2ba3d18f0e1b42cbb69f0184becc4d1ee6bd 100644 (file)
@@ -31,7 +31,7 @@ public interface EnumTypeDefinition extends TypeDefinition<EnumTypeDefinition> {
      * Contains the methods for accessing the data about the concrete
      * enumeration item which represents <code>enum</code> YANG type.
      */
-    interface EnumPair extends DocumentedNode {
+    interface EnumPair extends DocumentedNode.WithStatus {
         /**
          * The name to specify each assigned name of an enumeration type.
          *
index baa2dbddee139bf3b810b31f154e4e07bd7e0075..1a20b63719c29b49b8c2e491acd5f469cca944c4 100644 (file)
@@ -734,7 +734,7 @@ class SchemaContextEmitter {
         }
     }
 
-    private void emitDocumentedNode(final DocumentedNode input) {
+    private void emitDocumentedNode(final DocumentedNode.WithStatus input) {
         emitStatusNode(input.getStatus());
         emitDescriptionNode(input.getDescription());
         emitReferenceNode(input.getReference());
index ce4eeff53bf1ced17cd67884bedc1f3ec9aa2db3..d0c29ec02c901b5b0df8f4bba06c6062ee7f10ac 100644 (file)
@@ -13,7 +13,7 @@ import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 public abstract class AbstractEffectiveDocumentedNode<A, D extends DeclaredStatement<A>>
-        extends DeclaredEffectiveStatementBase<A, D> implements DocumentedNode {
+        extends DeclaredEffectiveStatementBase<A, D> implements DocumentedNode.WithStatus {
 
     private final String description;
     private final String reference;