2 * Copyright (c) 2015 Pantheon Technologies s.r.o. 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.base.MoreObjects;
13 import com.google.common.collect.ImmutableList;
14 import java.util.Collection;
15 import java.util.Objects;
16 import java.util.Optional;
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.opendaylight.yangtools.concepts.Immutable;
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.EnumTypeDefinition.EnumPair;
23 final class EnumPairImpl implements EnumPair, Immutable {
24 private final @NonNull ImmutableList<UnknownSchemaNode> unknownSchemaNodes;
25 private final String description;
26 private final String reference;
27 private final @NonNull Status status;
28 private final @NonNull String name;
29 private final int value;
31 EnumPairImpl(final String name, final int value, final String description, final String reference,
32 final Status status, final ImmutableList<UnknownSchemaNode> unknownSchemaNodes) {
33 this.name = requireNonNull(name);
35 this.description = description;
36 this.reference = reference;
37 this.status = requireNonNull(status);
38 this.unknownSchemaNodes = requireNonNull(unknownSchemaNodes);
42 public Collection<? extends UnknownSchemaNode> getUnknownSchemaNodes() {
43 return unknownSchemaNodes;
47 public Optional<String> getDescription() {
48 return Optional.ofNullable(description);
52 public Optional<String> getReference() {
53 return Optional.ofNullable(reference);
57 public Status getStatus() {
62 public String getName() {
67 public int getValue() {
72 public int hashCode() {
75 result = prime * result + unknownSchemaNodes.hashCode();
76 result = prime * result + name.hashCode();
77 result = prime * result + Integer.hashCode(value);
82 public boolean equals(final Object obj) {
86 if (!(obj instanceof EnumPair)) {
89 EnumPair other = (EnumPair) obj;
90 if (!Objects.equals(name, other.getName())) {
94 return value == other.getValue() && Objects.equals(unknownSchemaNodes, other.getUnknownSchemaNodes());
98 public String toString() {
99 return MoreObjects.toStringHelper(this).add("name", name).add("value", value).toString();