2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.submodule;
10 import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
12 import java.util.Objects;
13 import org.opendaylight.yangtools.yang.common.QNameModule;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleEffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractEffectiveModule;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
21 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
23 // FIXME: hide this class
24 public final class SubmoduleEffectiveStatementImpl extends AbstractEffectiveModule<SubmoduleStatement>
25 implements SubmoduleEffectiveStatement {
27 private final QNameModule qnameModule;
29 SubmoduleEffectiveStatementImpl(
30 final StmtContext<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> ctx) {
33 final String belongsToModuleName = firstAttributeOf(ctx.declaredSubstatements(), BelongsToStatement.class);
34 final QNameModule belongsToModuleQName = ctx.getFromNamespace(ModuleNameToModuleQName.class,
36 final RevisionEffectiveStatement submoduleRevision = firstEffective(RevisionEffectiveStatement.class);
37 this.qnameModule = QNameModule.create(belongsToModuleQName.getNamespace(),
38 submoduleRevision == null ? null : submoduleRevision.argument()).intern();
42 public QNameModule getQNameModule() {
47 public int hashCode() {
50 result = prime * result + Objects.hashCode(getName());
51 result = prime * result + Objects.hashCode(getYangVersion());
52 result = prime * result + Objects.hashCode(qnameModule);
57 public boolean equals(final Object obj) {
64 if (getClass() != obj.getClass()) {
67 SubmoduleEffectiveStatementImpl other = (SubmoduleEffectiveStatementImpl) obj;
68 if (!Objects.equals(getName(), other.getName())) {
71 if (!qnameModule.equals(other.qnameModule)) {
74 if (!Objects.equals(getYangVersion(), other.getYangVersion())) {