From a0b53d1530f144bdf9d28ee15c98ebb0c2863a02 Mon Sep 17 00:00:00 2001 From: recursiveribbons Date: Wed, 25 Dec 2019 18:53:58 +0100 Subject: [PATCH] Override equals and hashCode for Callbackgame and LoginUrl --- .../meta/api/objects/LoginUrl.java | 20 +++++++++++++++++++ .../meta/api/objects/games/CallbackGame.java | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java index c422d9c8..c3d85987 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java @@ -5,6 +5,8 @@ import org.telegram.telegrambots.meta.api.interfaces.InputBotApiObject; import org.telegram.telegrambots.meta.api.interfaces.Validable; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; +import java.util.Objects; + import static com.google.common.base.Preconditions.checkNotNull; /** @@ -105,4 +107,22 @@ public class LoginUrl implements InputBotApiObject, Validable { ", requestWriteAccess=" + requestWriteAccess + '}'; } + + @Override + public boolean equals(Object o) { + if (o == this) return true; + if (!(o instanceof LoginUrl)) { + return false; + } + LoginUrl loginUrl = (LoginUrl) o; + return Objects.equals(url, loginUrl.url) && + Objects.equals(forwardText, loginUrl.forwardText) && + Objects.equals(botUsername, loginUrl.botUsername) && + Objects.equals(requestWriteAccess, loginUrl.requestWriteAccess); + } + + @Override + public int hashCode() { + return Objects.hash(url, forwardText, botUsername, requestWriteAccess); + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/CallbackGame.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/CallbackGame.java index 9f4fbe46..6528163b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/CallbackGame.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/CallbackGame.java @@ -34,4 +34,14 @@ public class CallbackGame implements BotApiObject { public String toString() { return "CallbackGame{}"; } + + @Override + public boolean equals(Object o) { + return o == this || o instanceof CallbackGame; + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } }