Skip to content

Commit

Permalink
Add additionalProperties to equals/toString/hashcode
Browse files Browse the repository at this point in the history
  • Loading branch information
sschnabe committed Oct 6, 2023
1 parent 7cc4f97 commit 20b5004
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
7 changes: 5 additions & 2 deletions gen/main/java/issue/_303/MapConstruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ public boolean equals(Object object) {
if (object == null || getClass() != object.getClass()) {
return false;
}
return super.equals(object);
MapConstruct other = (MapConstruct) object;
return java.util.Objects.equals(this.additionalProperties, other.additionalProperties)
&& super.equals(object);
}

@Override
public int hashCode() {
return java.util.Objects.hash();
return java.util.Objects.hash(this.additionalProperties);
}

@Override
public java.lang.String toString() {
return new java.lang.StringBuilder()
.append("MapConstruct[")
.append("additionalProperties=").append(this.additionalProperties)
.append("]")
.toString();
}
Expand Down
7 changes: 5 additions & 2 deletions gen/main/java/issue/_315/ServiceScopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ public boolean equals(Object object) {
if (object == null || getClass() != object.getClass()) {
return false;
}
return super.equals(object);
ServiceScopes other = (ServiceScopes) object;
return java.util.Objects.equals(this.additionalProperties, other.additionalProperties)
&& super.equals(object);
}

@Override
public int hashCode() {
return java.util.Objects.hash();
return java.util.Objects.hash(this.additionalProperties);
}

@Override
public java.lang.String toString() {
return new java.lang.StringBuilder()
.append("ServiceScopes[")
.append("additionalProperties=").append(this.additionalProperties)
.append("]")
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ public boolean equals(Object object) {
return false;
}
AdditionalPropertiesModel other = (AdditionalPropertiesModel) object;
return java.util.Objects.equals(id, other.id);
return java.util.Objects.equals(this.additionalProperties, other.additionalProperties)
&& java.util.Objects.equals(id, other.id);
}

@Override
public int hashCode() {
return java.util.Objects.hash(id);
return java.util.Objects.hash(this.additionalProperties, id);
}

@Override
public java.lang.String toString() {
return new java.lang.StringBuilder()
.append("AdditionalPropertiesModel[")
.append("additionalProperties=").append(this.additionalProperties)
.append("id=").append(id)
.append("]")
.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ public boolean equals(Object object) {
return false;
}
AdditionalPropertiesModel other = (AdditionalPropertiesModel) object;
return java.util.Objects.equals(id, other.id);
return java.util.Objects.equals(this.additionalProperties, other.additionalProperties)
&& java.util.Objects.equals(id, other.id);
}

@Override
public int hashCode() {
return java.util.Objects.hash(id);
return java.util.Objects.hash(this.additionalProperties, id);
}

@Override
public java.lang.String toString() {
return new java.lang.StringBuilder()
.append("AdditionalPropertiesModel[")
.append("additionalProperties=").append(this.additionalProperties)
.append("id=").append(id)
.append("]")
.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ public boolean equals(Object object) {
return false;
}
AdditionalPropertiesModel other = (AdditionalPropertiesModel) object;
return java.util.Objects.equals(id, other.id);
return java.util.Objects.equals(this.additionalProperties, other.additionalProperties)
&& java.util.Objects.equals(id, other.id);
}

@Override
public int hashCode() {
return java.util.Objects.hash(id);
return java.util.Objects.hash(this.additionalProperties, id);
}

