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.opendaylight.yangtools.yang.model.api.TypeDefinition;
15 * Contains the method which access union item in the union type.
17 public interface UnionTypeDefinition extends TypeDefinition<UnionTypeDefinition> {
20 * Returns type definitions which represent the values of the arguments for
21 * all YANG <code>type</code> substatement in the main <code>union</code>
24 * @return list of the type definition which contains the union items.
26 List<TypeDefinition<?>> getTypes();
28 static int hashCode(final UnionTypeDefinition type) {
29 return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(),
30 type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getTypes());
33 static boolean equals(final UnionTypeDefinition type, final Object obj) {
38 final UnionTypeDefinition other = TypeDefinitions.castIfEquals(UnionTypeDefinition.class, type, obj);
39 return other != null && type.getTypes().equals(other.getTypes());
42 static String toString(final UnionTypeDefinition type) {
43 return TypeDefinitions.toStringHelper(type).add("types", type.getTypes()).toString();