YANGTOOLS-706: Split out yang-parser-rfc7950
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / module / ModuleEffectiveStatementImpl.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.module;
9
10 import com.google.common.base.Verify;
11 import java.util.Objects;
12 import org.opendaylight.yangtools.yang.common.QNameModule;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
16 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractEffectiveModule;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName;
19
20 final class ModuleEffectiveStatementImpl extends AbstractEffectiveModule<ModuleStatement>
21         implements ModuleEffectiveStatement {
22     private final QNameModule qnameModule;
23
24     ModuleEffectiveStatementImpl(
25             final StmtContext<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> ctx) {
26         super(ctx);
27         qnameModule = Verify.verifyNotNull(ctx.getFromNamespace(ModuleCtxToModuleQName.class, ctx));
28     }
29
30     @Override
31     public QNameModule getQNameModule() {
32         return qnameModule;
33     }
34
35     @Override
36     public int hashCode() {
37         final int prime = 31;
38         int result = 1;
39         result = prime * result + Objects.hashCode(getName());
40         result = prime * result + Objects.hashCode(getYangVersion());
41         result = prime * result + Objects.hashCode(qnameModule);
42         return result;
43     }
44
45     @Override
46     public boolean equals(final Object obj) {
47         if (this == obj) {
48             return true;
49         }
50         if (!(obj instanceof ModuleEffectiveStatementImpl)) {
51             return false;
52         }
53         ModuleEffectiveStatementImpl other = (ModuleEffectiveStatementImpl) obj;
54         if (!Objects.equals(getName(), other.getName())) {
55             return false;
56         }
57         if (!qnameModule.equals(other.qnameModule)) {
58             return false;
59         }
60         if (!Objects.equals(getYangVersion(), other.getYangVersion())) {
61             return false;
62         }
63         return true;
64     }
65
66 }