lib/vdl/codegen/java: don't emit a cast unless there are fields to be compared
This change fixes findbugs warnings in generated code.
Change-Id: Ib7a3443f873ad4cc86ea87e1895e3b5f2373016f
diff --git a/lib/vdl/codegen/java/file_struct.go b/lib/vdl/codegen/java/file_struct.go
index e2083e2..a5058f8 100644
--- a/lib/vdl/codegen/java/file_struct.go
+++ b/lib/vdl/codegen/java/file_struct.go
@@ -66,7 +66,7 @@
if (this == obj) return true;
if (obj == null) return false;
if (this.getClass() != obj.getClass()) return false;
- final {{.Name}} other = ({{.Name}})obj;
+ {{ if gt (len .Fields) 0 }} final {{.Name}} other = ({{.Name}})obj; {{ end }}
{{ range $field := .Fields }}
{{ if .IsArray }}