Fix minor bug in FRM proactive flow code path
[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 final 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 EMPTY_TYPE = Types.typeForClass(Boolean.class);
25     public static final Type INT8_TYPE = Types.typeForClass(Byte.class);
26     public static final Type INT16_TYPE = Types.typeForClass(Short.class);
27     public static final Type INT32_TYPE = Types.typeForClass(Integer.class);
28     public static final Type INT64_TYPE = Types.typeForClass(Long.class);
29     public static final Type STRING_TYPE = Types.typeForClass(String.class);
30     public static final Type DECIMAL64_TYPE = Types.typeForClass(Double.class);
31     public static final Type UINT8_TYPE = Types.typeForClass(Short.class);
32     public static final Type UINT16_TYPE = Types.typeForClass(Integer.class);
33     public static final Type UINT32_TYPE = Types.typeForClass(Long.class);
34     public static final Type UINT64_TYPE = Types.typeForClass(BigInteger.class);
35     public static final Type BINARY_TYPE = Types.primitiveType("byte[]");
36
37     static {
38         typeMap.put("boolean", BOOLEAN_TYPE);
39         typeMap.put("empty", EMPTY_TYPE);
40         typeMap.put("int8", INT8_TYPE);
41         typeMap.put("int16", INT16_TYPE);
42         typeMap.put("int32", INT32_TYPE);
43         typeMap.put("int64", INT64_TYPE);
44         typeMap.put("string", STRING_TYPE);
45         typeMap.put("decimal64", DECIMAL64_TYPE);
46         typeMap.put("uint8", UINT8_TYPE);
47         typeMap.put("uint16", UINT16_TYPE);
48         typeMap.put("uint32", UINT32_TYPE);
49         typeMap.put("uint64", UINT64_TYPE);
50         typeMap.put("binary", BINARY_TYPE);
51     }
52
53     public static final TypeProvider BASE_YANG_TYPES_PROVIDER = new TypeProvider() {
54
55         @Override
56         public Type javaTypeForYangType(String type) {
57             return typeMap.get(type);
58         }
59
60         @Override
61         public Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type) {
62             if (type != null) {
63                 return typeMap.get(type.getQName().getLocalName());
64             }
65
66             return null;
67         }
68     };
69 }