From a25f689e80fd25fd050a961474e531265cbc141c Mon Sep 17 00:00:00 2001 From: Daniel Rainer <daniel.m.rainer@student.uibk.ac.at> Date: Sat, 6 Mar 2021 17:16:07 +0100 Subject: [PATCH] Refactor SearchResultDTO.equals --- .../service/dto/SearchResultsDTO.java | 145 ++++-------------- 1 file changed, 34 insertions(+), 111 deletions(-) diff --git a/src/main/java/at/ac/uibk/gitsearch/service/dto/SearchResultsDTO.java b/src/main/java/at/ac/uibk/gitsearch/service/dto/SearchResultsDTO.java index 1a6e18d28..f67de0a5a 100644 --- a/src/main/java/at/ac/uibk/gitsearch/service/dto/SearchResultsDTO.java +++ b/src/main/java/at/ac/uibk/gitsearch/service/dto/SearchResultsDTO.java @@ -480,118 +480,41 @@ public class SearchResultsDTO { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; + if (this == obj) { + return true; + } + if (!(obj instanceof SearchResultDTO)) { + return false; + } SearchResultDTO other = (SearchResultDTO) obj; - if (audience == null) { - if (other.audience != null) - return false; - } else if (!audience.equals(other.audience)) - return false; - if (!Arrays.equals(collectionContent, other.collectionContent)) - return false; - if (!Arrays.equals(contributor, other.contributor)) - return false; - if (!Arrays.equals(creator, other.creator)) - return false; - if (deprecated != other.deprecated) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (difficulty == null) { - if (other.difficulty != null) - return false; - } else if (!difficulty.equals(other.difficulty)) - return false; - if (educationLevel == null) { - if (other.educationLevel != null) - return false; - } else if (!educationLevel.equals(other.educationLevel)) - return false; - if (!Arrays.equals(format, other.format)) - return false; - if (gitURL == null) { - if (other.gitURL != null) - return false; - } else if (!gitURL.equals(other.gitURL)) - return false; - if (identifier == null) { - if (other.identifier != null) - return false; - } else if (!identifier.equals(other.identifier)) - return false; - if (image == null) { - if (other.image != null) - return false; - } else if (!image.equals(other.image)) - return false; - if (!Arrays.equals(keyword, other.keyword)) - return false; - if (!Arrays.equals(language, other.language)) - return false; - if (license == null) { - if (other.license != null) - return false; - } else if (!license.equals(other.license)) - return false; - if (metadataVersion == null) { - if (other.metadataVersion != null) - return false; - } else if (!metadataVersion.equals(other.metadataVersion)) - return false; - if (!Arrays.equals(programmingLanguage, other.programmingLanguage)) - return false; - if (project == null) { - if (other.project != null) - return false; - } else if (!project.equals(other.project)) - return false; - if (!Arrays.equals(publisher, other.publisher)) - return false; - if (repositoryURL == null) { - if (other.repositoryURL != null) - return false; - } else if (!repositoryURL.equals(other.repositoryURL)) - return false; - if (!Arrays.equals(requires, other.requires)) - return false; - if (!Arrays.equals(source, other.source)) - return false; - if (status == null) { - if (other.status != null) - return false; - } else if (!status.equals(other.status)) - return false; - if (structure == null) { - if (other.structure != null) - return false; - } else if (!structure.equals(other.structure)) - return false; - if (timeRequired == null) { - if (other.timeRequired != null) - return false; - } else if (!timeRequired.equals(other.timeRequired)) - return false; - if (title == null) { - if (other.title != null) - return false; - } else if (!title.equals(other.title)) - return false; - if (type != other.type) - return false; - if (version == null) { - if (other.version != null) - return false; - } else if (!version.equals(other.version)) - return false; - return true; + return Objects.equals(this.audience, other.audience) + && Arrays.equals(this.collectionContent, other.collectionContent) + && Arrays.equals(this.contributor, other.contributor) + && Arrays.equals(this.creator, other.creator) + && this.deprecated == other.deprecated + && Objects.equals(this.description, other.description) + && Objects.equals(this.difficulty, other.difficulty) + && Objects.equals(this.educationLevel, other.educationLevel) + && Arrays.equals(this.format, other.format) + && Objects.equals(this.gitURL, other.gitURL) + && Objects.equals(this.identifier, other.identifier) + && Objects.equals(this.image, other.image) + && Arrays.equals(this.keyword, other.keyword) + && Arrays.equals(this.language, other.language) + && Objects.equals(this.license, other.license) + && Objects.equals(this.metadataVersion, other.metadataVersion) + && Arrays.equals(this.programmingLanguage, other.programmingLanguage) + && Objects.equals(this.project, other.project) + && Arrays.equals(this.publisher, other.publisher) + && Objects.equals(this.repositoryURL, other.repositoryURL) + && Arrays.equals(this.requires, other.requires) + && Arrays.equals(this.source, other.source) + && Objects.equals(this.status, other.status) + && Objects.equals(this.structure, other.structure) + && Objects.equals(this.timeRequired, other.timeRequired) + && Objects.equals(this.title, other.title) + && this.type == other.type + && Objects.equals(this.version, other.version); } } -- GitLab