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.stmt.rfc6020.effective.type;
10 import com.google.common.collect.ImmutableList;
11 import java.util.ArrayList;
12 import java.util.List;
13 import java.util.Objects;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
17 import org.opendaylight.yangtools.yang.model.api.Status;
18 import org.opendaylight.yangtools.yang.model.api.stmt.BitStatement;
19 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
20 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
22 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DescriptionEffectiveStatementImpl;
23 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase;
24 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.PositionEffectiveStatementImpl;
25 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ReferenceEffectiveStatementImpl;
26 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.StatusEffectiveStatementImpl;
27 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
29 public class BitEffectiveStatementImpl extends EffectiveStatementBase<QName, BitStatement> implements
30 BitsTypeDefinition.Bit {
32 private final QName qName;
33 private final SchemaPath schemaPath;
34 private Long position;
35 private String description;
36 private String reference;
37 private Status status;
38 private List<UnknownSchemaNode> unknownSchemaNodes;
40 public BitEffectiveStatementImpl(StmtContext<QName, BitStatement, ?> ctx) {
43 List<UnknownSchemaNode> unknownSchemaNodesInit = new ArrayList<>();
45 qName = ctx.getStatementArgument();
46 schemaPath = Utils.getSchemaPath(ctx);
48 for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
49 if (effectiveStatement instanceof DescriptionEffectiveStatementImpl) {
50 description = ((DescriptionEffectiveStatementImpl) effectiveStatement).argument();
52 if (effectiveStatement instanceof ReferenceEffectiveStatementImpl) {
53 reference = ((ReferenceEffectiveStatementImpl) effectiveStatement).argument();
55 if (effectiveStatement instanceof StatusEffectiveStatementImpl) {
56 status = ((StatusEffectiveStatementImpl) effectiveStatement).argument();
58 if (effectiveStatement instanceof PositionEffectiveStatementImpl) {
59 position = ((PositionEffectiveStatementImpl) effectiveStatement).argument();
62 if (effectiveStatement instanceof UnknownSchemaNode) {
63 unknownSchemaNodesInit.add((UnknownSchemaNode) effectiveStatement);
67 unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodesInit);
71 public Long getPosition() {
76 public String getName() {
77 return qName.getLocalName();
81 public QName getQName() {
86 public SchemaPath getPath() {
91 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
92 return unknownSchemaNodes;
96 public String getDescription() {
101 public String getReference() {
106 public Status getStatus() {
111 public int hashCode() {
112 final int prime = 31;
114 result = prime * result + qName.hashCode();
115 result = prime * result + schemaPath.hashCode();
116 result = prime * result + Objects.hashCode(position);
117 result = prime * result + Objects.hashCode(unknownSchemaNodes);
122 public boolean equals(final Object obj) {
129 if (getClass() != obj.getClass()) {
132 BitsTypeDefinition.Bit other = (BitsTypeDefinition.Bit) obj;
134 if (other.getQName() != null) {
137 } else if (!qName.equals(other.getQName())) {
140 if (schemaPath == null) {
141 if (other.getPath() != null) {
144 } else if (!schemaPath.equals(other.getPath())) {
151 public String toString() {
152 return BitEffectiveStatementImpl.class.getSimpleName() + "[name=" + qName.getLocalName() + ", position="