diff --git a/client/deployment/src/main/resources/templates/libraries/microprofile/pojo.qute b/client/deployment/src/main/resources/templates/libraries/microprofile/pojo.qute index ae5542c1e..f2fc851ea 100644 --- a/client/deployment/src/main/resources/templates/libraries/microprofile/pojo.qute +++ b/client/deployment/src/main/resources/templates/libraries/microprofile/pojo.qute @@ -1,5 +1,6 @@ {@org.openapitools.codegen.CodegenModel m} import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; {#if m.description} /** @@ -135,6 +136,49 @@ public class {m.classname} {#if m.parent}extends {m.parent}{/if}{#if serializabl return sb.toString(); } +{#if m.vars.size > 0} + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + {m.classname} model = ({m.classname}) o; + + {#if m.vars.size == 1} + return Objects.equals({m.vars.0.name}, model.{m.vars.0.name}); + {#else} + {#for v in m.vars} + {#if v_isFirst} + return Objects.equals({v.name}, model.{v.name}) && + {#else if v_isLast} + Objects.equals({v.name}, model.{v.name}); + {#else} + Objects.equals({v.name}, model.{v.name}) && + {/if} + {/for} + {/if} + } +{/if} + +{#if m.vars.size > 0} + @Override + public int hashCode() { + {#if m.vars.size == 1} + return Objects.hash({m.vars.0.name}); + {#else} + {#for v in m.vars} + {#if v_isFirst} + return Objects.hash({v.name}, + {#else if v_isLast} + {v.name}); + {#else} + {v.name}, + {/if} + {/for} + {/if} + } +{/if} + /** * Convert the given object to string with each line indented by 4 spaces * (except the first line).