Merge pull request #708 from recursiveribbons/override-equals

Override equals and hashCode for CallbackGame and LoginUrl
This commit is contained in:
Ruben Bermudez 2019-12-31 03:29:30 +01:00 committed by GitHub
commit b27f273ba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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();
}
}