Add equals and hashCode methods to Microprofile (#20011)

* Add equals and hashCode methods to microprofile

* Add missing import

* Update samples

* Add missing dependency for reflection equals
This commit is contained in:
DielN
2024-11-10 10:43:19 +01:00
committed by GitHub
parent 824f864512
commit 2a17134628
52 changed files with 884 additions and 33 deletions

View File

@@ -150,6 +150,8 @@
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger.core.version>1.5.18</swagger.core.version>
<jetty.version>9.2.9.v20150224</jetty.version>
<junit.version>5.10.2</junit.version>
@@ -172,6 +174,5 @@
<jandex.maven.plugin.version>1.1.0</jandex.maven.plugin.version>
<maven.failsafe.plugin.version>2.6</maven.failsafe.plugin.version>
<build.helper.maven.plugin.version>1.9.1</build.helper.maven.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@@ -12,6 +12,8 @@
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import java.lang.reflect.Type;
import jakarta.json.bind.annotation.JsonbTypeDeserializer;
import jakarta.json.bind.annotation.JsonbTypeSerializer;
@@ -75,6 +77,23 @@ public class Category {
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Category category = (Category) o;
return Objects.equals(this.id, category.id) &&
Objects.equals(this.name, category.name);
}
@Override
public int hashCode() {
return Objects.hash(id, name);
}
/**
* Create a string representation of this pojo.

View File

@@ -12,6 +12,8 @@
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import java.lang.reflect.Type;
import jakarta.json.bind.annotation.JsonbTypeDeserializer;
import jakarta.json.bind.annotation.JsonbTypeSerializer;
@@ -98,6 +100,24 @@ public class ModelApiResponse {
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ModelApiResponse _apiResponse = (ModelApiResponse) o;
return Objects.equals(this.code, _apiResponse.code) &&
Objects.equals(this.type, _apiResponse.type) &&
Objects.equals(this.message, _apiResponse.message);
}
@Override
public int hashCode() {
return Objects.hash(code, type, message);
}
/**
* Create a string representation of this pojo.

View File

@@ -12,6 +12,8 @@
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import java.util.Date;
import java.lang.reflect.Type;
import jakarta.json.bind.annotation.JsonbTypeDeserializer;
@@ -213,6 +215,27 @@ public class Order {
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Order order = (Order) o;
return Objects.equals(this.id, order.id) &&
Objects.equals(this.petId, order.petId) &&
Objects.equals(this.quantity, order.quantity) &&
Objects.equals(this.shipDate, order.shipDate) &&
Objects.equals(this.status, order.status) &&
Objects.equals(this.complete, order.complete);
}
@Override
public int hashCode() {
return Objects.hash(id, petId, quantity, shipDate, status, complete);
}
/**
* Create a string representation of this pojo.

View File

@@ -12,6 +12,8 @@
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -235,6 +237,27 @@ public class Pet {
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Pet pet = (Pet) o;
return Objects.equals(this.id, pet.id) &&
Objects.equals(this.category, pet.category) &&
Objects.equals(this.name, pet.name) &&
Objects.equals(this.photoUrls, pet.photoUrls) &&
Objects.equals(this.tags, pet.tags) &&
Objects.equals(this.status, pet.status);
}
@Override
public int hashCode() {
return Objects.hash(id, category, name, photoUrls, tags, status);
}
/**
* Create a string representation of this pojo.

View File

@@ -12,6 +12,8 @@
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import java.lang.reflect.Type;
import jakarta.json.bind.annotation.JsonbTypeDeserializer;
import jakarta.json.bind.annotation.JsonbTypeSerializer;
@@ -75,6 +77,23 @@ public class Tag {
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Tag tag = (Tag) o;
return Objects.equals(this.id, tag.id) &&
Objects.equals(this.name, tag.name);
}
@Override
public int hashCode() {
return Objects.hash(id, name);
}
/**
* Create a string representation of this pojo.

View File

@@ -12,6 +12,8 @@
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import java.lang.reflect.Type;
import jakarta.json.bind.annotation.JsonbTypeDeserializer;
import jakarta.json.bind.annotation.JsonbTypeSerializer;
@@ -216,6 +218,29 @@ public class User {
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
User user = (User) o;
return Objects.equals(this.id, user.id) &&
Objects.equals(this.username, user.username) &&
Objects.equals(this.firstName, user.firstName) &&
Objects.equals(this.lastName, user.lastName) &&
Objects.equals(this.email, user.email) &&
Objects.equals(this.password, user.password) &&
Objects.equals(this.phone, user.phone) &&
Objects.equals(this.userStatus, user.userStatus);
}
@Override
public int hashCode() {
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
}
/**
* Create a string representation of this pojo.