Reformulate StatementContextFactory.createEffective()
[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.EffectiveStmtCtx.Current;
21
22 final class MaxAccessEffectiveStatementImpl extends UnknownEffectiveStatementBase<MaxAccess, MaxAccessStatement>
23         implements MaxAccessEffectiveStatement, MaxAccessSchemaNode {
24     private final SchemaPath path;
25
26     MaxAccessEffectiveStatementImpl(final Current<MaxAccess, MaxAccessStatement> stmt,
27             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
28         super(stmt, substatements);
29         path = stmt.getParent().getSchemaPath().createChild(getNodeType());
30     }
31
32     @Override
33     public MaxAccess getArgument() {
34         return argument();
35     }
36
37     @Override
38     public QName getQName() {
39         return getNodeType();
40     }
41
42     @Override
43     @Deprecated
44     public SchemaPath getPath() {
45         return path;
46     }
47
48     @Override
49     public MaxAccessEffectiveStatement asEffectiveStatement() {
50         return this;
51     }
52
53     @Override
54     public int hashCode() {
55         return Objects.hash(path, getNodeType(), getNodeParameter());
56     }
57
58     @Override
59     public boolean equals(final Object obj) {
60         if (this == obj) {
61             return true;
62         }
63         if (obj == null) {
64             return false;
65         }
66         if (getClass() != obj.getClass()) {
67             return false;
68         }
69         final MaxAccessEffectiveStatementImpl other = (MaxAccessEffectiveStatementImpl) obj;
70         if (!Objects.equals(path, other.path)) {
71             return false;
72         }
73         if (!Objects.equals(getNodeType(), other.getNodeType())) {
74             return false;
75         }
76         if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
77             return false;
78         }
79         return true;
80     }
81 }