Separate out Module and Submodule interfaces
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / ModuleLike.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.annotations.Beta;
11 import java.net.URI;
12 import java.util.Collection;
13 import java.util.Optional;
14 import org.opendaylight.yangtools.concepts.Immutable;
15 import org.opendaylight.yangtools.concepts.SemVer;
16 import org.opendaylight.yangtools.yang.common.QNameModule;
17 import org.opendaylight.yangtools.yang.common.Revision;
18 import org.opendaylight.yangtools.yang.common.YangVersion;
19
20 /**
21  * This interface contains common methods for getting the schema contents from a YANG module or submodule.
22  */
23 @Beta
24 public interface ModuleLike extends DataNodeContainer, DocumentedNode, Immutable, NotificationNodeContainer,
25         NamespaceRevisionAware {
26     /**
27      * Returns the name of the module which is specified as argument of YANG {@code module} statement.
28      *
29      * @return string with the name of the module
30      */
31     String getName();
32
33     /**
34      * Returns a {@link QNameModule}, which contains the namespace and the revision of the module.
35      *
36      * @return QNameModule identifier.
37      */
38     QNameModule getQNameModule();
39
40     /**
41      * Returns the namespace of the module which is specified as argument of YANG {@code namespace}
42      * keyword. If you need both namespace and revision, please consider using {@link #getQNameModule()}.
43      *
44      * @return URI format of the namespace of the module
45      */
46     @Override
47     default URI getNamespace() {
48         return getQNameModule().getNamespace();
49     }
50
51     /**
52      * Returns the revision date for the module. If you need both namespace and
53      * revision, please consider using {@link #getQNameModule()}.
54      *
55      * @return date of the module revision which is specified as argument of YANG {@code revison} statement
56      */
57     @Override
58     default Optional<Revision> getRevision() {
59         return getQNameModule().getRevision();
60     }
61
62     /**
63      * Returns the semantic version of YANG module. If the semantic version is not specified, default semantic version
64      * of module is returned.
65      *
66      * @return SemVer semantic version of YANG module which is specified as argument of
67      *         {@code (urn:opendaylight:yang:extension:semantic-version?revision=2016-02-02)semantic-version} statement
68      */
69     Optional<SemVer> getSemanticVersion();
70
71     /**
72      * Returns the prefix of the module.
73      *
74      * @return string with the module prefix which is specified as argument of YANG {@code prefix} statement
75      */
76     String getPrefix();
77
78     /**
79      * Returns the YANG version.
80      *
81      * @return YANG version of this module.
82      */
83     YangVersion getYangVersion();
84
85     /**
86      * Returns the module organization.
87      *
88      * @return string with the name of the organization specified in the module as the argument of YANG
89      *         {@code organization} statement
90      */
91     Optional<String> getOrganization();
92
93     /**
94      * Returns the module contact.
95      *
96      * <p>
97      * The contact represents the person or persons to whom technical queries concerning this module should be sent,
98      * such as their name, postal address, telephone number, and electronic mail address.
99      *
100      * @return string with the contact data specified in the module as the argument of YANG {@code contact} statement
101      */
102     Optional<String> getContact();
103
104     /**
105      * Returns imports which represents YANG modules which are imported to this module via {@code import} statement.
106      *
107      * @return set of module imports which are specified in the module as the argument of YANG {@code import}
108      *         statements.
109      */
110     Collection<? extends ModuleImport> getImports();
111
112     // FIXME: YANGTOOLS-1006: this should be only in Module
113     Collection<? extends Submodule> getSubmodules();
114
115     /**
116      * Returns {@link FeatureDefinition} instances which contain data from {@code feature} statements defined in the
117      * module.
118      *
119      * <p>
120      * The feature is used to define a mechanism by which portions of the schema are marked as conditional.
121      *
122      * @return feature statements in lexicographical order which are specified in the module as the argument of YANG
123      *         {@code feature} statements.
124      */
125     Collection<? extends FeatureDefinition> getFeatures();
126
127     /**
128      * Returns {@link AugmentationSchemaNode} instances which contain data from {@code augment} statements defined
129      * in the module.
130      *
131      * @return set of the augmentation schema instances which are specified in the module as YANG {@code augment}
132      *         statement and are lexicographically ordered
133      */
134     Collection<? extends AugmentationSchemaNode> getAugmentations();
135
136     /**
137      * Returns {@link RpcDefinition} instances which contain data from {@code rpc} statements defined in the module.
138      *
139      * @return set of the RPC definition instances which are specified in the module as YANG {@code rpc} statements and
140      *         are lexicographicaly ordered
141      */
142     Collection<? extends RpcDefinition> getRpcs();
143
144     /**
145      * Returns {@link Deviation} instances which contain data from {@code deviation} statements defined in the module.
146      *
147      * @return set of the deviation instances
148      */
149     Collection<? extends Deviation> getDeviations();
150
151     /**
152      * Returns {@link IdentitySchemaNode} instances which contain data from {@code identity} statements defined in the
153      * module.
154      *
155      * @return set of identity schema node instances which are specified in the module as YANG {@code identity}
156      *         statements and are lexicographically ordered
157      */
158     Collection<? extends IdentitySchemaNode> getIdentities();
159
160     /**
161      * Returns {@link ExtensionDefinition} instances which contain data from {@code extension} statements defined in
162      * the module.
163      *
164      * @return set of extension definition instances which are specified in the module as YANG {@code extension}
165      *         statements and are lexicographically ordered
166      */
167     Collection<? extends ExtensionDefinition> getExtensionSchemaNodes();
168 }