Un-deprecate CopyableNode, AddedByUsesAware
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / ModuleImport.java
index 0ef81046e37c56eb033e9e3435b9abfcb7ad2bc4..4a135bb4a2d6d8d6098fd665fd2786c6d9549cd2 100644 (file)
@@ -7,38 +7,49 @@
  */
 package org.opendaylight.yangtools.yang.model.api;
 
-import java.util.Date;
+import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
 
 /**
- * Interface describing YANG 'import' statement.
- * <p>
- * The import statement makes definitions from one module available inside
+ * Interface describing YANG 'import' statement. The import statement makes definitions from one module available inside
  * another module or submodule.
- * </p>
  */
-public interface ModuleImport {
-
+// FIXME: 7.0.0: this class is a leak of the declared world into the effective one. In effective world, all nodes form
+//               a tree, which consists of multiple (mostly) QName-navigated namespaces. As such module imports
+//               contribute only a prefix/QNameModule mapping to the effective world and hence should be mapped that
+//               way:
+//               - Module exposes String->QNameModule mapping
+public interface ModuleImport extends DocumentedNode, EffectiveStatementEquivalent<ImportEffectiveStatement> {
     /**
+     * Returns the name of the module to import.
+     *
      * @return Name of the module to import
      */
-    String getModuleName();
+    default @NonNull String getModuleName() {
+        return asEffectiveStatement().argument();
+    }
 
     /**
+     * Returns the module revision to import. May be null.
+     *
      * @return Revision of module to import
      */
-    Date getRevision();
+    Optional<Revision> getRevision();
 
     /**
+     * Returns the semantic version to import.
+     *
      * @return Semantic version of module to import
      */
-    default SemVer getSemanticVersion() {
-        return Module.DEFAULT_SEMANTIC_VERSION;
-    }
+    Optional<SemVer> getSemanticVersion();
 
     /**
+     * Returns the prefix associated with the imported module.
+     *
      * @return Prefix used to point to imported module
      */
-    String getPrefix();
-
+    @NonNull String getPrefix();
 }