dbc862152b85ba498ce030143e922acb6f5176f5
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / openconfig / stmt / OpenConfigVersionEffectiveStatementImpl.java
1 /*
2  * Copyright (c) 2016 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.openconfig.stmt;
9
10 import java.util.Objects;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yangtools.concepts.SemVer;
13 import org.opendaylight.yangtools.openconfig.model.api.OpenConfigVersionEffectiveStatement;
14 import org.opendaylight.yangtools.openconfig.model.api.OpenConfigVersionStatement;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
17 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.UnknownEffectiveStatementBase;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19
20 final class OpenConfigVersionEffectiveStatementImpl extends
21         UnknownEffectiveStatementBase<SemVer, OpenConfigVersionStatement>
22         implements OpenConfigVersionEffectiveStatement {
23
24     private final @NonNull SchemaPath path;
25
26     OpenConfigVersionEffectiveStatementImpl(final StmtContext<SemVer, OpenConfigVersionStatement, ?> ctx) {
27         super(ctx);
28         path = ctx.coerceParentContext().getSchemaPath().get().createChild(getNodeType());
29     }
30
31     @Override
32     public QName getQName() {
33         return getNodeType();
34     }
35
36     @Override
37     public SchemaPath getPath() {
38         return path;
39     }
40
41     @Override
42     public int hashCode() {
43         return Objects.hash(path, getNodeType(), getNodeParameter());
44     }
45
46     @Override
47     public boolean equals(final Object obj) {
48         if (this == obj) {
49             return true;
50         }
51         if (!(obj instanceof OpenConfigVersionEffectiveStatementImpl)) {
52             return false;
53         }
54         final OpenConfigVersionEffectiveStatementImpl other = (OpenConfigVersionEffectiveStatementImpl) obj;
55         return Objects.equals(path, other.path) && Objects.equals(getNodeType(), other.getNodeType())
56                 && Objects.equals(getNodeParameter(), other.getNodeParameter());
57     }
58 }