2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.bit;
10 import java.util.Objects;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.BitEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.BitStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.PositionEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
18 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractEffectiveDocumentedNode;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
21 // FIXME: 5.0.0: hide this class
22 public final class BitEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<QName, BitStatement>
23 implements BitEffectiveStatement {
25 private final QName qname;
26 private final SchemaPath schemaPath;
27 private final Long declaredPosition;
29 BitEffectiveStatementImpl(final StmtContext<QName, BitStatement, ?> ctx) {
32 qname = ctx.getStatementArgument();
33 schemaPath = ctx.getSchemaPath().get();
35 Long declaredPositionInit = null;
36 for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
37 if (effectiveStatement instanceof PositionEffectiveStatement) {
38 declaredPositionInit = ((PositionEffectiveStatement) effectiveStatement).argument();
42 declaredPosition = declaredPositionInit;
45 public Long getDeclaredPosition() {
46 return declaredPosition;
49 public String getName() {
50 return qname.getLocalName();
53 public QName getQName() {
57 public SchemaPath getPath() {
62 public int hashCode() {
65 result = prime * result + qname.hashCode();
66 result = prime * result + schemaPath.hashCode();
67 result = prime * result + Objects.hashCode(declaredPosition);
68 result = prime * result + getUnknownSchemaNodes().hashCode();
73 public boolean equals(final Object obj) {
80 if (getClass() != obj.getClass()) {
83 final BitsTypeDefinition.Bit other = (BitsTypeDefinition.Bit) obj;
84 return Objects.equals(qname, other.getQName()) && Objects.equals(schemaPath, other.getPath());
88 public String toString() {
89 return BitEffectiveStatementImpl.class.getSimpleName() + "[name=" + qname.getLocalName() + ", position="
90 + declaredPosition + "]";