Do not require namespace repairing
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / SchemaContext.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.model.api;
9
10 import com.google.common.base.Optional;
11 import javax.annotation.concurrent.Immutable;
12 import org.opendaylight.yangtools.yang.common.QName;
13
14 import java.net.URI;
15 import java.util.Date;
16 import java.util.Set;
17
18 /**
19  * The interface represents static view of compiled yang files,
20  * contains the methods for obtaining all the top level context
21  * data (data from all modules) like YANG notifications, extensions,
22  * operations...
23  * Instances MUST be immutable and thus usage in multi threaded
24  * environment is safe.
25  */
26 @Immutable
27 public interface SchemaContext extends ContainerSchemaNode {
28
29     public static final QName NAME = QName.create(URI.create("urn:ietf:params:xml:ns:netconf:base:1.0"), null, "data");
30
31     /**
32      * Returns data schema node instances which represents direct subnodes (like
33      * leaf, leaf-list, list, container) in all YANG modules in the context.
34      *
35      * @return set of <code>DataSchemaNode</code> instances which represents
36      *         YANG data nodes at the module top level
37      */
38     Set<DataSchemaNode> getDataDefinitions();
39
40     /**
41      * Returns modules which are part of the schema context.
42      *
43      * @return set of the modules which belong to the schema context
44      */
45     Set<Module> getModules();
46
47     /**
48      *
49      * Returns notification definition instances which are defined as the direct
50      * subelements in all YANG modules in the context.
51      *
52      * @return set of <code>NotificationDefinition</code> instances which
53      *         represents nodes defined via <code>notification</code> YANG
54      *         keyword
55      */
56     Set<NotificationDefinition> getNotifications();
57
58     /**
59      * Returns rpc definition instances which are defined as the direct
60      * subelements in all YANG modules in the context.
61      *
62      * @return set of <code>RpcDefinition</code> instances which represents
63      *         nodes defined via <code>rpc</code> YANG keyword
64      */
65     Set<RpcDefinition> getOperations();
66
67     /**
68      * Returns extencion definition instances which are defined as the direct
69      * subelements in all YANG modules in the context
70      *
71      * @return set of <code>ExtensionDefinition</code> instances which
72      *         represents nodes defined via <code>extension</code> YANG keyword
73      */
74     Set<ExtensionDefinition> getExtensions();
75
76     /**
77      * Returns module instance (from the context) with concrete name and
78      * revision date.
79      *
80      * @param name
81      *            string with the module name
82      * @param revision
83      *            date of the module revision
84      * @return module instance which has name and revision (if specified) the
85      *         same as are the values specified in parameters <code>name</code>
86      *         and <code>revision</code>. In other cases the <code>null</code>
87      *         value is returned.
88      *
89      */
90     Module findModuleByName(final String name, final Date revision);
91
92     /**
93      *
94      * Returns module instance (from the context) with concrete namespace.
95      *
96      * @param namespace
97      *            URI instance with specified namespace
98      * @return module instance which has namespace equal to the
99      *         <code>namespace</code> or <code>null</code> in other cases
100      */
101     Set<Module> findModuleByNamespace(final URI namespace);
102
103     /**
104      * Returns module instance based on given namespace and revision. If
105      * revision is not specified, returns module with newest revision.
106      *
107      * @param namespace
108      * @param revision
109      * @return
110      */
111     Module findModuleByNamespaceAndRevision(final URI namespace, final Date revision);
112
113
114     /**
115      * Get yang source code represented as string for matching
116      * {@link org.opendaylight.yangtools.yang.model.api.ModuleIdentifier}.
117      * @param moduleIdentifier must provide a non-null
118      * {@link org.opendaylight.yangtools.yang.model.api.ModuleIdentifier#getName()},
119      * other methods might return null.
120      * @return value iif matching module is found in schema context.
121      */
122     Optional<String> getModuleSource(ModuleIdentifier moduleIdentifier);
123
124     /**
125      * Get all module and submodule identifiers.
126      */
127     Set<ModuleIdentifier> getAllModuleIdentifiers();
128
129 }