Merge "BUG-994: reorganize SchemaPath into a tree"
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / SchemaContext.java
index 1555bbb38ff5b12cf149cea73310d63bc87fcd85..ecafe233a4fa210b52943408f63a7d0ba7e03964 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.model.api;
 
+import com.google.common.base.Optional;
+import org.opendaylight.yangtools.yang.common.QName;
+
 import java.net.URI;
 import java.util.Date;
 import java.util.Set;
@@ -16,12 +19,14 @@ import java.util.Set;
  * data (data from all red modules) like YANG notifications, extensions,
  * operations...
  */
-public interface SchemaContext {
+public interface SchemaContext extends ContainerSchemaNode {
+
+    public static final QName NAME = QName.create(URI.create("urn:ietf:params:xml:ns:netconf:base:1.0"), null, "data");
 
     /**
      * Returns data schema node instances which represents direct subnodes (like
      * leaf, leaf-list, list, container) in all YANG modules in the context.
-     * 
+     *
      * @return set of <code>DataSchemaNode</code> instances which represents
      *         YANG data nodes at the module top level
      */
@@ -29,16 +34,16 @@ public interface SchemaContext {
 
     /**
      * Returns modules which are part of the schema context.
-     * 
+     *
      * @return set of the modules which belong to the schema context
      */
     Set<Module> getModules();
 
     /**
-     * 
+     *
      * Returns notification definition instances which are defined as the direct
      * subelements in all YANG modules in the context.
-     * 
+     *
      * @return set of <code>NotificationDefinition</code> instances which
      *         represents nodes defined via <code>notification</code> YANG
      *         keyword
@@ -48,7 +53,7 @@ public interface SchemaContext {
     /**
      * Returns rpc definition instances which are defined as the direct
      * subelements in all YANG modules in the context.
-     * 
+     *
      * @return set of <code>RpcDefinition</code> instances which represents
      *         nodes defined via <code>rpc</code> YANG keyword
      */
@@ -57,7 +62,7 @@ public interface SchemaContext {
     /**
      * Returns extencion definition instances which are defined as the direct
      * subelements in all YANG modules in the context
-     * 
+     *
      * @return set of <code>ExtensionDefinition</code> instances which
      *         represents nodes defined via <code>extension</code> YANG keyword
      */
@@ -66,7 +71,7 @@ public interface SchemaContext {
     /**
      * Returns module instance (from the context) with concrete name and
      * revision date.
-     * 
+     *
      * @param name
      *            string with the module name
      * @param revision
@@ -75,18 +80,45 @@ public interface SchemaContext {
      *         same as are the values specified in parameters <code>name</code>
      *         and <code>revision</code>. In other cases the <code>null</code>
      *         value is returned.
-     * 
+     *
      */
     Module findModuleByName(final String name, final Date revision);
 
     /**
-     * 
+     *
      * Returns module instance (from the context) with concrete namespace.
-     * 
+     *
      * @param namespace
      *            URI instance with specified namespace
      * @return module instance which has namespace equal to the
      *         <code>namespace</code> or <code>null</code> in other cases
      */
-    Module findModuleByNamespace(final URI namespace);
+    Set<Module> findModuleByNamespace(final URI namespace);
+
+    /**
+     * Returns module instance based on given namespace and revision. If
+     * revision is not specified, returns module with newest revision.
+     *
+     * @param namespace
+     * @param revision
+     * @return
+     */
+    Module findModuleByNamespaceAndRevision(final URI namespace, final Date revision);
+
+
+    /**
+     * Get yang source code represented as string for matching
+     * {@link org.opendaylight.yangtools.yang.model.api.ModuleIdentifier}.
+     * @param moduleIdentifier must provide a non-null
+     * {@link org.opendaylight.yangtools.yang.model.api.ModuleIdentifier#getName()},
+     * other methods might return null.
+     * @return value iif matching module is found in schema context.
+     */
+    Optional<String> getModuleSource(ModuleIdentifier moduleIdentifier);
+
+    /**
+     * Get all module and submodule identifiers.
+     */
+    Set<ModuleIdentifier> getAllModuleIdentifiers();
+
 }