c5b33ae879b356bb47ce71ab31de80852b49818a
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / Module.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 java.net.URI;
11 import java.util.Date;
12 import java.util.List;
13 import java.util.Optional;
14 import java.util.Set;
15 import javax.annotation.Nonnull;
16 import javax.annotation.concurrent.Immutable;
17 import org.opendaylight.yangtools.concepts.SemVer;
18 import org.opendaylight.yangtools.yang.common.QNameModule;
19 import org.opendaylight.yangtools.yang.common.YangVersion;
20
21 /**
22  * This interface contains the methods for getting the data from the YANG
23  * module.<br>
24  * <br>
25  * <i>Example of YANG module</i> <code><br>
26  * {@link #getName() <b><font color="#FF0000">module</font></b>} module_name{<br>
27     &nbsp;&nbsp;{@link #getYangVersion() <b><font color="#8b4513">yang-version</font></b>} "1";<br><br>
28
29     &nbsp;&nbsp;{@link #getNamespace() <b><font color="#00FF00">namespace</font></b>} "urn:module:namespace";<br>
30     &nbsp;&nbsp;{@link #getPrefix() <b><font color="#0000FF">prefix</font></b><a name="prefix"></a>} "prefix";<br><br>
31
32     &nbsp;&nbsp;{@link #getDescription() <b><font color="#b8860b">description</font></b>} "description test";<br>
33     &nbsp;&nbsp;{@link #getReference() <b><font color="#008b8b">reference</font></b>} "reference test";<br><br>
34
35     &nbsp;&nbsp;{@link #getOrganization() <b><font color="#606060">organization</font></b>}
36     "John Doe, john.doe@email.com";<br>
37     &nbsp;&nbsp;{@link #getContact() <b><font color="#FF9900">contact</font></b>} "http://www.opendaylight.org/";<br>
38     <br>
39
40     &nbsp;&nbsp;{@link #getFeatures() <b><font color="#8b0000">feature</font></b>} feature-test{<br>
41     &nbsp;&nbsp;&nbsp;&nbsp; description "description of some feature";<br>
42     &nbsp;&nbsp;}<br>
43
44     &nbsp;&nbsp;{@link #getNotifications() <b><font color="#b22222">notification</font></b>} notification-test;<br>
45     &nbsp;&nbsp;{@link #getRpcs() <b><font color="#d2691e">rpc</font></b>} rpc-test;<br>
46     <!-- &nbsp;&nbsp;{@link #getDeviations() <b><font color="#b8860b">deviation</font></b>} deviation-test;<br> -->
47     &nbsp;&nbsp;{@link #getIdentities() <b><font color="#bdb76b">identity</font></b>} identity-test;<br>
48     &nbsp;&nbsp;{@link #getExtensionSchemaNodes() <b><font color="#808000">extension</font></b>} extension-test;<br>
49
50
51     &nbsp;&nbsp;{@link #getRevision() <b><font color="#339900">revision</font></b>} 2011-08-27 {<br>
52
53     &nbsp;&nbsp;{@link #getImports() <b><font color="#9400d3">import</font></b>} other_module {<br>
54     &nbsp;&nbsp;&nbsp;&nbsp;prefix "other_module_prefix"<br>
55     &nbsp;&nbsp;&nbsp;&nbsp;revision-date 2011-08-27<br>
56     &nbsp;&nbsp;}<br><br>
57
58     &nbsp;&nbsp;container cont {<br>
59     &nbsp;&nbsp;}<br>
60
61     &nbsp;&nbsp;{@link #getAugmentations() <b><font color="#dc143c">augment</font></b>} "/cont" { ;<br>
62     &nbsp;&nbsp;}<br>
63     }
64
65     </code>
66  */
67 @Immutable
68 public interface Module extends DataNodeContainer, NotificationNodeContainer {
69     /**
70      * Returns the name of the module which is specified as argument of YANG
71      * {@link Module <b><font color="#FF0000">module</font></b>} keyword.
72      *
73      * @return string with the name of the module
74      */
75     String getName();
76
77     /**
78      * Returns a {@link QNameModule}, which contains the namespace and
79      * the revision of the module.
80      *
81      * @return QNameModule identifier.
82      */
83     QNameModule getQNameModule();
84
85     /**
86      * Returns the namespace of the module which is specified as argument of
87      * YANG {@link Module <b><font color="#00FF00">namespace</font></b>}
88      * keyword. If you need both namespace and revision, please consider using
89      * {@link #getQNameModule()}.
90      *
91      * @return URI format of the namespace of the module
92      */
93     default URI getNamespace() {
94         return getQNameModule().getNamespace();
95     }
96
97     /**
98      * Returns the revision date for the module. If you need both namespace and
99      * revision, please consider using {@link #getQNameModule()}.
100      *
101      * @return date of the module revision which is specified as argument of
102      *         YANG {@link Module <b><font color="#339900">revison</font></b>}
103      *         keyword
104      */
105     // FIXME: BUG-4688: should return Optional<Revision>
106     default Optional<Date> getRevision() {
107         return getQNameModule().getRevision();
108     }
109
110     /**
111      * Returns the semantic version of yang module.
112      *
113      * <p>
114      * If the semantic version is not specified, default semantic version of
115      * module is returned.
116      *
117      * @return SemVer semantic version of yang module which is specified as
118      *         argument of
119      *         (urn:opendaylight:yang:extension:semantic-version?revision
120      *         =2016-02-02)semantic-version statement
121      */
122     Optional<SemVer> getSemanticVersion();
123
124     /**
125      * Returns the prefix of the module.
126      *
127      * @return string with the module prefix which is specified as argument of
128      *         YANG {@link Module <b><font color="#0000FF">prefix</font></b>}
129      *         keyword
130      */
131     String getPrefix();
132
133     /**
134      * Returns the YANG version.
135      *
136      * @return YANG version of this module.
137      */
138     YangVersion getYangVersion();
139
140     /**
141      * Returns the module description.
142      *
143      * @return string with the module description which is specified as argument
144      *         of YANG {@link Module <b><font
145      *         color="#b8860b">description</font></b>} keyword
146      */
147     String getDescription();
148
149     /**
150      * Returns the module reference.
151      *
152      * @return string with the module reference which is specified as argument
153      *         of YANG {@link Module <b><font
154      *         color="#008b8b">reference</font></b>} keyword
155      */
156     String getReference();
157
158     /**
159      * Returns the module organization.
160      *
161      * @return string with the name of the organization specified in the module
162      *         as the argument of YANG {@link Module <b><font
163      *         color="#606060">organization</font></b>} keyword
164      */
165     String getOrganization();
166
167     /**
168      * Returns the module contact.
169      *
170      * <p>
171      * The contact represents the person or persons to whom technical queries
172      * concerning this module should be sent, such as their name, postal
173      * address, telephone number, and electronic mail address.
174      *
175      * @return string with the contact data specified in the module as the
176      *         argument of YANG {@link Module <b><font
177      *         color="#FF9900">contact</font></b>} keyword
178      */
179     String getContact();
180
181     /**
182      * Returns imports which represents YANG modules which are imported to this
183      * module via <b>import</b> statement.
184      *
185      * @return set of module imports which are specified in the module as the
186      *         argument of YANG {@link Module <b><font
187      *         color="#9400d3">import</font></b>} keywords.
188      */
189     Set<ModuleImport> getImports();
190
191     Set<Module> getSubmodules();
192
193     /**
194      * Returns <code>FeatureDefinition</code> instances which contain data from
195      * <b>feature</b> statements defined in the module.
196      *
197      * <p>
198      * The feature is used to define a mechanism by which portions of the schema
199      * are marked as conditional.
200      *
201      * @return feature statements in lexicographical order which are specified
202      *         in the module as the argument of YANG {@link Module <b><font
203      *         color="#8b0000">feature</font></b>} keywords.
204      */
205     Set<FeatureDefinition> getFeatures();
206
207     /**
208      * Returns <code>AugmentationSchema</code> instances which contain data from
209      * <b>augment</b> statements defined in the module.
210      *
211      * @return set of the augmentation schema instances which are specified in
212      *         the module as YANG {@link Module <b><font
213      *         color="#dc143c">augment</font></b>} keyword and are
214      *         lexicographically ordered
215      */
216     Set<AugmentationSchema> getAugmentations();
217
218     /**
219      * Returns <code>RpcDefinition</code> instances which contain data from
220      * <b>rpc</b> statements defined in the module.
221      *
222      * @return set of the rpc definition instances which are specified in the
223      *         module as YANG {@link Module <b><font
224      *         color="#d2691e">rpc</font></b>} keywords and are lexicographicaly
225      *         ordered
226      */
227     Set<RpcDefinition> getRpcs();
228
229     /**
230      * Returns <code>Deviation</code> instances which contain data from
231      * <b>deviation</b> statements defined in the module.
232      *
233      * @return set of the deviation instances
234      */
235     Set<Deviation> getDeviations();
236
237     /**
238      * Returns <code>IdentitySchemaNode</code> instances which contain data from
239      * <b>identity</b> statements defined in the module.
240      *
241      * @return set of identity schema node instances which are specified in the
242      *         module as YANG {@link Module <b><font
243      *         color="#bdb76b">identity</font></b>} keywords and are
244      *         lexicographically ordered
245      */
246     Set<IdentitySchemaNode> getIdentities();
247
248     /**
249      * Returns <code>ExtensionDefinition</code> instances which contain data
250      * from <b>extension</b> statements defined in the module.
251      *
252      * @return set of extension definition instances which are specified in the
253      *         module as YANG {@link Module <b><font
254      *         color="#808000">extension</font></b>} keyword and are
255      *         lexicographically ordered
256      */
257     List<ExtensionDefinition> getExtensionSchemaNodes();
258
259     /**
260      * Returns unknown nodes defined in module.
261      *
262      * @return unknown nodes in lexicographical order
263      */
264     @Nonnull
265     List<UnknownSchemaNode> getUnknownSchemaNodes();
266 }