7007758ffe50ae262d1bd17d1057bb56d6236b8f
[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 == null) {
65             return false;
66         }
67         if (getClass() != obj.getClass()) {
68             return false;
69         }
70         final MaxAccessEffectiveStatementImpl other = (MaxAccessEffectiveStatementImpl) obj;
71         if (!Objects.equals(path, other.path)) {
72             return false;
73         }
74         if (!Objects.equals(getNodeType(), other.getNodeType())) {
75             return false;
76         }
77         if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
78             return false;
79         }
80         return true;
81     }
82 }