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 YLeaf extends AbstractStatement {
37 public YLeaf(final AbstractStatement parentStatement, final YangDomElement domNode) {
38 super(parentStatement, domNode);
42 public String getStatementIdentifier() {
47 public boolean definesSchemaNode() {
52 public boolean definesDataNode() {
57 public StatementArgumentType getArgumentType() {
58 return StatementArgumentType.NAME;
62 public StatementModuleAndName getStatementModuleAndName() {
66 public String getLeafName() {
67 return domElement.getValue();
70 public YConfig getConfig() {
71 return getChild(CY.STMT_CONFIG);
74 public YDefault getDefault() {
75 return getChild(CY.STMT_DEFAULT);
78 public List<YIfFeature> getIfFeatures() {
79 return getChildren(CY.STMT_IF_FEATURE);
82 public YMandatory getMandatory() {
83 return getChild(CY.STMT_MANDATORY);
87 * Returns whether the leaf is mandatory.
89 public boolean isMandatory() {
90 final YMandatory yMandatory = getMandatory();
91 return yMandatory == null ? false : yMandatory.isMandatoryTrue();
94 public List<YMust> getMusts() {
95 return getChildren(CY.STMT_MUST);
98 public YStatus getStatus() {
99 return getChild(CY.STMT_STATUS);
102 public YType getType() {
103 return getChild(CY.STMT_TYPE);
106 public YUnits getUnits() {
107 return getChild(CY.STMT_UNITS);
110 public List<YWhen> getWhens() {
111 return getChildren(CY.STMT_WHEN);
114 protected void validate(final ParserExecutionContext context) {
115 validateArgumentNotNullNotEmpty(context);
116 validateIsYangIdentifier(context, getLeafName());