Added generate To File for specified directory.
[controller.git] / opendaylight / sal / yang-prototype / code-generator / binding-generator-impl / src / main / java / org / opendaylight / controller / sal / binding / yang / types / BaseYangTypes.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.binding.yang.types;
9
10 import java.math.BigInteger;
11 import java.util.HashMap;
12 import java.util.Map;
13
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;
18
19 public class BaseYangTypes {
20
21     private static Map<String, Type> typeMap = new HashMap<String, Type>();
22
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);
34
35     static {
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);
47     }
48
49     public static final TypeProvider BASE_YANG_TYPES_PROVIDER = new TypeProvider() {
50
51         @Override
52         public Type javaTypeForYangType(String type) {
53             return typeMap.get(type);
54         }
55
56         @Override
57         public Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type) {
58             if (type != null) {
59                 return typeMap.get(type.getQName().getLocalName());
60             }
61
62             return null;
63         }
64     };
65
66 }