BUG-865: remove use of deprecated model instances 10/39910/5
authorRobert Varga <rovarga@cisco.com>
Mon, 6 Jun 2016 23:11:46 +0000 (01:11 +0200)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 15 Jun 2016 05:09:49 +0000 (05:09 +0000)
Type checking should be done via DerivedTypes test methods.

Change-Id: Iacefe651997ea464082e3286de8963864b92cc12
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLODLUtils.java

index 16a33b3..96c6d89 100644 (file)
@@ -28,10 +28,9 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
-import org.opendaylight.yangtools.yang.model.util.Uint16;
-import org.opendaylight.yangtools.yang.model.util.Uint32;
-import org.opendaylight.yangtools.yang.model.util.Uint64;
-import org.opendaylight.yangtools.yang.model.util.Uint8;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.util.type.DerivedTypes;
+
 /**
  * @author Sharon Aicler(saichler@gmail.com)
  **/
@@ -269,16 +268,19 @@ public class XSQLODLUtils {
     }
 
     public static Class<?> getTypeForODLColumn(Object odlNode){
-        Object type = get(odlNode,"type");
-        if(type instanceof Uint32 || type instanceof Uint64){
-            return long.class;
-        }else
-        if(type instanceof Uint16){
-            return int.class;
-        }else
-        if(type instanceof Uint8){
-            return byte.class;
+        final Object o = get(odlNode,"type");
+        if (o instanceof TypeDefinition) {
+            final TypeDefinition<?> type = (TypeDefinition<?>)o;
+
+            if (DerivedTypes.isUint32(type) || DerivedTypes.isUint64(type)) {
+                return long.class;
+            } else if (DerivedTypes.isUint16(type)) {
+                return int.class;
+            } else if (DerivedTypes.isUint8(type)) {
+                return byte.class;
+            }
         }
+
         return String.class;
     }