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.ri.type;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableList;
13 import java.util.Collection;
14 import java.util.List;
15 import java.util.Optional;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.opendaylight.yangtools.concepts.Immutable;
18 import org.opendaylight.yangtools.yang.common.Uint32;
19 import org.opendaylight.yangtools.yang.model.api.Status;
20 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
23 final class BitImpl implements Bit, Immutable {
24 private final @NonNull ImmutableList<UnknownSchemaNode> unknownNodes;
25 private final @NonNull String name;
26 private final String description;
27 private final String reference;
28 private final @NonNull Status status;
29 private final @NonNull Uint32 position;
31 BitImpl(final String name, final Uint32 position, final String description,
32 final String reference, final Status status, final List<UnknownSchemaNode> unknownNodes) {
33 this.name = requireNonNull(name);
34 this.position = requireNonNull(position);
35 this.description = description;
36 this.reference = reference;
37 this.status = requireNonNull(status);
38 this.unknownNodes = ImmutableList.copyOf(unknownNodes);
42 public Optional<String> getDescription() {
43 return Optional.ofNullable(description);
47 public Optional<String> getReference() {
48 return Optional.ofNullable(reference);
52 public Status getStatus() {
57 public Collection<? extends UnknownSchemaNode> getUnknownSchemaNodes() {
62 public Uint32 getPosition() {
67 public String getName() {
72 public int hashCode() {
73 return 31 * name.hashCode() + position.hashCode();
77 public boolean equals(final Object obj) {
81 if (!(obj instanceof Bit)) {
84 final Bit other = (Bit) obj;
85 return name.equals(other.getName()) && position == other.getPosition();
89 public String toString() {
90 return Bit.class.getSimpleName() + "[name=" + name + ", position=" + position + "]";