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.oran;
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.model.statements.AbstractStatement;
28 import org.oran.smo.yangtools.parser.model.statements.ExtensionStatement;
29 import org.oran.smo.yangtools.parser.model.statements.StatementModuleAndName;
30 import org.oran.smo.yangtools.parser.model.statements.yang.CY;
31 import org.oran.smo.yangtools.parser.model.yangdom.YangDomElement;
33 public class YOranSmoTeivASide extends ExtensionStatement {
35 public YOranSmoTeivASide(final AbstractStatement parentStatement, final YangDomElement domNode) {
36 super(parentStatement, domNode);
40 public StatementArgumentType getArgumentType() {
41 return StatementArgumentType.NAME;
45 public StatementModuleAndName getStatementModuleAndName() {
46 return CORAN.ORAN_SMO_TEIV_COMMON_YANG_EXTENSIONS__A_SIDE;
50 public boolean argumentIsMandatory() {
54 public String getTeivTypeName() {
55 return getValue() != null ? getValue() : "";
58 private static final List<StatementModuleAndName> REQUIRED_PARENTS = Arrays.asList(CY.STMT_LEAF, CY.STMT_LEAF_LIST);
61 public boolean canBeChildOf(final StatementModuleAndName parentSman) {
62 return REQUIRED_PARENTS.contains(parentSman);
66 protected void validate(final ParserExecutionContext context) {
68 * From o-ran-smo-teiv-common-yang-extensions:
70 * Defines the A-side of a relationship.
72 * The statement MUST only be a substatement of a 'leaf' or 'leaf-list'
73 * statement, which itself must be a substatement of the
74 * 'uni-directional-topology-relationship' statement.
76 * The data type of the parent 'leaf' or 'leaf-list' MUST be
77 * 'instance-identifier'. Constraints MAY be used as part of the parent
78 * 'leaf' or 'leaf-list' to enforce cardinality.
80 * The identifier of the parent 'leaf' or 'leaf-list' is used as name of
81 * the role of the A-side of the relationship. The name of the role is
82 * scoped to the type on which the A-side is defined and MUST be unique
85 * While the parent 'leaf' or 'leaf-list' does not result in a property of
86 * the relationship, it is RECOMMENDED to avoid using the name of an
87 * existing type property as role name to avoid potential ambiguities
88 * between properties of a type, and roles of a relationship on the type.
90 * The argument is the name of the type on which the A-side resides. If the
91 * type is declared in another module, the type must be prefixed, and a
92 * corresponding 'import' statement be used to declare the prefix.";
94 validateArgumentNotNullNotEmpty(context);
97 checkCardinalityUnderParent(context, 1);