From 9a436910ff4d179f849e29391dc0d46a9212746c Mon Sep 17 00:00:00 2001 From: Abbas Abou Daya Date: Thu, 10 May 2018 01:27:57 +0300 Subject: [PATCH] Add detailed constructor, equals and hashCode to User object --- .../telegrambots/api/objects/User.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/User.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/User.java index 88a0f0a9..828a2cf3 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/User.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/User.java @@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.telegram.telegrambots.api.interfaces.BotApiObject; +import java.util.Objects; + /** * @author Ruben Bermudez * @version 3.0 @@ -35,6 +37,15 @@ public class User implements BotApiObject { super(); } + public User(Integer id, String firstName, Boolean isBot, String lastName, String userName, String languageCode) { + this.id = id; + this.firstName = firstName; + this.isBot = isBot; + this.lastName = lastName; + this.userName = userName; + this.languageCode = languageCode; + } + public Integer getId() { return id; } @@ -59,6 +70,24 @@ public class User implements BotApiObject { return isBot; } + @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(id, user.id) && + Objects.equals(firstName, user.firstName) && + Objects.equals(isBot, user.isBot) && + Objects.equals(lastName, user.lastName) && + Objects.equals(userName, user.userName) && + Objects.equals(languageCode, user.languageCode); + } + + @Override + public int hashCode() { + return Objects.hash(id, firstName, isBot, lastName, userName, languageCode); + } + @Override public String toString() { return "User{" +