Bug 3336 - Binding DTOs: fix binary-derived constructor 60/21560/3
authorJan Hajnar <jhajnar@cisco.com>
Mon, 1 Jun 2015 14:40:16 +0000 (16:40 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 5 Jun 2015 10:46:37 +0000 (10:46 +0000)
* added condition to only check for null in value assignmet if class has
one property (because then CheckNull is generated before assgnment)

Change-Id: I3bd18ec60347b3d1d5dec32e7bcafa432c56b5ad
Signed-off-by: Jan Hajnar <jhajnar@cisco.com>
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend

index dc1d88110c91173025911ba129dbd30e6e8f3b1e..d9dd1c1c3bb3018cb56aaae372b1f4928fbb8b72 100644 (file)
@@ -311,7 +311,12 @@ class ClassTemplate extends BaseTemplate {
 
         «FOR p : properties»
             «IF p.returnType.importedName.contains("[]")»
-            this.«p.fieldName» = «p.fieldName» == null ? null : «p.fieldName».clone();
+                «IF genTO.typedef && !allProperties.empty && allProperties.size == 1 && allProperties.get(0).name
+                .equals("value")»
+                this.«p.fieldName» = «p.fieldName».clone();
+                «ELSE»
+                this.«p.fieldName» = «p.fieldName» == null ? null : «p.fieldName».clone();
+                «ENDIF»
             «ELSE»
             this.«p.fieldName» = «p.fieldName»;
             «ENDIF»