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 javax.annotation.Nonnull;
14 import org.opendaylight.yangtools.concepts.Immutable;
15 import org.opendaylight.yangtools.yang.common.QName;
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.UnknownSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
21 final class BitImpl implements Bit, Immutable {
22 private final List<UnknownSchemaNode> unknownNodes;
23 private final SchemaPath schemaPath;
24 private final String description;
25 private final String reference;
26 private final Status status;
27 private final long position;
29 BitImpl(final SchemaPath schemaPath, final long position, final String description,
30 final String reference, final Status status, final List<UnknownSchemaNode> unknownNodes) {
31 this.schemaPath = Preconditions.checkNotNull(schemaPath, "Schema Path should not be null");
33 Preconditions.checkArgument(position >= 0L && position <= 4294967295L, "Invalid position %s", position);
34 this.position = position;
35 this.description = description;
36 this.reference = reference;
37 this.status = Preconditions.checkNotNull(status);
38 this.unknownNodes = Preconditions.checkNotNull(unknownNodes);
43 public QName getQName() {
44 return schemaPath.getLastComponent();
49 public SchemaPath getPath() {
54 public String getDescription() {
59 public String getReference() {
65 public Status getStatus() {
71 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
76 public long getPosition() {
82 public String getName() {
83 return getQName().getLocalName();
87 public int hashCode() {
90 result = prime * result + getQName().hashCode();
91 result = prime * result + schemaPath.hashCode();
92 result = prime * result + Long.hashCode(position);
93 result = prime * result + unknownNodes.hashCode();
98 public boolean equals(final Object obj) {
105 if (getClass() != obj.getClass()) {
108 final Bit other = (Bit) obj;
109 return Objects.equals(schemaPath, other.getPath());
113 public String toString() {
114 return Bit.class.getSimpleName() + "[name=" + getQName().getLocalName() + ", position=" + position + "]";