2 * Copyright (c) 2013 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.controller.yang.parser.util;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.controller.yang.common.QName;
14 import org.opendaylight.controller.yang.model.api.SchemaPath;
15 import org.opendaylight.controller.yang.model.api.Status;
16 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
17 import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition;
18 import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition.Bit;
20 final class BitImpl implements BitsTypeDefinition.Bit {
21 private final Long position;
22 private final QName qname;
23 private final SchemaPath schemaPath;
24 private final String description;
25 private final String reference;
26 private final Status status;
27 private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
29 BitImpl(final Long position, final QName qname,
30 final SchemaPath schemaPath, final String description,
31 final String reference, final Status status,
32 final List<UnknownSchemaNode> unknownNodes) {
33 this.position = position;
35 this.schemaPath = schemaPath;
36 this.description = description;
37 this.reference = reference;
39 if(unknownNodes != null) {
40 this.unknownNodes = unknownNodes;
45 public QName getQName() {
50 public SchemaPath getPath() {
55 public String getDescription() {
60 public String getReference() {
65 public Status getStatus() {
70 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
75 public Long getPosition() {
80 public String getName() {
81 return qname.getLocalName();
85 public int hashCode() {
88 result = prime * result
89 + ((qname == null) ? 0 : qname.hashCode());
90 result = prime * result
91 + ((schemaPath == null) ? 0 : schemaPath.hashCode());
92 result = prime * result
93 + ((position == null) ? 0 : position.hashCode());
96 + ((unknownNodes == null) ? 0 : unknownNodes.hashCode());
101 public boolean equals(Object obj) {
108 if (getClass() != obj.getClass()) {
111 Bit other = (Bit) obj;
113 if (other.getQName() != null) {
116 } else if (!qname.equals(other.getQName())) {
119 if (schemaPath == null) {
120 if (other.getPath() != null) {
123 } else if (!schemaPath.equals(other.getPath())) {
130 public String toString() {
131 return Bit.class.getSimpleName() + "[name="
132 + qname.getLocalName() + ", position=" + position + "]";