@Override
public java.lang.String toString() {
return new java.lang.StringBuilder()
.append("AdditionalPropertiesModel[")
.append("additionalProperties=").append(this.additionalProperties)
.append("id=").append(id)
.append("]")
.toString();
Expand Down
13 changes: 8 additions & 5 deletions src/main/resources/Micronaut/modelPojo.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,28 @@ public {{#discriminator}}abstract {{/discriminator}}class {{classname}}{{^parent
if (object == null || getClass() != object.getClass()) {
return false;
}
{{^vars}}{{#discriminator}} {{classname}} other = ({{classname}}) object;
{{/discriminator}}{{/vars}}{{#vars}}{{#-last}} {{classname}} other = ({{classname}}) object;
{{/-last}}{{/vars}} return {{^vars}}{{#discriminator}}java.util.Objects.equals({{discriminator.propertyGetter}}(), other.{{discriminator.propertyGetter}}());{{/discriminator}}{{^discriminator}}super.equals(object);{{/discriminator}}{{/vars}}{{#vars}}{{^isFile}}{{^isByteArray}}java.util.Objects{{/isByteArray}}{{/isFile}}{{#isByteArray}}java.util.Arrays{{/isByteArray}}{{#isFile}}java.util.Arrays{{/isFile}}.equals({{name}}, other.{{name}}){{^-last}}
{{^vars}}{{^discriminator}}{{#vendorExtensions.additionalPropertiesMap}} {{classname}} other = ({{classname}}) object;
{{/vendorExtensions.additionalPropertiesMap}}{{/discriminator}}{{#discriminator}}{{^vendorExtensions.additionalPropertiesMap}} {{classname}} other = ({{classname}}) object;
{{/vendorExtensions.additionalPropertiesMap}}{{/discriminator}}{{/vars}}{{#vars}}{{#-last}} {{classname}} other = ({{classname}}) object;
{{/-last}}{{/vars}} return {{#vendorExtensions.additionalPropertiesMap}}java.util.Objects.equals(this.additionalProperties, other.additionalProperties)
&& {{/vendorExtensions.additionalPropertiesMap}}{{^vars}}{{#discriminator}}java.util.Objects.equals({{discriminator.propertyGetter}}(), other.{{discriminator.propertyGetter}}());{{/discriminator}}{{^discriminator}}super.equals(object);{{/discriminator}}{{/vars}}{{#vars}}{{^isFile}}{{^isByteArray}}java.util.Objects{{/isByteArray}}{{/isFile}}{{#isByteArray}}java.util.Arrays{{/isByteArray}}{{#isFile}}java.util.Arrays{{/isFile}}.equals({{name}}, other.{{name}}){{^-last}}
&& {{/-last}}{{#-last}}{{#discriminator}}
&& java.util.Objects.equals({{discriminator.propertyGetter}}(), other.{{discriminator.propertyGetter}}()){{/discriminator}}{{#parent}}
&& super.equals(object){{/parent}};{{/-last}}{{/vars}}
}

@Override
public int hashCode() {
return java.util.Objects.hash({{^vars}}{{#discriminator}}{{discriminator.propertyGetter}}(){{/discriminator}}{{/vars}}{{#vars}}{{^isFile}}{{^isByteArray}}{{name}}{{/isByteArray}}{{/isFile}}{{#isByteArray}}java.util.Arrays.hashCode({{name}}){{/isByteArray}}{{#isFile}}java.util.Arrays.hashCode({{name}}){{/isFile}}{{^-last}}, {{/-last}}{{#-last}}{{#discriminator}}, {{discriminator.propertyGetter}}(){{/discriminator}}{{#parent}}, super.hashCode(){{/parent}}{{/-last}}{{/vars}});
return java.util.Objects.hash({{#vendorExtensions.additionalPropertiesMap}}this.additionalProperties{{#vars}}, {{/vars}}{{/vendorExtensions.additionalPropertiesMap}}{{^vars}}{{#discriminator}}{{discriminator.propertyGetter}}(){{/discriminator}}{{/vars}}{{#vars}}{{^isFile}}{{^isByteArray}}{{name}}{{/isByteArray}}{{/isFile}}{{#isByteArray}}java.util.Arrays.hashCode({{name}}){{/isByteArray}}{{#isFile}}java.util.Arrays.hashCode({{name}}){{/isFile}}{{^-last}}, {{/-last}}{{#-last}}{{#discriminator}}, {{discriminator.propertyGetter}}(){{/discriminator}}{{#parent}}, super.hashCode(){{/parent}}{{/-last}}{{/vars}});
}

@Override
public java.lang.String toString() {
return new java.lang.StringBuilder()
.append("{{classname}}["){{#parent}}
.append("super").append(super.toString()){{/parent}}
{{#vars}} .append("{{name}}{{^isByteArray}}=").append({{name}}{{/isByteArray}}{{#isByteArray}}.length=").append({{name}} == null ? null : {{name}}.length{{/isByteArray}}){{^-last}}.append(","){{/-last}}
{{#vendorExtensions.additionalPropertiesMap}} .append("additionalProperties=").append(this.additionalProperties)
{{/vendorExtensions.additionalPropertiesMap}}{{#vars}} .append("{{name}}{{^isByteArray}}=").append({{name}}{{/isByteArray}}{{#isByteArray}}.length=").append({{name}} == null ? null : {{name}}.length{{/isByteArray}}){{^-last}}.append(","){{/-last}}
{{/vars}} .append("]")
.toString();
}{{#vars}}{{#-first}}
Expand Down

0 comments on commit 20b5004

Please sign in to comment.