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.controller.sal.binding.yang.types;
10 import java.math.BigInteger;
11 import java.util.HashMap;
14 import org.opendaylight.controller.binding.generator.util.Types;
15 import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;
16 import org.opendaylight.controller.sal.binding.model.api.Type;
17 import org.opendaylight.controller.yang.model.api.TypeDefinition;
19 public class BaseYangTypes {
21 private static Map<String, Type> typeMap = new HashMap<String, Type>();
23 public static final Type BOOLEAN_TYPE = Types.typeForClass(Boolean.class);
24 public static final Type INT8_TYPE = Types.typeForClass(Byte.class);
25 public static final Type INT16_TYPE = Types.typeForClass(Short.class);
26 public static final Type INT32_TYPE = Types.typeForClass(Integer.class);
27 public static final Type INT64_TYPE = Types.typeForClass(Long.class);
28 public static final Type STRING_TYPE = Types.typeForClass(String.class);
29 public static final Type DECIMAL64_TYPE = Types.typeForClass(Double.class);
30 public static final Type UINT8_TYPE = Types.typeForClass(Short.class);
31 public static final Type UINT16_TYPE = Types.typeForClass(Integer.class);
32 public static final Type UINT32_TYPE = Types.typeForClass(Long.class);
33 public static final Type UINT64_TYPE = Types.typeForClass(BigInteger.class);
36 typeMap.put("boolean", BOOLEAN_TYPE);
37 typeMap.put("int8", INT8_TYPE);
38 typeMap.put("int16", INT16_TYPE);
39 typeMap.put("int32", INT32_TYPE);
40 typeMap.put("int64", INT64_TYPE);
41 typeMap.put("string", STRING_TYPE);
42 typeMap.put("decimal64", DECIMAL64_TYPE);
43 typeMap.put("uint8", UINT8_TYPE);
44 typeMap.put("uint16", UINT16_TYPE);
45 typeMap.put("uint32", UINT32_TYPE);
46 typeMap.put("uint64", UINT64_TYPE);
49 public static final TypeProvider BASE_YANG_TYPES_PROVIDER = new TypeProvider() {
52 public Type javaTypeForYangType(String type) {
53 return typeMap.get(type);
57 public Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type) {
59 return typeMap.get(type.getQName().getLocalName());