Un-deprecate CopyableNode, AddedByUsesAware
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / ModuleImport.java
index eceb2fa6bce2ab85b807c13f6828043c243ebf52..4a135bb4a2d6d8d6098fd665fd2786c6d9549cd2 100644 (file)
@@ -1,36 +1,55 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.yang.model.api;\r
-\r
-import java.util.Date;\r
-\r
-/**\r
- * Interface describing YANG 'import' statement.\r
- * <p>\r
- * The import statement makes definitions from one module available inside\r
- * another module or submodule.\r
- * </p>\r
- */\r
-public interface ModuleImport {\r
-\r
-    /**\r
-     * @return Name of the module to import\r
-     */\r
-    String getModuleName();\r
-\r
-    /**\r
-     * @return Revision of module to import\r
-     */\r
-    Date getRevision();\r
-\r
-    /**\r
-     * @return Prefix used to point to imported module\r
-     */\r
-    String getPrefix();\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.model.api;
+
+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. The import statement makes definitions from one module available inside
+ * another module or submodule.
+ */
+// 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
+     */
+    default @NonNull String getModuleName() {
+        return asEffectiveStatement().argument();
+    }
+
+    /**
+     * Returns the module revision to import. May be null.
+     *
+     * @return Revision of module to import
+     */
+    Optional<Revision> getRevision();
+
+    /**
+     * Returns the semantic version to import.
+     *
+     * @return Semantic version of module to import
+     */
+    Optional<SemVer> getSemanticVersion();
+
+    /**
+     * Returns the prefix associated with the imported module.
+     *
+     * @return Prefix used to point to imported module
+     */
+    @NonNull String getPrefix();
+}