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.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
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 public final class EnumPairImpl implements EnumPair, Immutable {
24 private final List<UnknownSchemaNode> unknownSchemaNodes;
25 private final String description;
26 private final String reference;
27 private final SchemaPath path;
28 private final Status status;
29 private final Integer value;
30 private final String name;
32 public EnumPairImpl(final String name, final Integer value, final SchemaPath path, final String description,
33 final String reference, final Status status, final Collection<UnknownSchemaNode> unknownSchemaNodes) {
34 this.path = Preconditions.checkNotNull(path);
35 this.value = Preconditions.checkNotNull(value);
36 this.name = Preconditions.checkNotNull(name);
37 this.description = description;
38 this.reference = reference;
39 this.status = Preconditions.checkNotNull(status);
40 this.unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodes);
44 public QName getQName() {
45 return path.getLastComponent();
49 public SchemaPath getPath() {
54 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
55 return unknownSchemaNodes;
59 public String getDescription() {
64 public String getReference() {
69 public Status getStatus() {
74 public String getName() {
79 public Integer getValue() {
84 public int hashCode() {
87 result = prime * result + Objects.hashCode(path.getLastComponent());
88 result = prime * result + Objects.hashCode(path);
89 result = prime * result + Objects.hashCode(unknownSchemaNodes);
90 result = prime * result + Objects.hashCode(name);
91 result = prime * result + Objects.hashCode(value);
96 public boolean equals(final Object obj) {
100 if (!(obj instanceof EnumPair)) {
103 EnumPair other = (EnumPair) obj;
104 if (!Objects.equals(name, other.getName())) {
108 return Objects.equals(value, other.getValue()) && Objects.equals(getPath(), other.getPath()) &&
109 Objects.equals(unknownSchemaNodes, other.getUnknownSchemaNodes());
113 public String toString() {
114 return MoreObjects.toStringHelper(this).add("name", name).add("value", value).toString();