2 * Copyright (c) 2016 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.model.util.type;
10 import com.google.common.base.Preconditions;
11 import java.util.List;
12 import java.util.Objects;
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.Bit;
20 final class BitImpl implements Bit, Immutable {
21 private final List<UnknownSchemaNode> unknownNodes;
22 private final SchemaPath schemaPath;
23 private final String description;
24 private final String reference;
25 private final Status status;
26 private final long position;
28 BitImpl(final SchemaPath schemaPath, final long position, final String description,
29 final String reference, final Status status, final List<UnknownSchemaNode> unknownNodes) {
30 this.schemaPath = Preconditions.checkNotNull(schemaPath, "Schema Path should not be null");
32 Preconditions.checkArgument(position >= 0L && position <= 4294967295L, "Invalid position %s", position);
33 this.position = position;
34 this.description = description;
35 this.reference = reference;
36 this.status = Preconditions.checkNotNull(status);
37 this.unknownNodes = Preconditions.checkNotNull(unknownNodes);
41 public QName getQName() {
42 return schemaPath.getLastComponent();
46 public SchemaPath getPath() {
51 public String getDescription() {
56 public String getReference() {
61 public Status getStatus() {
66 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
71 public long getPosition() {
76 public String getName() {
77 return getQName().getLocalName();
81 public int hashCode() {
84 result = prime * result + getQName().hashCode();
85 result = prime * result + schemaPath.hashCode();
86 result = prime * result + Long.hashCode(position);
87 result = prime * result + unknownNodes.hashCode();
92 public boolean equals(final Object obj) {
99 if (getClass() != obj.getClass()) {
102 final Bit other = (Bit) obj;
103 return Objects.equals(schemaPath, other.getPath());
107 public String toString() {
108 return Bit.class.getSimpleName() + "[name=" + getQName().getLocalName() + ", position=" + position + "]";