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 org.opendaylight.yangtools.concepts.Immutable;
15 import org.opendaylight.yangtools.yang.model.api.Status;
16 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
19 final class EnumPairImpl implements EnumPair, Immutable {
20 private final List<UnknownSchemaNode> unknownSchemaNodes;
21 private final String description;
22 private final String reference;
23 private final Status status;
24 private final Integer value;
25 private final String name;
27 EnumPairImpl(final String name, final Integer value, final String description, final String reference,
28 final Status status, final List<UnknownSchemaNode> unknownSchemaNodes) {
29 this.value = Preconditions.checkNotNull(value);
30 this.name = Preconditions.checkNotNull(name);
31 this.description = description;
32 this.reference = reference;
33 this.status = Preconditions.checkNotNull(status);
34 this.unknownSchemaNodes = Preconditions.checkNotNull(unknownSchemaNodes);
38 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
39 return unknownSchemaNodes;
43 public String getDescription() {
48 public String getReference() {
53 public Status getStatus() {
58 public String getName() {
63 public Integer getValue() {
68 public int hashCode() {
71 result = prime * result + unknownSchemaNodes.hashCode();
72 result = prime * result + name.hashCode();
73 result = prime * result + value.hashCode();
78 public boolean equals(final Object obj) {
82 if (!(obj instanceof EnumPair)) {
85 EnumPair other = (EnumPair) obj;
86 if (!Objects.equals(name, other.getName())) {
90 return Objects.equals(value, other.getValue()) &&
91 Objects.equals(unknownSchemaNodes, other.getUnknownSchemaNodes());
95 public String toString() {
96 return MoreObjects.toStringHelper(this).add("name", name).add("value", value).toString();