| OLD | NEW |
| 1 {% from "constant_definition.tmpl" import constant_def %} | 1 {% from "constant_definition.tmpl" import constant_def %} |
| 2 {% from "enum_definition.tmpl" import enum_def %} | 2 {% from "enum_definition.tmpl" import enum_def %} |
| 3 | 3 |
| 4 {%- macro inequality(kind, v1, v2) -%} | 4 {%- macro inequality(kind, v1, v2) -%} |
| 5 {%- if kind|is_reference_kind -%} | 5 {%- if kind|is_reference_kind -%} |
| 6 {%- if kind|is_array_kind -%} | 6 {%- if kind|is_array_kind -%} |
| 7 {%- if kind.kind|is_reference_kind -%} | 7 {%- if kind.kind|is_reference_kind -%} |
| 8 !java.util.Arrays.deepEquals({{v1}}, {{v2}}) | 8 !java.util.Arrays.deepEquals({{v1}}, {{v2}}) |
| 9 {%- else -%} | 9 {%- else -%} |
| 10 !java.util.Arrays.equals({{v1}}, {{v2}}) | 10 !java.util.Arrays.equals({{v1}}, {{v2}}) |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 * @see Object#equals(Object) | 180 * @see Object#equals(Object) |
| 181 */ | 181 */ |
| 182 @Override | 182 @Override |
| 183 public boolean equals(Object object) { | 183 public boolean equals(Object object) { |
| 184 if (object == this) | 184 if (object == this) |
| 185 return true; | 185 return true; |
| 186 if (object == null) | 186 if (object == null) |
| 187 return false; | 187 return false; |
| 188 if (getClass() != object.getClass()) | 188 if (getClass() != object.getClass()) |
| 189 return false; | 189 return false; |
| 190 {% if struct.fields|length %} |
| 190 {{struct|name}} other = ({{struct|name}}) object; | 191 {{struct|name}} other = ({{struct|name}}) object; |
| 191 {% for field in struct.fields %} | 192 {% for field in struct.fields %} |
| 192 if ({{inequality(field.kind, field|name, 'other.'~field|name)}}) | 193 if ({{inequality(field.kind, field|name, 'other.'~field|name)}}) |
| 193 return false; | 194 return false; |
| 194 {% endfor %} | 195 {% endfor %} |
| 196 {% endif %} |
| 195 return true; | 197 return true; |
| 196 } | 198 } |
| 197 | 199 |
| 198 /** | 200 /** |
| 199 * @see Object#hashCode() | 201 * @see Object#hashCode() |
| 200 */ | 202 */ |
| 201 @Override | 203 @Override |
| 202 public int hashCode() { | 204 public int hashCode() { |
| 203 final int prime = 31; | 205 final int prime = 31; |
| 204 int result = 1; | 206 int result = prime + getClass().hashCode(); |
| 205 {% for field in struct.fields %} | 207 {% for field in struct.fields %} |
| 206 result = prime * result + {{hash(field.kind, field|name)}}; | 208 result = prime * result + {{hash(field.kind, field|name)}}; |
| 207 {% endfor %} | 209 {% endfor %} |
| 208 return result; | 210 return result; |
| 209 } | 211 } |
| 210 } | 212 } |
| 211 {% endmacro %} | 213 {% endmacro %} |
| OLD | NEW |