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");
31 this.position = Preconditions.checkNotNull(position, "Position should not be null");
32 this.description = description;
33 this.reference = reference;
34 this.status = Preconditions.checkNotNull(status);
35 this.unknownNodes = Preconditions.checkNotNull(unknownNodes);
39 public QName getQName() {
40 return schemaPath.getLastComponent();
44 public SchemaPath getPath() {
49 public String getDescription() {
54 public String getReference() {
59 public Status getStatus() {
64 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
69 public Long getPosition() {
74 public String getName() {
75 return getQName().getLocalName();
79 public int hashCode() {
82 result = prime * result + getQName().hashCode();
83 result = prime * result + schemaPath.hashCode();
84 result = prime * result + position.hashCode();
85 result = prime * result + unknownNodes.hashCode();
90 public boolean equals(final Object obj) {
97 if (getClass() != obj.getClass()) {
100 Bit other = (Bit) obj;
101 return Objects.equals(schemaPath, other.getPath());
105 public String toString() {
106 return Bit.class.getSimpleName() + "[name=" + getQName().getLocalName() + ", position=" + position + "]";