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;
23 import java.util.Objects;
25 import org.oran.smo.yangtools.parser.model.statements.yang.CY;
28 * Holds information about the name of a statement, and the module where the statement has
31 * @author Mark Hollmann
33 public class StatementModuleAndName {
35 private final String moduleName;
36 private final String statementName;
37 private final boolean isYangCoreStatement;
40 * Creates a new SMAN. The module name is the name of the module defining the statement.
42 public StatementModuleAndName(final String moduleName, final String statementName) {
43 this.moduleName = Objects.requireNonNull(moduleName);
44 this.statementName = Objects.requireNonNull(statementName);
45 this.isYangCoreStatement = CY.YANG_CORE_MODULE_NAME.equals(moduleName);
49 * Returns the module in which the statement has been defined. If the statement is part of
50 * the core YANG language, the constant {@link CY.YANG_CORE_MODULE_NAME} will be returned.
52 public String getModuleName() {
57 * Returns whether this statement is part of the YANG core language.
59 public boolean isYangCoreStatement() {
60 return isYangCoreStatement;
64 * Returns whether this statement is an extension statement.
66 public boolean isExtensionStatement() {
67 return !isYangCoreStatement;
71 * Returns the statement name. Note that different modules may define
72 * extensions having the same (statement-) name.
74 public String getStatementName() {
79 public int hashCode() {
80 return statementName.hashCode();
84 public String toString() {
85 return isYangCoreStatement() ? statementName : moduleName + ":" + statementName;
89 public boolean equals(final Object obj) {
95 if (!(obj instanceof StatementModuleAndName)) {
99 final StatementModuleAndName other = (StatementModuleAndName) obj;
101 return this.statementName.equals(other.statementName) && this.moduleName.equals(other.moduleName);