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