Improve equals generation for jvpp DTOs
Variable 'other' is no longer defined in equals method
of DTOs without defined fileds.
Fixes dead local store coverity issues.
Change-Id: I69eddf2b4b3f433149ff4d49e49c46515572d61a
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
diff --git a/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py b/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
index b117288..1235479 100644
--- a/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
+++ b/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
@@ -150,7 +150,9 @@
return tostring_template.substitute(cls_name=camel_case_dto_name,
fields_tostring=tostring_fields[:-8])
-
+equals_other_template = Template("""
+ final $cls_name other = ($cls_name) o;
+\n""")
equals_field_template = Template(""" if (!java.util.Objects.equals(this.$field_name, other.$field_name)) {
return false;
}\n""")
@@ -165,9 +167,6 @@
if (o == null || getClass() != o.getClass()) {
return false;
}
-
- final $cls_name other = ($cls_name) o;
-
$comparisons
return true;
}\n\n""")
@@ -187,8 +186,10 @@
else:
equals_fields += equals_field_template.substitute(field_name=field_name)
- return equals_template.substitute(cls_name=camel_case_dto_name,
- comparisons=equals_fields)
+ if equals_fields != "":
+ equals_fields = equals_other_template.substitute(cls_name=camel_case_dto_name) + equals_fields
+
+ return equals_template.substitute(comparisons=equals_fields)
hash_template = Template(""" @Override