X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fcode-generator%2Fbinding-generator-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fyang%2Ftypes%2FBaseYangTypes.java;h=374ad8bf9251463b0dc9e86896a105b4f64f20e0;hp=d00b73d676bee50ccf29affa6e6370a698528652;hb=d0f1a6162437a9e003e87c7a8b36ea875f8de984;hpb=42210c03b0a4c54706320ba9f55794c0abd4d201 diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/yang/types/BaseYangTypes.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/yang/types/BaseYangTypes.java index d00b73d676..374ad8bf92 100644 --- a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/yang/types/BaseYangTypes.java +++ b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/yang/types/BaseYangTypes.java @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.yang.types; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; - -import org.opendaylight.controller.binding.generator.util.Types; -import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider; -import org.opendaylight.controller.sal.binding.model.api.Type; -import org.opendaylight.controller.yang.model.api.TypeDefinition; - -public class BaseYangTypes { - - private static Map typeMap = new HashMap(); - - public static final Type BOOLEAN_TYPE = Types.typeForClass(Boolean.class); - public static final Type INT8_TYPE = Types.typeForClass(Byte.class); - public static final Type INT16_TYPE = Types.typeForClass(Short.class); - public static final Type INT32_TYPE = Types.typeForClass(Integer.class); - public static final Type INT64_TYPE = Types.typeForClass(Long.class); - public static final Type STRING_TYPE = Types.typeForClass(String.class); - public static final Type DECIMAL64_TYPE = Types.typeForClass(Double.class); - public static final Type UINT8_TYPE = Types.typeForClass(Short.class); - public static final Type UINT16_TYPE = Types.typeForClass(Integer.class); - public static final Type UINT32_TYPE = Types.typeForClass(Long.class); - public static final Type UINT64_TYPE = Types.typeForClass(BigDecimal.class); - - static { - typeMap.put("boolean", BOOLEAN_TYPE); - typeMap.put("int8", INT8_TYPE); - typeMap.put("int16", INT16_TYPE); - typeMap.put("int32", INT32_TYPE); - typeMap.put("int64", INT64_TYPE); - typeMap.put("string", STRING_TYPE); - typeMap.put("decimal64", DECIMAL64_TYPE); - typeMap.put("uint8", UINT8_TYPE); - typeMap.put("uint16", UINT16_TYPE); - typeMap.put("uint32", UINT32_TYPE); - typeMap.put("uint64", UINT64_TYPE); - - } - - public static final TypeProvider BASE_YANG_TYPES_PROVIDER = new TypeProvider() { - - @Override - public Type javaTypeForYangType(String type) { - return typeMap.get(type); - } - - @Override - public Type javaTypeForSchemaDefinitionType(TypeDefinition type) { - if (type != null) { - return typeMap.get(type.getQName().getLocalName()); - } - - return null; - } - }; - -} +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.sal.binding.yang.types; + +import java.math.BigInteger; +import java.util.HashMap; +import java.util.Map; + +import org.opendaylight.controller.binding.generator.util.Types; +import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider; +import org.opendaylight.controller.sal.binding.model.api.Type; +import org.opendaylight.controller.yang.model.api.TypeDefinition; + +public class BaseYangTypes { + + private static Map typeMap = new HashMap(); + + public static final Type BOOLEAN_TYPE = Types.typeForClass(Boolean.class); + public static final Type EMPTY_TYPE = Types.typeForClass(Boolean.class); + public static final Type INT8_TYPE = Types.typeForClass(Byte.class); + public static final Type INT16_TYPE = Types.typeForClass(Short.class); + public static final Type INT32_TYPE = Types.typeForClass(Integer.class); + public static final Type INT64_TYPE = Types.typeForClass(Long.class); + public static final Type STRING_TYPE = Types.typeForClass(String.class); + public static final Type DECIMAL64_TYPE = Types.typeForClass(Double.class); + public static final Type UINT8_TYPE = Types.typeForClass(Short.class); + public static final Type UINT16_TYPE = Types.typeForClass(Integer.class); + public static final Type UINT32_TYPE = Types.typeForClass(Long.class); + public static final Type UINT64_TYPE = Types.typeForClass(BigInteger.class); + + static { + typeMap.put("boolean", BOOLEAN_TYPE); + typeMap.put("empty", EMPTY_TYPE); + typeMap.put("int8", INT8_TYPE); + typeMap.put("int16", INT16_TYPE); + typeMap.put("int32", INT32_TYPE); + typeMap.put("int64", INT64_TYPE); + typeMap.put("string", STRING_TYPE); + typeMap.put("decimal64", DECIMAL64_TYPE); + typeMap.put("uint8", UINT8_TYPE); + typeMap.put("uint16", UINT16_TYPE); + typeMap.put("uint32", UINT32_TYPE); + typeMap.put("uint64", UINT64_TYPE); + } + + public static final TypeProvider BASE_YANG_TYPES_PROVIDER = new TypeProvider() { + + @Override + public Type javaTypeForYangType(String type) { + return typeMap.get(type); + } + + @Override + public Type javaTypeForSchemaDefinitionType(TypeDefinition type) { + if (type != null) { + return typeMap.get(type.getQName().getLocalName()); + } + + return null; + } + }; +}