From 897a3403b0d418416aa71b32c85d150091605b20 Mon Sep 17 00:00:00 2001 From: Alexandru2909 Date: Tue, 21 Jun 2022 10:47:33 +0300 Subject: [PATCH] For #12361 - Implement equals and hashCode methods for SearchRequest --- .../concept/engine/search/SearchRequest.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/components/concept/engine/src/main/java/mozilla/components/concept/engine/search/SearchRequest.kt b/components/concept/engine/src/main/java/mozilla/components/concept/engine/search/SearchRequest.kt index 8af1bf0c1eb..8b29c439e09 100644 --- a/components/concept/engine/src/main/java/mozilla/components/concept/engine/search/SearchRequest.kt +++ b/components/concept/engine/src/main/java/mozilla/components/concept/engine/search/SearchRequest.kt @@ -7,4 +7,19 @@ package mozilla.components.concept.engine.search /** * Value type that represents a request for showing a search to the user. */ -data class SearchRequest(val isPrivate: Boolean, val query: String) +data class SearchRequest(val isPrivate: Boolean, val query: String) { + override fun equals(other: Any?): Boolean { + if (other === this) return true + if (other !is SearchRequest) return false + if (other.isPrivate != this.isPrivate) return false + if (other.query != this.query) return false + return true + } + + override fun hashCode(): Int { + /* auto-generated */ + var result = isPrivate.hashCode() + result = 31 * result + query.hashCode() + return result + } +}