X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-model-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Futil%2FYangTypesConverter.java;h=98c63d022ba6a8a3a734a7b03897e8526e174afc;hb=1a2b11ce0b23d8a8942f39abb89993861c27e999;hp=f7ea048a0780003c444c1516a8f3a8dae802f0ed;hpb=df1236c753c1e917b587686efb9251f83e49cfb2;p=yangtools.git diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/YangTypesConverter.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/YangTypesConverter.java index f7ea048a07..98c63d022b 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/YangTypesConverter.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/YangTypesConverter.java @@ -1,83 +1,46 @@ -/* - * 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.yangtools.yang.model.util; - -import java.util.HashSet; -import java.util.Set; - -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; - -public final class YangTypesConverter { - private static final Set baseYangTypes = new HashSet(); - - static { - baseYangTypes.add("binary"); - baseYangTypes.add("bits"); - baseYangTypes.add("boolean"); - baseYangTypes.add("decimal64"); - baseYangTypes.add("empty"); - baseYangTypes.add("enumeration"); - baseYangTypes.add("identityref"); - baseYangTypes.add("instance-identifier"); - baseYangTypes.add("int8"); - baseYangTypes.add("int16"); - baseYangTypes.add("int32"); - baseYangTypes.add("int64"); - baseYangTypes.add("leafref"); - baseYangTypes.add("string"); - baseYangTypes.add("uint8"); - baseYangTypes.add("uint16"); - baseYangTypes.add("uint32"); - baseYangTypes.add("uint64"); - baseYangTypes.add("union"); - } - - public static boolean isBaseYangType(String type) { - return baseYangTypes.contains(type); - } - - public static TypeDefinition javaTypeForBaseYangType(SchemaPath path, String typeName) { - TypeDefinition type = null; - - if (typeName.startsWith("int")) { - if ("int8".equals(typeName)) { - type = new Int8(path); - } else if ("int16".equals(typeName)) { - type = new Int16(path); - } else if ("int32".equals(typeName)) { - type = new Int32(path); - } else if ("int64".equals(typeName)) { - type = new Int64(path); - } - } else if (typeName.startsWith("uint")) { - if ("uint8".equals(typeName)) { - type = new Uint8(path); - } else if ("uint16".equals(typeName)) { - type = new Uint16(path); - } else if ("uint32".equals(typeName)) { - type = new Uint32(path); - } else if ("uint64".equals(typeName)) { - type = new Uint64(path); - } - } else if ("string".equals(typeName)) { - type = new StringType(path); - } else if("binary".equals(typeName)) { - type = new BinaryType(path); - } else if("boolean".equals(typeName)) { - type = new BooleanType(path); - } else if("empty".equals(typeName)) { - type = new EmptyType(path); - } else if("instance-identifier".equals(typeName)) { - type = new InstanceIdentifier(path, null, true); - } - - return type; - } - -} +/* + * 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.yangtools.yang.model.util; + +import org.opendaylight.yangtools.yang.model.api.TypeDefinition; + +/** + * Utility class which provides various helper methods for working with YANG + * built-in types. + * + * @deprecated Use {@link BaseTypes} instead. + */ +@Deprecated +public final class YangTypesConverter { + /** + * It isn't desirable to create the instances of this class + */ + private YangTypesConverter() { + } + + @Deprecated + public static boolean isBaseYangType(final String type) { + return BaseTypes.isYangBuildInType(type); + } + + /** + * + * Returns default instance of built-in type for supplied string. + * + * @param typeName + * @return default instance of built-in type for supplied string or null, if + * default instance does not exist. + * + * @deprecated Use {@link BaseTypes#defaultBaseTypeFor(String)} instead. + */ + @Deprecated + public static TypeDefinition javaTypeForBaseYangType(final String typeName) { + return BaseTypes.defaultBaseTypeFor(typeName).orNull(); + } + +}