2 * Copyright (c) 2013 Cisco Systems, Inc. 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.api.type;
10 import java.util.List;
11 import java.util.Objects;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
15 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
18 * Makes is possible to access to the individual enumeration values of this type.
20 public interface EnumTypeDefinition extends TypeDefinition<EnumTypeDefinition> {
22 * Contains the methods for accessing the data about the concrete enumeration item which represents {@code enum}
25 interface EnumPair extends DocumentedNode.WithStatus {
27 * The name to specify each assigned name of an enumeration type.
29 * @return name of each assigned name of an enumeration type.
34 * The "value" statement, which is optional, is used to associate an integer value with the assigned name
35 * for the enum. This integer value MUST be unique within the enumeration type.
37 * @return integer value assigned to enumeration
43 * Returns all enumeration values.
45 * @return list of {@code EnumPair} type instances which contain the data about all individual enumeration pairs
46 * of {@code enumeration} YANG built-in type
48 @NonNull List<EnumPair> getValues();
50 static boolean equals(final @NonNull EnumTypeDefinition type, final @Nullable Object obj) {
55 final EnumTypeDefinition other = TypeDefinitions.castIfEquals(EnumTypeDefinition.class, type, obj);
56 return other != null && type.getValues().equals(other.getValues());
59 static int hashCode(final @NonNull EnumTypeDefinition type) {
60 return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(),
61 type.getUnits().orElse(null),
62 type.getDefaultValue(), type.getValues());
65 static String toString(final @NonNull EnumTypeDefinition type) {
66 return TypeDefinitions.toStringHelper(type).add("values", type.getValues()).toString();