Split out isBitsType() 81/100481/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 8 Apr 2022 10:38:44 +0000 (12:38 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 8 Apr 2022 10:39:10 +0000 (12:39 +0200)
Simplify dispatch of checking to a separate method.

Change-Id: I59e3baf22bf99ead66f43c7df0fd62ab2b030894
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/UnionTemplate.xtend

index c940dea1950d4e983c3d4c8cc9268df341860c14..4779907d5792efe1578be54ec177c27bb2f85a7b 100644 (file)
@@ -137,9 +137,7 @@ class UnionTemplate extends ClassTemplate {
                 «ELSEIF EMPTY_TYPE.equals(propRet) || EMPTY_TYPE.equals(propRet.typedefReturnType)»
                     ««« generated empty typedef
                 return "";
-                «ELSEIF propRet instanceof GeneratedTransferObject // Is it a GeneratedTransferObject
-                        && (propRet as GeneratedTransferObject).typedef  // Is it a typedef
-                        && (propRet as GeneratedTransferObject).baseType instanceof BitsTypeDefinition»
+                «ELSEIF propRet.isBitsType»
                     ««« generated bits typedef
                 return «JU_ARRAYS.importedName».toString(«field».getValue());
                 «ELSE»
@@ -152,6 +150,13 @@ class UnionTemplate extends ClassTemplate {
         }
     '''
 
+    private static def isBitsType(Type type) {
+        if (type instanceof GeneratedTransferObject) {
+            return type.typedef && type.baseType instanceof BitsTypeDefinition
+        }
+        return false
+    }
+
     private static def Type typedefReturnType(Type type) {
         if (!(type instanceof GeneratedTransferObject)) {
             return null