Fix somar complaints in equals methods
[yangtools.git] / yang / rfc6643-parser-support / src / main / java / org / opendaylight / yangtools / rfc6643 / parser / MaxAccessEffectiveStatementImpl.java
1 /*
2  * Copyright (c) 2016, 2020 PANTHEON.tech, s.r.o. 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.rfc6643.parser;
9
10 import com.google.common.collect.ImmutableList;
11 import java.util.Objects;
12 import org.opendaylight.yangtools.rfc6643.model.api.MaxAccess;
13 import org.opendaylight.yangtools.rfc6643.model.api.MaxAccessEffectiveStatement;
14 import org.opendaylight.yangtools.rfc6643.model.api.MaxAccessSchemaNode;
15 import org.opendaylight.yangtools.rfc6643.model.api.MaxAccessStatement;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.UnknownEffectiveStatementBase;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
21
22 final class MaxAccessEffectiveStatementImpl extends UnknownEffectiveStatementBase<MaxAccess, MaxAccessStatement>
23         implements MaxAccessEffectiveStatement, MaxAccessSchemaNode {
24     private final SchemaPath path;
25
26     MaxAccessEffectiveStatementImpl(final MaxAccessStatement declared,
27             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
28             final StmtContext<MaxAccess, MaxAccessStatement, ?> ctx) {
29         super(declared.argument(), declared, substatements, ctx);
30         path = ctx.coerceParentContext().getSchemaPath().get().createChild(getNodeType());
31     }
32
33     @Override
34     public MaxAccess getArgument() {
35         return argument();
36     }
37
38     @Override
39     public QName getQName() {
40         return getNodeType();
41     }
42
43     @Override
44     @Deprecated
45     public SchemaPath getPath() {
46         return path;
47     }
48
49     @Override
50     public MaxAccessEffectiveStatement asEffectiveStatement() {
51         return this;
52     }
53
54     @Override
55     public int hashCode() {
56         return Objects.hash(path, getNodeType(), getNodeParameter());
57     }
58
59     @Override
60     public boolean equals(final Object obj) {
61         if (this == obj) {
62             return true;
63         }
64         if (!(obj instanceof MaxAccessEffectiveStatementImpl)) {
65             return false;
66         }
67         final MaxAccessEffectiveStatementImpl other = (MaxAccessEffectiveStatementImpl) obj;
68         return Objects.equals(getNodeType(), other.getNodeType())
69             && Objects.equals(getNodeParameter(), other.getNodeParameter()) && Objects.equals(path, other.path);
70     }
71 }