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;
10 import com.google.common.base.MoreObjects;
11 import com.google.common.base.Preconditions;
12 import com.google.common.collect.ImmutableList;
13 import java.util.Collection;
14 import java.util.List;
15 import java.util.Objects;
16 import org.opendaylight.yangtools.concepts.Immutable;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 import org.opendaylight.yangtools.yang.model.api.Status;
19 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
22 public final class EnumPairImpl implements EnumPair, Immutable {
23 private final List<UnknownSchemaNode> unknownSchemaNodes;
24 private final String description;
25 private final String reference;
26 private final Status status;
27 private final Integer value;
28 private final String name;
31 * @deprecated Use the constructor without a SchemaPath
34 public EnumPairImpl(final String name, final Integer value, final SchemaPath path, final String description,
35 final String reference, final Status status, final Collection<UnknownSchemaNode> unknownSchemaNodes) {
36 this(name, value, description, reference, status, unknownSchemaNodes);
39 public EnumPairImpl(final String name, final Integer value, final String description, final String reference,
40 final Status status, final Collection<UnknownSchemaNode> unknownSchemaNodes) {
41 this.value = Preconditions.checkNotNull(value);
42 this.name = Preconditions.checkNotNull(name);
43 this.description = description;
44 this.reference = reference;
45 this.status = Preconditions.checkNotNull(status);
46 this.unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodes);
50 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
51 return unknownSchemaNodes;
55 public String getDescription() {
60 public String getReference() {
65 public Status getStatus() {
70 public String getName() {
75 public Integer getValue() {
80 public int hashCode() {
83 result = prime * result + Objects.hashCode(unknownSchemaNodes);
84 result = prime * result + Objects.hashCode(name);
85 result = prime * result + Objects.hashCode(value);
90 public boolean equals(final Object obj) {
94 if (!(obj instanceof EnumPair)) {
97 EnumPair other = (EnumPair) obj;
98 if (!Objects.equals(name, other.getName())) {
102 return Objects.equals(value, other.getValue()) &&
103 Objects.equals(unknownSchemaNodes, other.getUnknownSchemaNodes());
107 public String toString() {
108 return MoreObjects.toStringHelper(this).add("name", name).add("value", value).toString();