File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -4098,6 +4098,8 @@ def generate_union_equals(self, data_type):
4098
4098
with w .block ('public boolean equals(Object obj)' ):
4099
4099
with w .block ('if (obj == this)' ):
4100
4100
w .out ('return true;' )
4101
+ with w .block ('if (obj == null)' ):
4102
+ w .out ('return false;' )
4101
4103
with w .block ('else if (obj instanceof %s)' , j .java_class (data_type )):
4102
4104
w .out ('%s other = (%s) obj;' , j .java_class (data_type ), j .java_class (data_type ))
4103
4105
with w .block ('if (this._tag != other._tag)' ):
@@ -4128,6 +4130,8 @@ def generate_struct_equals(self, data_type):
4128
4130
with w .block ('public boolean equals(Object obj)' ):
4129
4131
with w .block ('if (obj == this)' ):
4130
4132
w .out ('return true;' )
4133
+ with w .block ('if (obj == null)' ):
4134
+ w .out ('return false;' )
4131
4135
w .out ('// be careful with inheritance' )
4132
4136
with w .block ('else if (obj.getClass().equals(this.getClass()))' ):
4133
4137
w .out ('%s other = (%s) obj;' , j .java_class (data_type ), j .java_class (data_type ))
You can’t perform that action at this time.
0 commit comments