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.mdsal.binding.generator.util;
10 import com.google.common.collect.ImmutableMap;
11 import java.math.BigDecimal;
12 import org.opendaylight.mdsal.binding.model.api.Type;
13 import org.opendaylight.mdsal.binding.model.util.Types;
14 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
15 import org.opendaylight.yangtools.yang.common.Empty;
16 import org.opendaylight.yangtools.yang.common.Uint16;
17 import org.opendaylight.yangtools.yang.common.Uint32;
18 import org.opendaylight.yangtools.yang.common.Uint64;
19 import org.opendaylight.yangtools.yang.common.Uint8;
21 public final class BaseYangTypes {
23 * <code>Type</code> representation of <code>boolean</code> YANG type.
25 public static final Type BOOLEAN_TYPE = Types.BOOLEAN;
28 * <code>Type</code> representation of <code>empty</code> YANG type.
30 public static final Type EMPTY_TYPE = Types.typeForClass(Empty.class);
32 public static final Type ENUM_TYPE = Types.typeForClass(Enum.class);
35 * <code>Type</code> representation of <code>int8</code> YANG type.
37 public static final Type INT8_TYPE = Types.typeForClass(Byte.class);
40 * <code>Type</code> representation of <code>int16</code> YANG type.
42 public static final Type INT16_TYPE = Types.typeForClass(Short.class);
45 * <code>Type</code> representation of <code>int32</code> YANG type.
47 public static final Type INT32_TYPE = Types.typeForClass(Integer.class);
50 * <code>Type</code> representation of <code>int64</code> YANG type.
52 public static final Type INT64_TYPE = Types.typeForClass(Long.class);
55 * <code>Type</code> representation of <code>string</code> YANG type.
57 public static final Type STRING_TYPE = Types.STRING;
60 * <code>Type</code> representation of <code>decimal64</code> YANG type.
62 public static final Type DECIMAL64_TYPE = Types.typeForClass(BigDecimal.class);
65 * <code>Type</code> representation of <code>uint8</code> YANG type.
67 public static final Type UINT8_TYPE = Types.typeForClass(Uint8.class);
70 * <code>Type</code> representation of <code>uint16</code> YANG type.
72 public static final Type UINT16_TYPE = Types.typeForClass(Uint16.class);
75 * <code>Type</code> representation of <code>uint32</code> YANG type.
77 public static final Type UINT32_TYPE = Types.typeForClass(Uint32.class);
80 * <code>Type</code> representation of <code>uint64</code> YANG type.
82 public static final Type UINT64_TYPE = Types.typeForClass(Uint64.class);
85 * <code>Type</code> representation of <code>binary</code> YANG type.
87 public static final Type BINARY_TYPE = Types.typeForClass(byte[].class);
89 public static final Type INSTANCE_IDENTIFIER = Types.parameterizedTypeFor(Types
90 .typeForClass(InstanceIdentifier.class));
93 * mapping of basic built-in YANG types (keys) to JAVA {@link org.opendaylight.mdsal.binding.model.api.Type Type}.
94 * This map is filled with mapping data in static initialization block.
96 private static final ImmutableMap<String, Type> TYPE_MAP = ImmutableMap.<String, Type>builder()
97 .put("boolean", BOOLEAN_TYPE)
98 .put("empty", EMPTY_TYPE)
99 .put("enumeration", ENUM_TYPE)
100 .put("int8", INT8_TYPE)
101 .put("int16", INT16_TYPE)
102 .put("int32", INT32_TYPE)
103 .put("int64", INT64_TYPE)
104 .put("string", STRING_TYPE)
105 .put("decimal64", DECIMAL64_TYPE)
106 .put("uint8", UINT8_TYPE)
107 .put("uint16", UINT16_TYPE)
108 .put("uint32", UINT32_TYPE)
109 .put("uint64", UINT64_TYPE)
110 .put("binary", BINARY_TYPE)
111 .put("instance-identifier", INSTANCE_IDENTIFIER)
115 * It is undesirable to create instance of this class.
117 private BaseYangTypes() {
122 * Searches <code>Type</code> value to which is YANG <code>type</code>
126 * string with YANG type name
127 * @return java <code>Type</code> representation of <code>type</code>
129 public static Type javaTypeForYangType(final String type) {
130 return TYPE_MAP.get(type);