Skip to content

Commit

Permalink
remove code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Tenischev committed Nov 16, 2023
1 parent d79b9ef commit ab6b3d2
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ public class {{allName}} {
this.{{varName}} = {{varName}};
}
{% endfor %}
{% if params.disableEqualsHashCode === 'false' %}@Override
{% if params.disableEqualsHashCode === 'false' %}@Override{% set hasProps = schema.properties() | length > 0 %}
public boolean equals(Object o) {
{%- if schema.properties() | length === 0 %}
{%- if not hasProps %}
return super.equals(o);
{% else %}
if (this == o) {
Expand All @@ -175,7 +175,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
{%- if schema.properties() | length === 0 %}
{%- if not hasProps %}
return super.hashCode();
{% else %}
return Objects.hash({% for propName, prop in schema.properties() %}{{propName | camelCase}}{% if not loop.last %}, {% endif %}{% endfor %});
Expand Down

0 comments on commit ab6b3d2

Please sign in to comment.