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.threegpp;
23 import java.util.Arrays;
24 import java.util.List;
26 import org.oran.smo.yangtools.parser.ParserExecutionContext;
27 import org.oran.smo.yangtools.parser.findings.Finding;
28 import org.oran.smo.yangtools.parser.findings.ParserFindingType;
29 import org.oran.smo.yangtools.parser.model.statements.AbstractStatement;
30 import org.oran.smo.yangtools.parser.model.statements.ExtensionStatement;
31 import org.oran.smo.yangtools.parser.model.statements.StatementModuleAndName;
32 import org.oran.smo.yangtools.parser.model.statements.yang.CY;
33 import org.oran.smo.yangtools.parser.model.yangdom.YangDomElement;
36 * Type-safe 3GPP statement.
38 * @author Mark Hollmann
40 public class Y3gppInVariant extends ExtensionStatement {
42 public Y3gppInVariant(final AbstractStatement parentStatement, final YangDomElement domNode) {
43 super(parentStatement, domNode);
47 public StatementArgumentType getArgumentType() {
48 return StatementArgumentType.NO_ARG;
52 public StatementModuleAndName getStatementModuleAndName() {
53 return C3GPP.THREEGPP_COMMON_YANG_EXTENSIONS__IN_VARIANT;
56 private static final List<StatementModuleAndName> REQUIRED_PARENTS = Arrays.asList(CY.STMT_LEAF, CY.STMT_LEAF_LIST,
60 public boolean canBeChildOf(final StatementModuleAndName parentSman) {
61 return REQUIRED_PARENTS.contains(parentSman);
65 protected void validate(final ParserExecutionContext context) {
67 * From module _3gpp-common-yang-extensions:
69 * Indicates that the value for the data node can only be set when its
70 * parent data node is being created. To change the value after that, the
71 * parent data node must be deleted and recreated with the data node
72 * having the new value.
74 * It is unnecessary to use and MUST NOT be used for key leafs.
76 * The statement MUST only be a substatement of a leaf, leaf-list, list
77 * statements that is config=true.
78 * Zero or one inVariant statement is allowed per parent statement.
79 * NO substatements are allowed.
81 * Adding this statement is an NBC change, removing it is BC.
83 checkParentAlsoAllowDeviateOrRefine(context);
84 checkCardinalityUnderParent(context, 1);
86 if (getValue() != null) {
87 context.addFinding(new Finding(this, ParserFindingType.P015_INVALID_SYNTAX_IN_DOCUMENT,
88 "'inVariant' extension does not allow for an argument."));