diff options
| author | Szymon Szukalski <szymon@skas.io> | 2024-07-25 20:58:10 +1000 |
|---|---|---|
| committer | Szymon Szukalski <szymon@skas.io> | 2024-07-25 20:58:10 +1000 |
| commit | fefb88dfb1ef51d319f0677d4312462460909841 (patch) | |
| tree | 645993a16cd23949218bc863ffa7c7f3068283e6 | |
| parent | a46fd9c5637467fe24f94cb91fd9be412f101088 (diff) | |
Implement equals, hashCode and toString for DTO classes
| -rw-r--r-- | src/main/java/com/stileeducation/markr/dto/ImportResponseDTO.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/com/stileeducation/markr/dto/ImportResponseDTO.java b/src/main/java/com/stileeducation/markr/dto/ImportResponseDTO.java index 8613865..11eeae5 100644 --- a/src/main/java/com/stileeducation/markr/dto/ImportResponseDTO.java +++ b/src/main/java/com/stileeducation/markr/dto/ImportResponseDTO.java @@ -1,5 +1,7 @@ package com.stileeducation.markr.dto; +import java.util.Objects; + public class ImportResponseDTO { private String status; @@ -30,6 +32,30 @@ public class ImportResponseDTO { this.data = data; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ImportResponseDTO that = (ImportResponseDTO) o; + return Objects.equals(status, that.status) && + Objects.equals(message, that.message) && + Objects.equals(data, that.data); + } + + @Override + public int hashCode() { + return Objects.hash(status, message, data); + } + + @Override + public String toString() { + return "ImportResponseDTO{" + + "status='" + status + '\'' + + ", message='" + message + '\'' + + ", data=" + data + + '}'; + } + public static class ImportData { private int studentsCreated = 0; private int studentsUpdated = 0; @@ -111,5 +137,35 @@ public class ImportResponseDTO { public void incrementTestResultsUpdated() { this.testResultsUpdated++; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ImportData that = (ImportData) o; + return studentsCreated == that.studentsCreated && + studentsUpdated == that.studentsUpdated && + testsCreated == that.testsCreated && + testsUpdated == that.testsUpdated && + testResultsCreated == that.testResultsCreated && + testResultsUpdated == that.testResultsUpdated; + } + + @Override + public int hashCode() { + return Objects.hash(studentsCreated, studentsUpdated, testsCreated, testsUpdated, testResultsCreated, testResultsUpdated); + } + + @Override + public String toString() { + return "ImportData{" + + "studentsCreated=" + studentsCreated + + ", studentsUpdated=" + studentsUpdated + + ", testsCreated=" + testsCreated + + ", testsUpdated=" + testsUpdated + + ", testResultsCreated=" + testResultsCreated + + ", testResultsUpdated=" + testResultsUpdated + + '}'; + } } } |
