57f4640b1de11dcd159730e12c6c0a82442489d2
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / 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.stmt.rfc6020.effective;
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.ModuleStatement;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
16 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName;
17
18 public final class ModuleEffectiveStatementImpl extends AbstractEffectiveModule<ModuleStatement> {
19     private final QNameModule qnameModule;
20
21     public ModuleEffectiveStatementImpl(
22             final StmtContext<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> ctx) {
23         super(ctx);
24
25         qnameModule = Verify.verifyNotNull(ctx.getFromNamespace(ModuleCtxToModuleQName.class, ctx));
26     }
27
28     @Override
29     public QNameModule getQNameModule() {
30         return qnameModule;
31     }
32
33     @Override
34     public int hashCode() {
35         final int prime = 31;
36         int result = 1;
37         result = prime * result + Objects.hashCode(getName());
38         result = prime * result + Objects.hashCode(getYangVersion());
39         result = prime * result + Objects.hashCode(qnameModule);
40         return result;
41     }
42
43     @Override
44     public boolean equals(final Object obj) {
45         if (this == obj) {
46             return true;
47         }
48         if (!(obj instanceof ModuleEffectiveStatementImpl)) {
49             return false;
50         }
51         ModuleEffectiveStatementImpl other = (ModuleEffectiveStatementImpl) obj;
52         if (!Objects.equals(getName(), other.getName())) {
53             return false;
54         }
55         if (!qnameModule.equals(other.qnameModule)) {
56             return false;
57         }
58         if (!Objects.equals(getYangVersion(), other.getYangVersion())) {
59             return false;
60         }
61         return true;
62     }
63
64 }