2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2024 Ericsson
4 * Modifications Copyright (C) 2024 OpenInfra Foundation Europe
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
21 package org.oran.smo.yangtools.parser.model.statements.yang;
23 import java.util.List;
25 import org.oran.smo.yangtools.parser.ParserExecutionContext;
26 import org.oran.smo.yangtools.parser.model.statements.AbstractStatement;
27 import org.oran.smo.yangtools.parser.model.statements.StatementModuleAndName;
28 import org.oran.smo.yangtools.parser.model.yangdom.YangDomElement;
31 * Type-safe Yang core statement.
33 * @author Mark Hollmann
35 public class YSubmodule extends AbstractStatement {
37 public YSubmodule(final AbstractStatement modelRoot, final YangDomElement domNode) {
38 super(modelRoot, domNode);
42 public String getStatementIdentifier() {
43 return getSubmoduleName();
47 public StatementArgumentType getArgumentType() {
48 return StatementArgumentType.NAME;
52 public StatementModuleAndName getStatementModuleAndName() {
53 return CY.STMT_SUBMODULE;
57 * The submodule name will always be non-null.
59 public String getSubmoduleName() {
60 return domElement.getValue();
63 public List<YAnydata> getAnydata() {
64 return getChildren(CY.STMT_ANYDATA);
67 public List<YAnyxml> getAnyxmls() {
68 return getChildren(CY.STMT_ANYXML);
71 public List<YAugment> getAugments() {
72 return getChildren(CY.STMT_AUGMENT);
76 * Returns the 'belongs-to' statement, if any, under the 'submodule'. To get the actual value of the submodule's
77 * belongs-to, invoke mySubmodule.getBelongsToValue();
79 public YBelongsTo getBelongsTo() {
80 return getChild(CY.STMT_BELONGS_TO);
84 * Returns the value, if any, of the 'belongs-to' statement under the 'submodule'.
86 public String getBelongsToValue() {
87 final YBelongsTo yBelongsTo = getBelongsTo();
88 return yBelongsTo == null ? null : yBelongsTo.getBelongsToModuleName();
91 public List<YChoice> getChoices() {
92 return getChildren(CY.STMT_CHOICE);
95 public YContact getContact() {
96 return getChild(CY.STMT_CONTACT);
99 public List<YContainer> getContainers() {
100 return getChildren(CY.STMT_CONTAINER);
103 public List<YDeviation> getDeviations() {
104 return getChildren(CY.STMT_DEVIATION);
107 public List<YExtension> getExtensions() {
108 return getChildren(CY.STMT_EXTENSION);
111 public List<YFeature> getFeatures() {
112 return getChildren(CY.STMT_FEATURE);
115 public List<YGrouping> getGroupings() {
116 return getChildren(CY.STMT_GROUPING);
119 public List<YIdentity> getIdentities() {
120 return getChildren(CY.STMT_IDENTITY);
123 public List<YImport> getImports() {
124 return getChildren(CY.STMT_IMPORT);
127 public List<YInclude> getIncludes() {
128 return getChildren(CY.STMT_INCLUDE);
131 public List<YLeaf> getLeafs() {
132 return getChildren(CY.STMT_LEAF);
135 public List<YLeafList> getLeafLists() {
136 return getChildren(CY.STMT_LEAF_LIST);
139 public List<YList> getLists() {
140 return getChildren(CY.STMT_LIST);
143 public List<YNotification> getNotifications() {
144 return getChildren(CY.STMT_NOTIFICATION);
147 public YOrganization getOrganization() {
148 return getChild(CY.STMT_ORGANIZATION);
151 public List<YRevision> getRevisions() {
152 return getChildren(CY.STMT_REVISION);
155 public List<YRpc> getRpcs() {
156 return getChildren(CY.STMT_RPC);
159 public List<YTypedef> getTypedefs() {
160 return getChildren(CY.STMT_TYPEDEF);
163 public List<YUses> getUses() {
164 return getChildren(CY.STMT_USES);
167 public YYangVersion getYangVersion() {
168 return getChild(CY.STMT_YANG_VERSION);
171 public boolean is10Version() {
172 final YYangVersion yYangVersion = getYangVersion();
173 return yYangVersion == null ? false : yYangVersion.is10Version();
176 public boolean is11Version() {
177 final YYangVersion yYangVersion = getYangVersion();
178 return yYangVersion == null ? false : yYangVersion.is11Version();
181 protected void validate(final ParserExecutionContext context) {
182 validateArgumentNotNullNotEmpty(context);
183 validateIsYangIdentifier(context, getSubmoduleName());