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.util.type;
10 import com.google.common.base.MoreObjects;
11 import com.google.common.base.Preconditions;
12 import java.util.List;
13 import java.util.Objects;
14 import javax.annotation.Nonnull;
15 import org.opendaylight.yangtools.concepts.Immutable;
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.EnumTypeDefinition.EnumPair;
20 final class EnumPairImpl implements EnumPair, Immutable {
21 private final List<UnknownSchemaNode> unknownSchemaNodes;
22 private final String description;
23 private final String reference;
24 private final Status status;
25 private final String name;
26 private final int value;
28 EnumPairImpl(final String name, final int value, final String description, final String reference,
29 final Status status, final List<UnknownSchemaNode> unknownSchemaNodes) {
30 this.name = Preconditions.checkNotNull(name);
32 this.description = description;
33 this.reference = reference;
34 this.status = Preconditions.checkNotNull(status);
35 this.unknownSchemaNodes = Preconditions.checkNotNull(unknownSchemaNodes);
40 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
41 return unknownSchemaNodes;
45 public String getDescription() {
50 public String getReference() {
56 public Status getStatus() {
61 public String getName() {
66 public int getValue() {
71 public int hashCode() {
74 result = prime * result + unknownSchemaNodes.hashCode();
75 result = prime * result + name.hashCode();
76 result = prime * result + Integer.hashCode(value);
81 public boolean equals(final Object obj) {
85 if (!(obj instanceof EnumPair)) {
88 EnumPair other = (EnumPair) obj;
89 if (!Objects.equals(name, other.getName())) {
93 return value == other.getValue() && Objects.equals(unknownSchemaNodes, other.getUnknownSchemaNodes());
97 public String toString() {
98 return MoreObjects.toStringHelper(this).add("name", name).add("value", value).toString();