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.stmt.rfc6020.effective;
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.common.SimpleDateFormatUtil;
15 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
21 public final class SubmoduleEffectiveStatementImpl extends AbstractEffectiveModule<SubmoduleStatement> {
23 private final QNameModule qNameModule;
25 public SubmoduleEffectiveStatementImpl(
26 final StmtContext<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> ctx) {
29 String belongsToModuleName = firstAttributeOf(ctx.declaredSubstatements(), BelongsToStatement.class);
30 final QNameModule belongsToModuleQName = ctx.getFromNamespace(ModuleNameToModuleQName.class,
32 RevisionEffectiveStatementImpl submoduleRevision = firstEffective(RevisionEffectiveStatementImpl.class);
34 this.qNameModule = submoduleRevision == null ? QNameModule.create(belongsToModuleQName.getNamespace(),
35 SimpleDateFormatUtil.DEFAULT_DATE_REV) : QNameModule.create(belongsToModuleQName.getNamespace(),
36 submoduleRevision.argument());
40 public QNameModule getQNameModule() {
45 public int hashCode() {
48 result = prime * result + Objects.hashCode(getName());
49 result = prime * result + Objects.hashCode(getYangVersion());
50 result = prime * result + Objects.hashCode(qNameModule);
55 public boolean equals(final Object obj) {
62 if (getClass() != obj.getClass()) {
65 SubmoduleEffectiveStatementImpl other = (SubmoduleEffectiveStatementImpl) obj;
66 if (!Objects.equals(getName(), other.getName())) {
69 if (!qNameModule.equals(other.qNameModule)) {
72 if (!Objects.equals(getYangVersion(), other.getYangVersion())) {