Make AnyDataSchemaNode.getSchemaOfAnyData() return Optional
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / Module.java
index 32eb586157b4c5443411d913ac083968c05757d0..7717e912192671fd2555f5885df9395bb4de4306 100644 (file)
@@ -7,12 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.model.api;
 
+import java.net.URI;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
 import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.YangVersion;
 
 /**
  * This interface contains the methods for getting the data from the YANG
@@ -28,8 +31,10 @@ import org.opendaylight.yangtools.concepts.SemVer;
     &nbsp;&nbsp;{@link #getDescription() <b><font color="#b8860b">description</font></b>} "description test";<br>
     &nbsp;&nbsp;{@link #getReference() <b><font color="#008b8b">reference</font></b>} "reference test";<br><br>
 
-    &nbsp;&nbsp;{@link #getOrganization() <b><font color="#606060">organization</font></b>} "John Doe, john.doe@email.com";<br>
-    &nbsp;&nbsp;{@link #getContact() <b><font color="#FF9900">contact</font></b>} "http://www.opendaylight.org/";<br><br>
+    &nbsp;&nbsp;{@link #getOrganization() <b><font color="#606060">organization</font></b>}
+    "John Doe, john.doe@email.com";<br>
+    &nbsp;&nbsp;{@link #getContact() <b><font color="#FF9900">contact</font></b>} "http://www.opendaylight.org/";<br>
+    <br>
 
     &nbsp;&nbsp;{@link #getFeatures() <b><font color="#8b0000">feature</font></b>} feature-test{<br>
     &nbsp;&nbsp;&nbsp;&nbsp; description "description of some feature";<br>
@@ -59,14 +64,65 @@ import org.opendaylight.yangtools.concepts.SemVer;
     </code>
  */
 @Immutable
-public interface Module extends DataNodeContainer, SourceStreamAware, ModuleIdentifier, NotificationNodeContainer {
+public interface Module extends DataNodeContainer, DocumentedNode, NotificationNodeContainer, NamespaceRevisionAware {
     /**
-     * Default semantic version of Module.
+     * Returns the name of the module which is specified as argument of YANG
+     * {@link Module <b><font color="#FF0000">module</font></b>} keyword.
+     *
+     * @return string with the name of the module
+     */
+    String getName();
+
+    /**
+     * Returns a {@link QNameModule}, which contains the namespace and
+     * the revision of the module.
+     *
+     * @return QNameModule identifier.
+     */
+    QNameModule getQNameModule();
+
+    /**
+     * Returns the namespace of the module which is specified as argument of
+     * YANG {@link Module <b><font color="#00FF00">namespace</font></b>}
+     * keyword. If you need both namespace and revision, please consider using
+     * {@link #getQNameModule()}.
+     *
+     * @return URI format of the namespace of the module
+     */
+    @Override
+    default URI getNamespace() {
+        return getQNameModule().getNamespace();
+    }
+
+    /**
+     * Returns the revision date for the module. If you need both namespace and
+     * revision, please consider using {@link #getQNameModule()}.
+     *
+     * @return date of the module revision which is specified as argument of
+     *         YANG {@link Module <b><font color="#339900">revison</font></b>}
+     *         keyword
      */
-    SemVer DEFAULT_SEMANTIC_VERSION = SemVer.create(0, 0, 0);
+    @Override
+    default Optional<Revision> getRevision() {
+        return getQNameModule().getRevision();
+    }
+
+    /**
+     * Returns the semantic version of yang module.
+     *
+     * <p>
+     * If the semantic version is not specified, default semantic version of
+     * module is returned.
+     *
+     * @return SemVer semantic version of yang module which is specified as
+     *         argument of
+     *         (urn:opendaylight:yang:extension:semantic-version?revision
+     *         =2016-02-02)semantic-version statement
+     */
+    Optional<SemVer> getSemanticVersion();
 
     /**
-     * Returns the prefix of the module
+     * Returns the prefix of the module.
      *
      * @return string with the module prefix which is specified as argument of
      *         YANG {@link Module <b><font color="#0000FF">prefix</font></b>}
@@ -77,13 +133,9 @@ public interface Module extends DataNodeContainer, SourceStreamAware, ModuleIden
     /**
      * Returns the YANG version.
      *
-     * Default value is 1.
-     *
-     * @return string with the module YANG version which is specified as
-     *         argument of YANG {@link Module <b> <font
-     *         color="#8b4513">yang-version</font></b>} keyword
+     * @return YANG version of this module.
      */
-    String getYangVersion();
+    YangVersion getYangVersion();
 
     /**
      * Returns the module description.
@@ -92,6 +144,7 @@ public interface Module extends DataNodeContainer, SourceStreamAware, ModuleIden
      *         of YANG {@link Module <b><font
      *         color="#b8860b">description</font></b>} keyword
      */
+    @Override
     String getDescription();
 
     /**
@@ -101,6 +154,7 @@ public interface Module extends DataNodeContainer, SourceStreamAware, ModuleIden
      *         of YANG {@link Module <b><font
      *         color="#008b8b">reference</font></b>} keyword
      */
+    @Override
     String getReference();
 
     /**
@@ -115,6 +169,7 @@ public interface Module extends DataNodeContainer, SourceStreamAware, ModuleIden
     /**
      * Returns the module contact.
      *
+     * <p>
      * The contact represents the person or persons to whom technical queries
      * concerning this module should be sent, such as their name, postal
      * address, telephone number, and electronic mail address.
@@ -141,6 +196,7 @@ public interface Module extends DataNodeContainer, SourceStreamAware, ModuleIden
      * Returns <code>FeatureDefinition</code> instances which contain data from
      * <b>feature</b> statements defined in the module.
      *
+     * <p>
      * The feature is used to define a mechanism by which portions of the schema
      * are marked as conditional.
      *
@@ -159,7 +215,7 @@ public interface Module extends DataNodeContainer, SourceStreamAware, ModuleIden
      *         color="#dc143c">augment</font></b>} keyword and are
      *         lexicographically ordered
      */
-    Set<AugmentationSchema> getAugmentations();
+    Set<AugmentationSchemaNode> getAugmentations();
 
     /**
      * Returns <code>RpcDefinition</code> instances which contain data from
@@ -201,22 +257,4 @@ public interface Module extends DataNodeContainer, SourceStreamAware, ModuleIden
      *         lexicographically ordered
      */
     List<ExtensionDefinition> getExtensionSchemaNodes();
-
-    /**
-     * Returns unknown nodes defined in module.
-     *
-     * @return unknown nodes in lexicographical order
-     */
-    @Nonnull
-    List<UnknownSchemaNode> getUnknownSchemaNodes();
-
-    /**
-     * Get YANG source.
-     *
-     * @return YANG text of this module, or null if the source is not available.
-     * @deprecated Use {@link org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository#getSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier, Class)}
-     *             instead.
-     */
-    @Deprecated
-    @Nullable String getSource();
 }