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.yangtools.yang.parser.util;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.yangtools.concepts.Immutable;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.model.api.Status;
17 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
19 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
21 final class BitImpl implements BitsTypeDefinition.Bit, Immutable {
22 private final Long position;
23 private final QName qname;
24 private final SchemaPath schemaPath;
25 private final String description;
26 private final String reference;
27 private final Status status;
28 private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
30 BitImpl(final Long position, final QName qname, final SchemaPath schemaPath, final String description,
31 final String reference, final Status status, final List<UnknownSchemaNode> unknownNodes) {
32 this.position = position;
34 this.schemaPath = schemaPath;
35 this.description = description;
36 this.reference = reference;
38 if (unknownNodes != null) {
39 this.unknownNodes = unknownNodes;
44 public QName getQName() {
49 public SchemaPath getPath() {
54 public String getDescription() {
59 public String getReference() {
64 public Status getStatus() {
69 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
74 public Long getPosition() {
79 public String getName() {
80 return qname.getLocalName();
84 public int hashCode() {
87 result = prime * result + ((qname == null) ? 0 : qname.hashCode());
88 result = prime * result + ((schemaPath == null) ? 0 : schemaPath.hashCode());
89 result = prime * result + ((position == null) ? 0 : position.hashCode());
90 result = prime * result + ((unknownNodes == null) ? 0 : unknownNodes.hashCode());
95 public boolean equals(Object obj) {
102 if (getClass() != obj.getClass()) {
105 Bit other = (Bit) obj;
107 if (other.getQName() != null) {
110 } else if (!qname.equals(other.getQName())) {
113 if (schemaPath == null) {
114 if (other.getPath() != null) {
117 } else if (!schemaPath.equals(other.getPath())) {
124 public String toString() {
125 return Bit.class.getSimpleName() + "[name=" + qname.getLocalName() + ", position=" + position + "]";