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 java.util.Optional;
14 import org.opendaylight.yangtools.yang.common.QNameModule;
15 import org.opendaylight.yangtools.yang.common.Revision;
16 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionEffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleEffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
21 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractEffectiveModule;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
25 final class SubmoduleEffectiveStatementImpl extends AbstractEffectiveModule<SubmoduleStatement>
26 implements SubmoduleEffectiveStatement {
28 private final QNameModule qnameModule;
30 SubmoduleEffectiveStatementImpl(
31 final StmtContext<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> ctx) {
34 final String belongsToModuleName = firstAttributeOf(ctx.declaredSubstatements(), BelongsToStatement.class);
35 final QNameModule belongsToModuleQName = ctx.getFromNamespace(ModuleNameToModuleQName.class,
38 final Optional<Revision> submoduleRevision = findFirstEffectiveSubstatementArgument(
39 RevisionEffectiveStatement.class);
40 this.qnameModule = QNameModule.create(belongsToModuleQName.getNamespace(), submoduleRevision).intern();
44 public QNameModule getQNameModule() {
49 public int hashCode() {
50 return Objects.hash(getName(), getYangVersion(), qnameModule);
54 public boolean equals(final Object obj) {
58 if (!(obj instanceof SubmoduleEffectiveStatementImpl)) {
61 final SubmoduleEffectiveStatementImpl other = (SubmoduleEffectiveStatementImpl) obj;
62 return Objects.equals(getName(), other.getName()) && qnameModule.equals(other.qnameModule)
63 && Objects.equals(getYangVersion(), other.getYangVersion());