Remove hashCode()/equals() from SchemaNode implementations
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / bit / BitEffectiveStatementImpl.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.rfc7950.stmt.bit;
9
10 import org.opendaylight.yangtools.yang.common.QName;
11 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
12 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
13 import org.opendaylight.yangtools.yang.model.api.stmt.BitEffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.BitStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.PositionEffectiveStatement;
16 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractEffectiveDocumentedNode;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18
19 // FIXME: 5.0.0: hide this class
20 public final class BitEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<QName, BitStatement>
21         implements BitEffectiveStatement {
22
23     private final QName qname;
24     private final SchemaPath schemaPath;
25     private final Long declaredPosition;
26
27     BitEffectiveStatementImpl(final StmtContext<QName, BitStatement, ?> ctx) {
28         super(ctx);
29
30         qname = ctx.getStatementArgument();
31         schemaPath = ctx.getSchemaPath().get();
32
33         Long declaredPositionInit = null;
34         for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
35             if (effectiveStatement instanceof PositionEffectiveStatement) {
36                 declaredPositionInit = ((PositionEffectiveStatement) effectiveStatement).argument();
37             }
38         }
39
40         declaredPosition = declaredPositionInit;
41     }
42
43     public Long getDeclaredPosition() {
44         return declaredPosition;
45     }
46
47     public String getName() {
48         return qname.getLocalName();
49     }
50
51     public QName getQName() {
52         return qname;
53     }
54
55     public SchemaPath getPath() {
56         return schemaPath;
57     }
58
59     @Override
60     public String toString() {
61         return BitEffectiveStatementImpl.class.getSimpleName() + "[name=" + qname.getLocalName() + ", position="
62                 + declaredPosition + "]";
63     }
64 }