diff --git a/README.md b/README.md index c0b89fa..2d7cf89 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ public class MyFirstEchoBot { context.reply(message.text).exec(); }); - bot.start(); // finally run the bot + bot.run(); // finally run the bot } } ``` @@ -138,7 +138,7 @@ public class MyFirstEchoBot { context.reply(message.text).exec(); }); - bot.start(); + bot.run(); } } ``` @@ -159,7 +159,7 @@ context.sendMessage("*Hello, World*") .parseMode(ParseMode.MARKDOWN) .exec(); ``` -Lastly we start our bot by using `start()` which does not take any parameter and run our bot via **long polling.** +Lastly we start our bot by using `run()` which does not take any parameter and run our bot via **long polling.** **IMPORTANT: All handlers are handled in the order in which they were registered.** @@ -558,7 +558,7 @@ class MyWebhookBot { bot.setWebhook(webhook); // set webhook //... - bot.start(); // start our bot on webhook + bot.run(); // start our bot on webhook } } diff --git a/src/main/java/et/telebof/ApiResponse.java b/src/main/java/et/telebof/ApiResponse.java index 6154440..27a53de 100644 --- a/src/main/java/et/telebof/ApiResponse.java +++ b/src/main/java/et/telebof/ApiResponse.java @@ -1,15 +1,39 @@ package et.telebof; -import et.telebof.types.JsonSerializable; +import java.util.Objects; -import java.util.Map; - -public class ApiResponse extends JsonSerializable { +public class ApiResponse { public boolean ok; public String description; public int error_code; - public Object result; + public T result; public ResponseParameters parameters; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ApiResponse that = (ApiResponse) object; + return ok == that.ok && error_code == that.error_code && + Objects.equals(description, that.description) && + Objects.equals(result, that.result) && + Objects.equals(parameters, that.parameters); + } + + @Override + public int hashCode() { + return Objects.hash(ok, description, error_code, result, parameters); + } + + @Override + public String toString() { + return "ApiResponse{" + + "ok=" + ok + + ", description='" + description + '\'' + + ", error_code=" + error_code + + ", result=" + result + + ", parameters=" + parameters + + '}'; + } } diff --git a/src/main/java/et/telebof/BotClient.java b/src/main/java/et/telebof/BotClient.java index 60d5137..4737f21 100644 --- a/src/main/java/et/telebof/BotClient.java +++ b/src/main/java/et/telebof/BotClient.java @@ -411,9 +411,8 @@ private void processWebhook(){ server.createContext(path, httpExchange -> { if (httpExchange.getRequestMethod().equals("POST")){ String response = getString(httpExchange); - ApiResponse apiResponse = Util.parseApiResponse(response); - List objects = Util.parse(apiResponse.result, List.class); - List updates = Util.parseList(objects, Update.class); + ApiResponse> apiResponse = Util.parseApiResponse(response, Update.class); + List updates = Util.parseUpdates(apiResponse.result); httpExchange.sendResponseHeaders(200, response.length()); OutputStream outputStream = httpExchange.getResponseBody(); outputStream.write("!".getBytes()); @@ -804,7 +803,7 @@ private void sleep(int seconds){ } } - public void start(){ + public void run(){ if (webhook != null){ BotLog.info("Bot started running via webhook"); deleteWebhook(); @@ -812,7 +811,7 @@ public void start(){ processWebhook(); } else { BotLog.info("Bot started running via longPolling"); - deleteWebhook(); + // deleteWebhook(); startPolling(); } } diff --git a/src/main/java/et/telebof/BotContext.java b/src/main/java/et/telebof/BotContext.java index 7425eaf..56880b3 100644 --- a/src/main/java/et/telebof/BotContext.java +++ b/src/main/java/et/telebof/BotContext.java @@ -329,28 +329,28 @@ public SendMediaGroup replyMediaGroup(T[] medias) { .parseMode(parseMode); } - public SendLocation sendLocation(Object chatId, float latitude, float longitude) { + public SendLocation sendLocation(Object chatId, double latitude, double longitude) { return new SendLocation(chatId, latitude, longitude, this.requestSender); } - public SendLocation sendLocation(float latitude, float longitude) { + public SendLocation sendLocation(double latitude, double longitude) { return new SendLocation(getChatId(), latitude, longitude, this.requestSender); } - public SendLocation replyLocation(float latitude, float longitude) { + public SendLocation replyLocation(double latitude, double longitude) { return new SendLocation(getChatId(), latitude, longitude, this.requestSender) .replyParameters(new ReplyParameters(getMessageId()).allowSendingWithoutReply(true)); } - public EditMessageLiveLocation editMessageLiveLocation(Object chatId, float latitude, float longitude, int messageId) { + public EditMessageLiveLocation editMessageLiveLocation(Object chatId, double latitude, double longitude, int messageId) { return new EditMessageLiveLocation(chatId, latitude, longitude, messageId, this.requestSender); } - public EditMessageLiveLocation editMessageLiveLocation(float latitude, float longitude, int messageId) { + public EditMessageLiveLocation editMessageLiveLocation(double latitude, double longitude, int messageId) { return new EditMessageLiveLocation(getChatId(), latitude, longitude, messageId, this.requestSender); } - public EditMessageLiveLocation editMessageLiveLocation(String inlineMessageId, float latitude, float longitude) { + public EditMessageLiveLocation editMessageLiveLocation(String inlineMessageId, double latitude, double longitude) { return new EditMessageLiveLocation(inlineMessageId, latitude, longitude, this.requestSender); } @@ -366,15 +366,15 @@ public StopMessageLiveLocation stopMessageLiveLocation(String inlineMessageId) { return new StopMessageLiveLocation(inlineMessageId, this.requestSender); } - public SendVenue sendVenue(Object chatId, float latitude, float longitude, String title, String address) { + public SendVenue sendVenue(Object chatId, double latitude, double longitude, String title, String address) { return new SendVenue(chatId, latitude, longitude, title, address, this.requestSender); } - public SendVenue sendVenue(float latitude, float longitude, String title, String address) { + public SendVenue sendVenue(double latitude, double longitude, String title, String address) { return new SendVenue(getChatId(), latitude, longitude, title, address, this.requestSender); } - public SendVenue replyVenue(float latitude, float longitude, String title, String address) { + public SendVenue replyVenue(double latitude, double longitude, String title, String address) { return new SendVenue(getChatId(), latitude, longitude, title, address, this.requestSender) .replyParameters(new ReplyParameters(getMessageId()).allowSendingWithoutReply(true)); } @@ -961,31 +961,28 @@ public AnswerWebAppQuery answerWebAppQuery(String webAppQueryId, InlineQueryResu public SendInvoice sendInvoice(Object chatId, String title, String description, String payload, String providerToken, String currency, LabeledPrice[] prices) { - return new SendInvoice(chatId, title, description, payload, providerToken, currency, prices, this.requestSender) + return new SendInvoice(chatId, title, description, payload, currency, prices, this.requestSender) .parseMode(parseMode); } - public SendInvoice sendInvoice(String title, String description, String payload, String providerToken, + public SendInvoice sendInvoice(String title, String description, String payload, String currency, LabeledPrice[] prices) { - return new SendInvoice(getChatId(), title, description, payload, providerToken, currency, prices, this.requestSender) + return new SendInvoice(getChatId(), title, description, payload, currency, prices, this.requestSender) .parseMode(parseMode); } - public SendInvoice replyInvoice(String title, String description, String payload, String providerToken, - String currency, LabeledPrice[] prices) { - return new SendInvoice(getChatId(), title, description, payload, providerToken, currency, prices, this.requestSender) + public SendInvoice replyInvoice(String title, String description, String payload, String currency, LabeledPrice[] prices) { + return new SendInvoice(getChatId(), title, description, payload, currency, prices, this.requestSender) .replyParameters(new ReplyParameters(getMessageId()).allowSendingWithoutReply(true)) .parseMode(parseMode); } - public CreateInvoiceLink createInvoiceLink(Object chatId, String title, String description, String payload, String providerToken, - String currency, LabeledPrice[] prices) { - return new CreateInvoiceLink(chatId, title, description, payload, providerToken, currency, prices, this.requestSender); + public CreateInvoiceLink createInvoiceLink(Object chatId, String title, String description, String payload, String currency, LabeledPrice[] prices) { + return new CreateInvoiceLink(chatId, title, description, payload, currency, prices, this.requestSender); } - public CreateInvoiceLink createInvoiceLink(String title, String description, String payload, String providerToken, - String currency, LabeledPrice[] prices) { - return new CreateInvoiceLink(getChatId(), title, description, payload, providerToken, currency, prices, this.requestSender); + public CreateInvoiceLink createInvoiceLink(String title, String description, String payload, String currency, LabeledPrice[] prices) { + return new CreateInvoiceLink(getChatId(), title, description, payload, currency, prices, this.requestSender); } public AnswerShippingQuery answerShippingQuery(String shippingQueryId, boolean ok) { diff --git a/src/main/java/et/telebof/Util.java b/src/main/java/et/telebof/Util.java index 9ba463a..6168136 100644 --- a/src/main/java/et/telebof/Util.java +++ b/src/main/java/et/telebof/Util.java @@ -1,22 +1,27 @@ package et.telebof; +import com.google.common.reflect.TypeToken; import com.google.gson.Gson; +import et.telebof.types.BotCommand; +import et.telebof.types.ChatMember; +import et.telebof.types.GameHighScore; +import et.telebof.types.Message; +import et.telebof.types.Sticker; +import et.telebof.types.Update; -import java.util.ArrayList; -import java.util.Arrays; +import java.lang.reflect.Type; import java.util.List; -import java.util.stream.Collectors; abstract public class Util { static Gson gson = new Gson(); - public static boolean isCommand(String text){ - if (text == null ) return false; + public static boolean isCommand(String text) { + if (text == null) return false; return text.startsWith("/"); } - public static String extractCommand(String text){ + public static String extractCommand(String text) { if (isCommand(text)) { try { String command; @@ -39,13 +44,13 @@ public static String extractText(String text) { String[] smart = text.split(" "); int len = smart.length; if (len == 1) return null; - List smarts = Arrays.stream(smart).collect(Collectors.toList()); + List smarts = List.of(smart); return String.join(" ", smarts.subList(1, len)); } return null; } - public static String escapeHtml(String text){ + public static String escapeHtml(String text) { if (text == null) return null; else return text @@ -54,26 +59,57 @@ public static String escapeHtml(String text){ .replace("<", "<"); } - - public static ApiResponse parseApiResponse(String o){ - return gson.fromJson(o, ApiResponse.class); + + + public static ApiResponse parseApiResponse(String json, Type type) { + Type responseType = com.google.gson.reflect.TypeToken.getParameterized(ApiResponse.class, type).getType(); + return gson.fromJson(json, responseType); } public static T parse(Object jsonString, Class res) { - try{ - return gson.fromJson((String) jsonString, res); - } catch (Exception e){ - return gson.fromJson(gson.toJson(jsonString), res); - } + return gson.fromJson(gson.toJson(jsonString), res); } - public static List parseList(List objectList, Class res) { - List tList = new ArrayList<>(); - objectList.forEach(r->{ - tList.add(Util.parse(gson.toJson(r), res)); - }); + public static List parseList(Object object, Class tClass){ + Type $type = com.google.gson.reflect.TypeToken.getParameterized(List.class, tClass).getType(); + String string = gson.toJson(object); + return gson.fromJson(string, $type); - return tList; } - + public static List parseUpdates(Object json) { + Type type = new TypeToken>() {}.getType(); + return gson.fromJson(gson.toJson(json), type); + } + + public static List parseSticker(Object json) { + Type type = new TypeToken>() {}.getType(); + return gson.fromJson(gson.toJson(json), type); + } + + public static List parseChatMember(Object json) { + Type type = new TypeToken>() {}.getType(); + return gson.fromJson(gson.toJson(json), type); + } + + public static List parseGameHighScore(Object json) { + Type type = new TypeToken>() {}.getType(); + return gson.fromJson(gson.toJson(json), type); + } + + public static List parseMessages(Object json) { + Type type = new TypeToken>() {}.getType(); + return gson.fromJson(gson.toJson(json), type); + } + + public static List parseGetMyCommands(Object json) { + Type type = new TypeToken>() {}.getType(); + return gson.fromJson(gson.toJson(json), type); + } + + + } + + + + diff --git a/src/main/java/et/telebof/enums/MenuButtonType.java b/src/main/java/et/telebof/enums/MenuButtonType.java new file mode 100644 index 0000000..25c68db --- /dev/null +++ b/src/main/java/et/telebof/enums/MenuButtonType.java @@ -0,0 +1,7 @@ +package et.telebof.enums; + +public enum MenuButtonType { + COMMANDS, + DEFAULT, + WEB_APP; +} diff --git a/src/main/java/et/telebof/enums/MimeType.java b/src/main/java/et/telebof/enums/MimeType.java new file mode 100644 index 0000000..e3bd734 --- /dev/null +++ b/src/main/java/et/telebof/enums/MimeType.java @@ -0,0 +1,6 @@ +package et.telebof.enums; + +public enum MimeType { + PDF, + ZIP +} diff --git a/src/main/java/et/telebof/filters/Filter.java b/src/main/java/et/telebof/filters/Filter.java index 9f9f38f..1a2c463 100644 --- a/src/main/java/et/telebof/filters/Filter.java +++ b/src/main/java/et/telebof/filters/Filter.java @@ -5,7 +5,10 @@ import et.telebof.states.StateMemoryStorage; import et.telebof.types.Message; import et.telebof.types.User; + +import java.util.Arrays; import java.util.List; +import java.util.regex.Pattern; public class Filter{ private final Update update; @@ -20,7 +23,7 @@ public Boolean text(){ return update.message !=null && update.message.text != null; } - public Boolean privateChat(){ + public Boolean Private(){ return chatType("private"); } @@ -314,4 +317,17 @@ else if (update.callback_query != null){ else return false; } + public boolean texts(String... texts){ + if (text()){ + return List.of(texts).contains(update.message.text); + } else return false; + } + + public boolean regex(String pattern){ + if (!text()) return false; + + Pattern instance = Pattern.compile(pattern); + return instance.matcher(update.message.text).find(); + } + } diff --git a/src/main/java/et/telebof/requests/AbstractBaseRequest.java b/src/main/java/et/telebof/requests/AbstractBaseRequest.java index c367b56..e7d8ad2 100644 --- a/src/main/java/et/telebof/requests/AbstractBaseRequest.java +++ b/src/main/java/et/telebof/requests/AbstractBaseRequest.java @@ -1,6 +1,8 @@ package et.telebof.requests; +import com.google.gson.reflect.TypeToken; import java.io.File; +import java.lang.reflect.Type; import java.util.Map; import java.util.TreeMap; @@ -10,19 +12,38 @@ abstract public class AbstractBaseRequest{ private String contentType = MediaContentType.DEFAULT; private boolean hasMultipart; T type = (T) this; - Class rClass; protected String methodName ; protected RequestSender requestSender; + private final Type responseType; + + public AbstractBaseRequest(Object chat_id, RequestSender requestSender, String methodName, Type responseType) { + add("chat_id", chat_id); + this.requestSender = requestSender; + this.methodName = methodName; + this.responseType = responseType; + } + + public AbstractBaseRequest(RequestSender requestSender, String methodName, Type responseType) { + this.methodName = methodName; + this.requestSender = requestSender; + this.responseType = responseType; + } public AbstractBaseRequest(Object chat_id, RequestSender requestSender, String methodName) { add("chat_id", chat_id); this.requestSender = requestSender; this.methodName = methodName; + this.responseType = Boolean.class; } public AbstractBaseRequest(RequestSender requestSender, String methodName) { this.methodName = methodName; this.requestSender = requestSender; + this.responseType = Boolean.class; + } + + protected Type getResponseType(){ + return responseType; } final protected T add(String key, Object values) { @@ -56,6 +77,8 @@ protected String getContentType() { return contentType; } - public abstract R exec(); + public R exec(){ + return requestSender.makeRequest(this); + } } diff --git a/src/main/java/et/telebof/requests/AddStickerToSet.java b/src/main/java/et/telebof/requests/AddStickerToSet.java index 18a7df9..6317118 100644 --- a/src/main/java/et/telebof/requests/AddStickerToSet.java +++ b/src/main/java/et/telebof/requests/AddStickerToSet.java @@ -10,10 +10,4 @@ public AddStickerToSet(long userId, String name, File sticker, RequestSender req add("sticker", sticker); this.setContentType(MediaContentType.PHOTO); } - - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/AnswerCallbackQuery.java b/src/main/java/et/telebof/requests/AnswerCallbackQuery.java index fb1e59d..ca296b1 100644 --- a/src/main/java/et/telebof/requests/AnswerCallbackQuery.java +++ b/src/main/java/et/telebof/requests/AnswerCallbackQuery.java @@ -23,9 +23,4 @@ public AnswerCallbackQuery cacheTime(int cacheTime){ return add("cache_time", cacheTime); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/AnswerInlineQuery.java b/src/main/java/et/telebof/requests/AnswerInlineQuery.java index 3b0e875..54c6a3b 100644 --- a/src/main/java/et/telebof/requests/AnswerInlineQuery.java +++ b/src/main/java/et/telebof/requests/AnswerInlineQuery.java @@ -29,9 +29,4 @@ public AnswerInlineQuery button(InlineQueryResultsButton button){ return add("button", button); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/AnswerPreCheckoutQuery.java b/src/main/java/et/telebof/requests/AnswerPreCheckoutQuery.java index e5dc0b7..dbbc6f8 100644 --- a/src/main/java/et/telebof/requests/AnswerPreCheckoutQuery.java +++ b/src/main/java/et/telebof/requests/AnswerPreCheckoutQuery.java @@ -10,10 +10,4 @@ public AnswerPreCheckoutQuery(String preCheckoutQueryId, boolean ok, RequestSend public AnswerPreCheckoutQuery errorMessage(String errorMessage) { return add("error_message", errorMessage); } - - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/AnswerShippingQuery.java b/src/main/java/et/telebof/requests/AnswerShippingQuery.java index 41862b7..c1353ec 100644 --- a/src/main/java/et/telebof/requests/AnswerShippingQuery.java +++ b/src/main/java/et/telebof/requests/AnswerShippingQuery.java @@ -21,9 +21,4 @@ public AnswerShippingQuery errorMessage(String errorMessage) { return add("error_message", errorMessage); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/AnswerWebAppQuery.java b/src/main/java/et/telebof/requests/AnswerWebAppQuery.java index 5c3add7..1dda8f2 100644 --- a/src/main/java/et/telebof/requests/AnswerWebAppQuery.java +++ b/src/main/java/et/telebof/requests/AnswerWebAppQuery.java @@ -6,13 +6,9 @@ public class AnswerWebAppQuery extends AbstractBaseRequest { public AnswerWebAppQuery(String webAppQueryId, InlineQueryResult result, RequestSender requestSender) { - super(requestSender, "answerWebAppQuery"); + super(requestSender, "answerWebAppQuery", SentWebAppMessage.class); add("web_app_query_id", webAppQueryId); add("result", result); } - @Override - public SentWebAppMessage exec() { - return Util.parse(requestSender.makeRequest(this), SentWebAppMessage.class); - } } diff --git a/src/main/java/et/telebof/requests/ApproveChatJoinRequest.java b/src/main/java/et/telebof/requests/ApproveChatJoinRequest.java index d37e230..6414d1a 100644 --- a/src/main/java/et/telebof/requests/ApproveChatJoinRequest.java +++ b/src/main/java/et/telebof/requests/ApproveChatJoinRequest.java @@ -6,10 +6,5 @@ public ApproveChatJoinRequest(Object chatId, long userId, RequestSender requestS add("user_id", userId); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/BanChatMember.java b/src/main/java/et/telebof/requests/BanChatMember.java index 2e0bbf8..047b41a 100644 --- a/src/main/java/et/telebof/requests/BanChatMember.java +++ b/src/main/java/et/telebof/requests/BanChatMember.java @@ -14,9 +14,4 @@ public BanChatMember revokeMessages(boolean revokeMessages){ return add("revoke_messages", revokeMessages); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/BanChatSenderChat.java b/src/main/java/et/telebof/requests/BanChatSenderChat.java index 96db39b..f20d77f 100644 --- a/src/main/java/et/telebof/requests/BanChatSenderChat.java +++ b/src/main/java/et/telebof/requests/BanChatSenderChat.java @@ -6,10 +6,4 @@ public BanChatSenderChat(Object chatId, long senderChatId, RequestSender request add("sender_chat_id", senderChatId); } - - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/Close.java b/src/main/java/et/telebof/requests/Close.java index 85ae005..59b1e06 100644 --- a/src/main/java/et/telebof/requests/Close.java +++ b/src/main/java/et/telebof/requests/Close.java @@ -5,9 +5,4 @@ public Close(RequestSender requestSender){ super(requestSender, "close"); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/CloseForumTopic.java b/src/main/java/et/telebof/requests/CloseForumTopic.java index 3364dd2..fbbf94b 100644 --- a/src/main/java/et/telebof/requests/CloseForumTopic.java +++ b/src/main/java/et/telebof/requests/CloseForumTopic.java @@ -5,10 +5,4 @@ public CloseForumTopic(Object chatId, int messageThreadId, RequestSender request super(chatId, requestSender, "closeForumTopic"); add("message_thread_id", messageThreadId); } - - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/CloseGeneralForumTopic.java b/src/main/java/et/telebof/requests/CloseGeneralForumTopic.java index dbde399..a23e3e5 100644 --- a/src/main/java/et/telebof/requests/CloseGeneralForumTopic.java +++ b/src/main/java/et/telebof/requests/CloseGeneralForumTopic.java @@ -5,9 +5,4 @@ public CloseGeneralForumTopic(Object chatId, RequestSender requestSender) { super(chatId, requestSender, "closeGeneralForumTopic"); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/CopyMessage.java b/src/main/java/et/telebof/requests/CopyMessage.java index b8c0b83..cac9129 100644 --- a/src/main/java/et/telebof/requests/CopyMessage.java +++ b/src/main/java/et/telebof/requests/CopyMessage.java @@ -1,19 +1,65 @@ package et.telebof.requests; import et.telebof.Util; +import et.telebof.enums.ParseMode; +import et.telebof.types.Markup; import et.telebof.types.MessageEntity; import et.telebof.types.MessageId; +import et.telebof.types.ReplyParameters; +import org.jetbrains.annotations.NotNull; import java.util.List; -public class CopyMessage extends DefaultParameters { +public class CopyMessage extends AbstractBaseRequest { public CopyMessage(Object chat, Object fromChatId, int messageId, RequestSender requestSender) { - super(chat, requestSender, "copyMessage"); + super(chat, requestSender, "copyMessage", MessageId.class); add("from_chat_id", fromChatId); add("message_id", messageId); } + public CopyMessage messageThreadId(int messageThreadId) { + return add("message_thread_id", messageThreadId); + } + + public CopyMessage parseMode(@NotNull ParseMode parseMode) { + return add("parse_mode", parseMode.name()); + } + + public CopyMessage disableWebPagePreview(boolean disableWebPagePreview) { + return add("disable_web_page_preview", disableWebPagePreview); + } + + public CopyMessage disableNotification(boolean disableNotification) { + return add("disable_notification", disableNotification); + } + + public CopyMessage protectContent(boolean protectContent) { + return add("protect_content", protectContent); + } + + @Deprecated(since = "v1.5.0") + public CopyMessage replyToMessageId(int replyToMessageId) { + return add("reply_to_message_id", replyToMessageId); + } + + @Deprecated(since = "v1.5.0") + public CopyMessage allowSendingWithoutReply(boolean allowSendingWithoutReply) { + return add("allow_sending_without_reply", allowSendingWithoutReply); + } + + public CopyMessage replyParameters(ReplyParameters replyParameters){ + return add("reply_parameters", replyParameters); + } + + public CopyMessage replyMarkup(Markup replyMarkup) { + return add("reply_markup", replyMarkup); + } + + public CopyMessage businessConnectionId(String business_connection_id){ + return add("business_connection_id", business_connection_id); + } + public CopyMessage caption(String cap) { return add("caption", cap); } @@ -22,8 +68,7 @@ public CopyMessage captionEntities(MessageEntity[] captionEntities) { return add("caption_entities", List.of(captionEntities)); } - @Override - public MessageId exec() { - return Util.parse(requestSender.makeRequest(this), MessageId.class); + public CopyMessage showCaptionAboveMedia(boolean show_caption_above_media){ + return add("show_caption_above_media", show_caption_above_media); } } diff --git a/src/main/java/et/telebof/requests/CopyMessages.java b/src/main/java/et/telebof/requests/CopyMessages.java index 703fc3e..4054095 100644 --- a/src/main/java/et/telebof/requests/CopyMessages.java +++ b/src/main/java/et/telebof/requests/CopyMessages.java @@ -1,15 +1,21 @@ package et.telebof.requests; +import com.google.gson.reflect.TypeToken; import et.telebof.Util; +import et.telebof.types.ChatMember; +import et.telebof.types.Message; import et.telebof.types.MessageEntity; import et.telebof.types.MessageId; +import java.lang.reflect.Type; import java.util.List; public class CopyMessages extends AbstractBaseRequest> { + private static final Type responseType = TypeToken.getParameterized(List.class, MessageId.class).getType(); + public CopyMessages(Object chatId, Object fromChatId, List messageIds, RequestSender requestSender) { - super(chatId, requestSender, "copyMessages"); + super(chatId, requestSender, "copyMessages", responseType); add("from_chat_id", fromChatId); add("message_id", messageIds); } @@ -22,9 +28,4 @@ public CopyMessages captionEntities(MessageEntity[] captionEntities) { return add("caption_entities", List.of(captionEntities)); } - @Override - public List exec() { - return Util.parse(requestSender.makeRequest(this), List.class); - } - } diff --git a/src/main/java/et/telebof/requests/CreateChatInviteLink.java b/src/main/java/et/telebof/requests/CreateChatInviteLink.java index ccc0e57..050c486 100644 --- a/src/main/java/et/telebof/requests/CreateChatInviteLink.java +++ b/src/main/java/et/telebof/requests/CreateChatInviteLink.java @@ -5,10 +5,10 @@ public class CreateChatInviteLink extends AbstractBaseRequest { public CreateChatInviteLink(Object chatId, RequestSender requestSender) { - super(chatId, requestSender, "createChatInviteLink"); + super(chatId, requestSender, "createChatInviteLink", ChatInviteLink.class); } - public CreateChatInviteLink(Object chatId, RequestSender requestSender, String methodName){ - super(chatId, requestSender, methodName); + CreateChatInviteLink(Object chatId, RequestSender requestSender, String methodName){ + super(chatId, requestSender, methodName, ChatInviteLink.class); } public CreateChatInviteLink name(String name) { @@ -27,8 +27,4 @@ public CreateChatInviteLink createsJoinRequest(boolean createsJoinRequest) { return add("creates_join_request", createsJoinRequest); } - @Override - public ChatInviteLink exec() { - return Util.parse(requestSender.makeRequest(this), ChatInviteLink.class); - } } diff --git a/src/main/java/et/telebof/requests/CreateForumTopic.java b/src/main/java/et/telebof/requests/CreateForumTopic.java index edc3f17..694748a 100644 --- a/src/main/java/et/telebof/requests/CreateForumTopic.java +++ b/src/main/java/et/telebof/requests/CreateForumTopic.java @@ -5,7 +5,7 @@ public class CreateForumTopic extends AbstractBaseRequest { public CreateForumTopic(Object chatId, String name, RequestSender requestSender) { - super(chatId, requestSender, "createForumTopic"); + super(chatId, requestSender, "createForumTopic", ForumTopic.class); add("name", name); } @@ -17,8 +17,4 @@ public CreateForumTopic iconCustomEmojiId(String iconCustomEmojiId) { return add("icon_custom_emoji_id", iconCustomEmojiId); } - @Override - public ForumTopic exec() { - return Util.parse(requestSender.makeRequest(this), ForumTopic.class); - } } diff --git a/src/main/java/et/telebof/requests/CreateInvoiceLink.java b/src/main/java/et/telebof/requests/CreateInvoiceLink.java index a1cdb97..74d3b56 100644 --- a/src/main/java/et/telebof/requests/CreateInvoiceLink.java +++ b/src/main/java/et/telebof/requests/CreateInvoiceLink.java @@ -8,17 +8,19 @@ import java.util.Map; public class CreateInvoiceLink extends AbstractBaseRequest { - public CreateInvoiceLink(Object chatId, String title, String description, String payload, String providerToken, + public CreateInvoiceLink(Object chatId, String title, String description, String payload, String currency, LabeledPrice[] prices, RequestSender requestSender) { - super(chatId, requestSender, "createInvoiceLink"); + super(chatId, requestSender, "createInvoiceLink", Object.class); add("title", title); add("description", description); add("payload", payload); - add("provider_token", providerToken); add("currency", currency); add("prices", List.of(prices)); } + public CreateInvoiceLink providerToken(String providerToken){ + return add("provider_token", providerToken); + } public CreateInvoiceLink maxTipAmount(int maxTipAmount) { return add("max_tip_amount", maxTipAmount); } @@ -75,9 +77,4 @@ public CreateInvoiceLink isFlexible(boolean isFlexible) { return add("is_flexible", isFlexible); } - - @Override - public String exec() { - return (String) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/CreateNewStickerSet.java b/src/main/java/et/telebof/requests/CreateNewStickerSet.java index 274b71c..1d17e7a 100644 --- a/src/main/java/et/telebof/requests/CreateNewStickerSet.java +++ b/src/main/java/et/telebof/requests/CreateNewStickerSet.java @@ -22,9 +22,4 @@ public CreateNewStickerSet needsRepainting(boolean needsRepainting) { return add("needs_repainting", needsRepainting); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/DeclineChatJoinRequest.java b/src/main/java/et/telebof/requests/DeclineChatJoinRequest.java index dfb0cd1..c3a01f7 100644 --- a/src/main/java/et/telebof/requests/DeclineChatJoinRequest.java +++ b/src/main/java/et/telebof/requests/DeclineChatJoinRequest.java @@ -6,9 +6,4 @@ public DeclineChatJoinRequest(Object chatId, long userId, RequestSender requestS add("user_id", userId); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/DefaultParameters.java b/src/main/java/et/telebof/requests/DefaultParameters.java index c772151..1059d6b 100644 --- a/src/main/java/et/telebof/requests/DefaultParameters.java +++ b/src/main/java/et/telebof/requests/DefaultParameters.java @@ -1,7 +1,11 @@ package et.telebof.requests; import et.telebof.enums.ParseMode; import et.telebof.types.Markup; +import et.telebof.types.Message; import et.telebof.types.ReplyParameters; +import org.jetbrains.annotations.NotNull; + +import java.lang.reflect.Type; /** * @author Natanim Negash @@ -9,15 +13,19 @@ abstract public class DefaultParameters extends AbstractBaseRequest { public DefaultParameters(Object chatId, RequestSender requestSender, String methodName) { - super(chatId, requestSender, methodName); + super(chatId, requestSender, methodName, Message.class); + } + + public DefaultParameters(Object chatId, RequestSender requestSender, String methodName, Type type) { + super(chatId, requestSender, methodName, type); } public T messageThreadId(int messageThreadId) { return add("message_thread_id", messageThreadId); } - public T parseMode(ParseMode parseMode) { - return add("parse_mode", parseMode != null ? parseMode.name() : null); + public T parseMode(@NotNull ParseMode parseMode) { + return add("parse_mode", parseMode.name()); } public T disableWebPagePreview(boolean disableWebPagePreview) { @@ -53,4 +61,8 @@ public T replyMarkup(Markup replyMarkup) { public T businessConnectionId(String business_connection_id){ return add("business_connection_id", business_connection_id); } + + public T messageEffectId(String message_effect_id ){ + return add("message_effect_id ", message_effect_id); + } } diff --git a/src/main/java/et/telebof/requests/DeleteChatPhoto.java b/src/main/java/et/telebof/requests/DeleteChatPhoto.java index 68d3376..dbf4b46 100644 --- a/src/main/java/et/telebof/requests/DeleteChatPhoto.java +++ b/src/main/java/et/telebof/requests/DeleteChatPhoto.java @@ -5,9 +5,4 @@ public DeleteChatPhoto(Object chatId, RequestSender requestSender) { super(chatId, requestSender, "deleteChatPhoto"); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/DeleteChatStickerSet.java b/src/main/java/et/telebof/requests/DeleteChatStickerSet.java index 0f77209..d52ce2e 100644 --- a/src/main/java/et/telebof/requests/DeleteChatStickerSet.java +++ b/src/main/java/et/telebof/requests/DeleteChatStickerSet.java @@ -5,9 +5,4 @@ public DeleteChatStickerSet(Object chatId, RequestSender requestSender) { super(chatId, requestSender, "deleteChatStickerSet"); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/DeleteForumTopic.java b/src/main/java/et/telebof/requests/DeleteForumTopic.java index 60c9e7f..33913e8 100644 --- a/src/main/java/et/telebof/requests/DeleteForumTopic.java +++ b/src/main/java/et/telebof/requests/DeleteForumTopic.java @@ -5,10 +5,4 @@ public DeleteForumTopic(Object chatId, int messageThreadId, RequestSender reques super(chatId, requestSender, "deleteForumTopic"); add("message_thread_id", messageThreadId); } - - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/DeleteMessage.java b/src/main/java/et/telebof/requests/DeleteMessage.java index ca27cd3..0c30f6a 100644 --- a/src/main/java/et/telebof/requests/DeleteMessage.java +++ b/src/main/java/et/telebof/requests/DeleteMessage.java @@ -6,9 +6,4 @@ public DeleteMessage(Object chatId, int messageId, RequestSender requestSender) add("message_id", messageId); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/DeleteMessages.java b/src/main/java/et/telebof/requests/DeleteMessages.java index 83f3dae..3fb5d07 100644 --- a/src/main/java/et/telebof/requests/DeleteMessages.java +++ b/src/main/java/et/telebof/requests/DeleteMessages.java @@ -7,9 +7,4 @@ public DeleteMessages(Object chatId, Integer[] messageIds, RequestSender request add("message_id", messageIds); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } \ No newline at end of file diff --git a/src/main/java/et/telebof/requests/DeleteMyCommands.java b/src/main/java/et/telebof/requests/DeleteMyCommands.java index f71c095..88d92e2 100644 --- a/src/main/java/et/telebof/requests/DeleteMyCommands.java +++ b/src/main/java/et/telebof/requests/DeleteMyCommands.java @@ -15,9 +15,4 @@ public DeleteMyCommands languageCode(String languageCode) { return add("language_code", languageCode); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/DeleteStickerFromSet.java b/src/main/java/et/telebof/requests/DeleteStickerFromSet.java index 350c5ca..59ad3db 100644 --- a/src/main/java/et/telebof/requests/DeleteStickerFromSet.java +++ b/src/main/java/et/telebof/requests/DeleteStickerFromSet.java @@ -6,9 +6,4 @@ public DeleteStickerFromSet(String sticker, RequestSender requestSender){ add("sticker", sticker); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/DeleteStickerSet.java b/src/main/java/et/telebof/requests/DeleteStickerSet.java index 94ee1b5..1fa131b 100644 --- a/src/main/java/et/telebof/requests/DeleteStickerSet.java +++ b/src/main/java/et/telebof/requests/DeleteStickerSet.java @@ -6,9 +6,4 @@ public DeleteStickerSet(String name, RequestSender requestSender) { add("name", name); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/DeleteWebhook.java b/src/main/java/et/telebof/requests/DeleteWebhook.java index 2a8fd3f..6b0299a 100644 --- a/src/main/java/et/telebof/requests/DeleteWebhook.java +++ b/src/main/java/et/telebof/requests/DeleteWebhook.java @@ -9,9 +9,4 @@ public DeleteWebhook dropPendingUpdates(boolean dropPendingUpdates){ return add("drop_pending_updates", dropPendingUpdates); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/EditForumTopic.java b/src/main/java/et/telebof/requests/EditForumTopic.java index a660fa9..ede78ae 100644 --- a/src/main/java/et/telebof/requests/EditForumTopic.java +++ b/src/main/java/et/telebof/requests/EditForumTopic.java @@ -14,9 +14,4 @@ public EditForumTopic iconCustomEmojiId(String iconCustomEmojiId) { return add("icon_custom_emoji_id", iconCustomEmojiId); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/EditGeneralForumTopic.java b/src/main/java/et/telebof/requests/EditGeneralForumTopic.java index 00d91fc..7a5bc0a 100644 --- a/src/main/java/et/telebof/requests/EditGeneralForumTopic.java +++ b/src/main/java/et/telebof/requests/EditGeneralForumTopic.java @@ -6,9 +6,4 @@ public EditGeneralForumTopic(Object chatId, String name, RequestSender requestSe add("name", name); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/EditMessageCaption.java b/src/main/java/et/telebof/requests/EditMessageCaption.java index f69c2de..41f4a37 100644 --- a/src/main/java/et/telebof/requests/EditMessageCaption.java +++ b/src/main/java/et/telebof/requests/EditMessageCaption.java @@ -5,34 +5,23 @@ import et.telebof.types.InlineKeyboardMarkup; import et.telebof.types.Message; import et.telebof.types.MessageEntity; +import org.jetbrains.annotations.NotNull; import java.util.List; public class EditMessageCaption extends AbstractBaseRequest { public EditMessageCaption(Object chatId, int messageId, RequestSender requestSender) { - super(chatId, requestSender, "editMessageCaption"); + super(chatId, requestSender, "editMessageCaption", Message.class); add("message_id", messageId); } public EditMessageCaption(String inlineMessageId, RequestSender requestSender) { - super(requestSender, "editMessageCaption"); + super(requestSender, "editMessageCaption", Message.class); add("inline_message_id", inlineMessageId); } - public EditMessageCaption chatId(Object chatId) { - return add("chat_id", chatId); - } - - public EditMessageCaption messageId(int messageId){ - return add("message_id", messageId); - } - - public EditMessageCaption inlineMessageId(String inlineMessageId) { - return add("inline_message_id", inlineMessageId); - } - - public EditMessageCaption parseMode(ParseMode parseMode) { - return add("parse_mode", parseMode!=null?parseMode.name():null); + public EditMessageCaption parseMode(@NotNull ParseMode parseMode) { + return add("parse_mode", parseMode); } public EditMessageCaption entities(MessageEntity[] captionEntities) { @@ -43,8 +32,7 @@ public EditMessageCaption replyMarkup(InlineKeyboardMarkup replyMarkup) { return add("reply_markup", replyMarkup); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); + public EditMessageCaption showCaptionAboveMedia(boolean show_caption_above_media){ + return add("show_caption_above_media", show_caption_above_media); } } diff --git a/src/main/java/et/telebof/requests/EditMessageLiveLocation.java b/src/main/java/et/telebof/requests/EditMessageLiveLocation.java index c55795f..2c36252 100644 --- a/src/main/java/et/telebof/requests/EditMessageLiveLocation.java +++ b/src/main/java/et/telebof/requests/EditMessageLiveLocation.java @@ -5,26 +5,22 @@ import et.telebof.types.Message; public class EditMessageLiveLocation extends AbstractBaseRequest { - public EditMessageLiveLocation(Object chatId, float latitude, float longitude, int messageId, RequestSender requestSender) { - super(chatId, requestSender, "editMessageLiveLocation"); + public EditMessageLiveLocation(Object chatId, double latitude, double longitude, int messageId, RequestSender requestSender) { + super(chatId, requestSender, "editMessageLiveLocation", Message.class); add("latitude", latitude); add("longitude", longitude); add("message_id", messageId); } - public EditMessageLiveLocation(String inlineMessageId, float latitude, float longitude, RequestSender requestSender) { - super(requestSender, "editMessageLiveLocation"); + public EditMessageLiveLocation(String inlineMessageId, double latitude, double longitude, RequestSender requestSender) { + super(requestSender, "editMessageLiveLocation", Message.class); add("latitude", latitude); add("longitude", longitude); add("inline_message_id", inlineMessageId); } - public EditMessageLiveLocation inlineMessageId(String inlineMessageId){ - return add("inline_message_id", inlineMessageId); - } - - public EditMessageLiveLocation horizontalAccuracy(float horizontalAccuracy){ + public EditMessageLiveLocation horizontalAccuracy(double horizontalAccuracy){ return add("horizontal_accuracy", horizontalAccuracy); } @@ -44,8 +40,4 @@ public EditMessageLiveLocation livePeriod(int live_period){ return add("live_period", live_period); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } } diff --git a/src/main/java/et/telebof/requests/EditMessageMedia.java b/src/main/java/et/telebof/requests/EditMessageMedia.java index 6a272ef..3aa931c 100644 --- a/src/main/java/et/telebof/requests/EditMessageMedia.java +++ b/src/main/java/et/telebof/requests/EditMessageMedia.java @@ -8,13 +8,13 @@ public class EditMessageMedia extends AbstractBaseRequest { public EditMessageMedia(File media, Object chatId, int messageId, RequestSender requestSender) { - super(chatId, requestSender, "editMessageMedia"); + super(chatId, requestSender, "editMessageMedia", Message.class); add("media", media); add("message_id", messageId); } public EditMessageMedia(File media, String inlineMessageId, RequestSender requestSender) { - super(requestSender, "editMessageMedia"); + super(requestSender, "editMessageMedia", Message.class); add("media", media); add("inline_message_id", inlineMessageId); } @@ -23,8 +23,4 @@ public EditMessageMedia replyMarkup(InlineKeyboardMarkup replyMarkup) { return add("reply_markup", replyMarkup); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } } diff --git a/src/main/java/et/telebof/requests/EditMessageReplyMarkup.java b/src/main/java/et/telebof/requests/EditMessageReplyMarkup.java index de79c73..ada6e45 100644 --- a/src/main/java/et/telebof/requests/EditMessageReplyMarkup.java +++ b/src/main/java/et/telebof/requests/EditMessageReplyMarkup.java @@ -6,12 +6,12 @@ public class EditMessageReplyMarkup extends AbstractBaseRequest { public EditMessageReplyMarkup(Object chatId, int messageId, RequestSender requestSender) { - super(chatId, requestSender, "editMessageReplyMarkup"); + super(chatId, requestSender, "editMessageReplyMarkup", Message.class); add("message_id", messageId); } public EditMessageReplyMarkup(String inlineMessageId, RequestSender requestSender) { - super(requestSender, "editMessageReplyMarkup"); + super(requestSender, "editMessageReplyMarkup", Message.class); add("inline_message_id", inlineMessageId); } @@ -19,8 +19,4 @@ public EditMessageReplyMarkup replyMarkup(InlineKeyboardMarkup replyMarkup) { return add("reply_markup", replyMarkup); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } } diff --git a/src/main/java/et/telebof/requests/EditMessageText.java b/src/main/java/et/telebof/requests/EditMessageText.java index fa24b29..4077b7e 100644 --- a/src/main/java/et/telebof/requests/EditMessageText.java +++ b/src/main/java/et/telebof/requests/EditMessageText.java @@ -11,13 +11,13 @@ public class EditMessageText extends AbstractBaseRequest { public EditMessageText(String text, Object chatId, int messageId, RequestSender requestSender) { - super(chatId, requestSender, "editMessageText"); + super(chatId, requestSender, "editMessageText", Message.class); add("text", text); add("message_id", messageId); } public EditMessageText(String text, String inlineMessageId, RequestSender requestSender) { - super(requestSender, "editMessageText"); + super(requestSender, "editMessageText", Message.class); add("text", text); add("inline_message_id", inlineMessageId); } @@ -44,8 +44,4 @@ public EditMessageText replyMarkup(InlineKeyboardMarkup replyMarkup) { return add("reply_markup", replyMarkup); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } } diff --git a/src/main/java/et/telebof/requests/ExportChatInviteLink.java b/src/main/java/et/telebof/requests/ExportChatInviteLink.java index 93992a2..54eaf7a 100644 --- a/src/main/java/et/telebof/requests/ExportChatInviteLink.java +++ b/src/main/java/et/telebof/requests/ExportChatInviteLink.java @@ -2,11 +2,7 @@ public class ExportChatInviteLink extends AbstractBaseRequest { public ExportChatInviteLink(Object chatId, RequestSender requestSender) { - super(chatId, requestSender, "exportChatInviteLink"); + super(chatId, requestSender, "exportChatInviteLink", Object.class); } - @Override - public String exec() { - return (String) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/ForwardMessage.java b/src/main/java/et/telebof/requests/ForwardMessage.java index cac5045..ec00157 100644 --- a/src/main/java/et/telebof/requests/ForwardMessage.java +++ b/src/main/java/et/telebof/requests/ForwardMessage.java @@ -5,7 +5,7 @@ public class ForwardMessage extends AbstractBaseRequest { public ForwardMessage(Object chatId, Object fromChatId, int messageId, RequestSender requestSender) { - super(chatId, requestSender, "forwardMessage"); + super(chatId, requestSender, "forwardMessage", Message.class); add("from_chat_id", fromChatId); add("message_id", messageId); } @@ -22,9 +22,5 @@ public ForwardMessage protectContent(boolean protectContent) { return add("protect_content", protectContent); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } } diff --git a/src/main/java/et/telebof/requests/ForwardMessages.java b/src/main/java/et/telebof/requests/ForwardMessages.java index b95086a..29ae0e9 100644 --- a/src/main/java/et/telebof/requests/ForwardMessages.java +++ b/src/main/java/et/telebof/requests/ForwardMessages.java @@ -1,14 +1,20 @@ package et.telebof.requests; +import com.google.gson.reflect.TypeToken; import et.telebof.Util; +import et.telebof.types.ChatMember; import et.telebof.types.Message; import et.telebof.types.MessageId; +import java.lang.reflect.Type; import java.util.List; public class ForwardMessages extends AbstractBaseRequest> { + + private static final Type responseType = TypeToken.getParameterized(List.class, MessageId.class).getType(); + public ForwardMessages(Object chatId, Object fromChatId, List messageIds, RequestSender requestSender) { - super(chatId, requestSender, "forwardMessages"); + super(chatId, requestSender, "forwardMessages", responseType); add("from_chat_id", fromChatId); add("message_id", messageIds); } @@ -25,10 +31,5 @@ public ForwardMessages protectContent(boolean protectContent) { return add("protect_content", protectContent); } - @Override - public List exec() { - return Util.parse(requestSender.makeRequest(this), List.class); - } - } diff --git a/src/main/java/et/telebof/requests/GetBusinessConnection.java b/src/main/java/et/telebof/requests/GetBusinessConnection.java index e5393bd..b8e8d9d 100644 --- a/src/main/java/et/telebof/requests/GetBusinessConnection.java +++ b/src/main/java/et/telebof/requests/GetBusinessConnection.java @@ -5,11 +5,7 @@ public class GetBusinessConnection extends AbstractBaseRequest { public GetBusinessConnection(String business_connection_id, RequestSender requestSender){ - super(requestSender, "getBusinessConnection"); + super(requestSender, "getBusinessConnection", BusinessConnection.class); } - @Override - public BusinessConnection exec() { - return Util.parse(requestSender.makeRequest(this), BusinessConnection.class); - } } diff --git a/src/main/java/et/telebof/requests/GetChat.java b/src/main/java/et/telebof/requests/GetChat.java index dd4f312..8f7fba6 100644 --- a/src/main/java/et/telebof/requests/GetChat.java +++ b/src/main/java/et/telebof/requests/GetChat.java @@ -5,11 +5,7 @@ public class GetChat extends AbstractBaseRequest { public GetChat(Object chatId, RequestSender requestSender) { - super(chatId, requestSender, "getChat"); + super(chatId, requestSender, "getChat", ChatFullInfo.class); } - @Override - public ChatFullInfo exec() { - return Util.parse(requestSender.makeRequest(this), ChatFullInfo.class); - } } diff --git a/src/main/java/et/telebof/requests/GetChatAdministrators.java b/src/main/java/et/telebof/requests/GetChatAdministrators.java index 52f63a3..773a4df 100644 --- a/src/main/java/et/telebof/requests/GetChatAdministrators.java +++ b/src/main/java/et/telebof/requests/GetChatAdministrators.java @@ -1,18 +1,18 @@ package et.telebof.requests; +import com.google.gson.reflect.TypeToken; import et.telebof.Util; import et.telebof.types.ChatMember; +import et.telebof.types.Update; +import java.lang.reflect.Type; import java.util.List; public class GetChatAdministrators extends AbstractBaseRequest> { + + private static final Type responseType = TypeToken.getParameterized(List.class, ChatMember.class).getType(); public GetChatAdministrators(Object chatId, RequestSender requestSender){ - super(chatId, requestSender, "getChatAdministrators"); + super(chatId, requestSender, "getChatAdministrators", responseType); } - @Override - @SuppressWarnings("unchecked") - public List exec() { - return Util.parseList(Util.parse(requestSender.makeRequest(this), List.class), ChatMember.class); - } } diff --git a/src/main/java/et/telebof/requests/GetChatMember.java b/src/main/java/et/telebof/requests/GetChatMember.java index 938970b..302c2b9 100644 --- a/src/main/java/et/telebof/requests/GetChatMember.java +++ b/src/main/java/et/telebof/requests/GetChatMember.java @@ -5,12 +5,8 @@ public class GetChatMember extends AbstractBaseRequest { public GetChatMember(Object chatId, long userId, RequestSender requestSender) { - super(chatId, requestSender, "getChatMember"); + super(chatId, requestSender, "getChatMember", ChatMember.class); add("user_id", userId); } - @Override - public ChatMember exec() { - return Util.parse(requestSender.makeRequest(this), ChatMember.class); - } } diff --git a/src/main/java/et/telebof/requests/GetChatMemberCount.java b/src/main/java/et/telebof/requests/GetChatMemberCount.java index 31f296c..dd549ab 100644 --- a/src/main/java/et/telebof/requests/GetChatMemberCount.java +++ b/src/main/java/et/telebof/requests/GetChatMemberCount.java @@ -2,11 +2,7 @@ public class GetChatMemberCount extends AbstractBaseRequest { public GetChatMemberCount(Object chatId, RequestSender requestSender) { - super(chatId, requestSender, "getChatMemberCount"); + super(chatId, requestSender, "getChatMemberCount", Integer.class); } - @Override - public Integer exec() { - return (Integer) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/GetChatMenuButton.java b/src/main/java/et/telebof/requests/GetChatMenuButton.java index be1741a..d81bc71 100644 --- a/src/main/java/et/telebof/requests/GetChatMenuButton.java +++ b/src/main/java/et/telebof/requests/GetChatMenuButton.java @@ -5,15 +5,11 @@ public class GetChatMenuButton extends AbstractBaseRequest { public GetChatMenuButton(RequestSender requestSender) { - super(requestSender, "getChatMenuButton"); + super(requestSender, "getChatMenuButton", MenuButton.class); } public GetChatMenuButton chatId(long chatId) { return add("chat_id", chatId); } - @Override - public MenuButton exec() { - return Util.parse(requestSender.makeRequest(this), MenuButton.class); - } } diff --git a/src/main/java/et/telebof/requests/GetCustomEmojiStickers.java b/src/main/java/et/telebof/requests/GetCustomEmojiStickers.java index d8b5232..a803b15 100644 --- a/src/main/java/et/telebof/requests/GetCustomEmojiStickers.java +++ b/src/main/java/et/telebof/requests/GetCustomEmojiStickers.java @@ -1,18 +1,20 @@ package et.telebof.requests; +import com.google.gson.reflect.TypeToken; import et.telebof.Util; +import et.telebof.types.Message; import et.telebof.types.Sticker; + +import java.lang.reflect.Type; import java.util.List; public class GetCustomEmojiStickers extends AbstractBaseRequest> { + + private static final Type responseType = TypeToken.getParameterized(List.class, Sticker.class).getType(); + public GetCustomEmojiStickers(String[] customEmojiIds, RequestSender requestSender) { - super(requestSender, "getCustomEmojiStickers"); + super(requestSender, "getCustomEmojiStickers", responseType); add("custom_emoji_ids", List.of(customEmojiIds)); } - @Override - @SuppressWarnings("unchecked") - public List exec() { - return Util.parseList(Util.parse(requestSender.makeRequest(this), List.class), Sticker.class); - } } diff --git a/src/main/java/et/telebof/requests/GetFile.java b/src/main/java/et/telebof/requests/GetFile.java index abd70ed..3e8248f 100644 --- a/src/main/java/et/telebof/requests/GetFile.java +++ b/src/main/java/et/telebof/requests/GetFile.java @@ -6,12 +6,8 @@ public class GetFile extends AbstractBaseRequest { public GetFile(String fileId, RequestSender requestSender) { - super(requestSender, "getFile"); + super(requestSender, "getFile", File.class); add("file_id", fileId); } - public File exec() { - return Util.parse(requestSender.makeRequest(this), File.class); - - } } diff --git a/src/main/java/et/telebof/requests/GetForumTopicIconStickers.java b/src/main/java/et/telebof/requests/GetForumTopicIconStickers.java index 5dcc0d0..a12f9e1 100644 --- a/src/main/java/et/telebof/requests/GetForumTopicIconStickers.java +++ b/src/main/java/et/telebof/requests/GetForumTopicIconStickers.java @@ -1,19 +1,17 @@ package et.telebof.requests; +import com.google.gson.reflect.TypeToken; import et.telebof.Util; +import et.telebof.types.ChatMember; import et.telebof.types.Sticker; +import java.lang.reflect.Type; import java.util.List; public class GetForumTopicIconStickers extends AbstractBaseRequest > { - + private static final Type responseType = TypeToken.getParameterized(List.class, Sticker.class).getType(); public GetForumTopicIconStickers(RequestSender requestSender) { - super(requestSender, "getForumTopicIconStickers"); + super(requestSender, "getForumTopicIconStickers", responseType); } - @Override - @SuppressWarnings("unchecked") - public List exec() { - return Util.parseList(Util.parse(requestSender.makeRequest(this), List.class), Sticker.class); - } } diff --git a/src/main/java/et/telebof/requests/GetGameHighScores.java b/src/main/java/et/telebof/requests/GetGameHighScores.java index 7d28f77..eb86769 100644 --- a/src/main/java/et/telebof/requests/GetGameHighScores.java +++ b/src/main/java/et/telebof/requests/GetGameHighScores.java @@ -1,27 +1,27 @@ package et.telebof.requests; +import com.google.gson.reflect.TypeToken; import et.telebof.Util; +import et.telebof.types.ChatMember; import et.telebof.types.GameHighScore; +import java.lang.reflect.Type; import java.util.List; public class GetGameHighScores extends AbstractBaseRequest> { + private static final Type responseType = TypeToken.getParameterized(List.class, GameHighScore.class).getType(); + public GetGameHighScores(long chatId, long userId, int messageId, RequestSender requestSender) { - super(chatId, requestSender, "getGameHighScores"); + super(chatId, requestSender, "getGameHighScores", responseType); add("user_id", userId); add("message_id", messageId); } public GetGameHighScores(String inlineMessageId, long userId, RequestSender requestSender) { - super(requestSender, "getGameHighScores"); + super(requestSender, "getGameHighScores", responseType); add("user_id", userId); add("inline_message_id", inlineMessageId); } - @Override - @SuppressWarnings("unchecked") - public List exec() { - return Util.parseList(Util.parse(requestSender.makeRequest(this), List.class), GameHighScore.class); - } } diff --git a/src/main/java/et/telebof/requests/GetMe.java b/src/main/java/et/telebof/requests/GetMe.java index fb30d71..146be76 100644 --- a/src/main/java/et/telebof/requests/GetMe.java +++ b/src/main/java/et/telebof/requests/GetMe.java @@ -5,11 +5,7 @@ public class GetMe extends AbstractBaseRequest { public GetMe(RequestSender requestSender) { - super(requestSender, "getMe"); + super(requestSender, "getMe", User.class); } - @Override - public User exec() { - return Util.parse(requestSender.makeRequest(this), User.class); - } } diff --git a/src/main/java/et/telebof/requests/GetMyCommands.java b/src/main/java/et/telebof/requests/GetMyCommands.java index 6131865..8ba0bf2 100644 --- a/src/main/java/et/telebof/requests/GetMyCommands.java +++ b/src/main/java/et/telebof/requests/GetMyCommands.java @@ -1,14 +1,17 @@ package et.telebof.requests; -import et.telebof.Util; +import com.google.gson.reflect.TypeToken; import et.telebof.types.BotCommand; import et.telebof.types.BotCommandScope; - +import java.lang.reflect.Type; import java.util.List; public class GetMyCommands extends AbstractBaseRequest > { + + private static final Type responseType = TypeToken.getParameterized(List.class, BotCommand.class).getType(); + public GetMyCommands(RequestSender requestSender) { - super(requestSender, "getMyCommands"); + super(requestSender, "getMyCommands", responseType); } public GetMyCommands scope(BotCommandScope botCommandScope) { @@ -19,9 +22,4 @@ public GetMyCommands languageCode(String languageCode) { return add("language_code", languageCode); } - @Override - @SuppressWarnings("unchecked") - public List exec() { - return Util.parseList(Util.parse(requestSender.makeRequest(this), List.class), BotCommand.class); - } } diff --git a/src/main/java/et/telebof/requests/GetMyDefaultAdministratorRights.java b/src/main/java/et/telebof/requests/GetMyDefaultAdministratorRights.java index 61510a8..ab8438b 100644 --- a/src/main/java/et/telebof/requests/GetMyDefaultAdministratorRights.java +++ b/src/main/java/et/telebof/requests/GetMyDefaultAdministratorRights.java @@ -5,15 +5,11 @@ public class GetMyDefaultAdministratorRights extends AbstractBaseRequest { public GetMyDefaultAdministratorRights(RequestSender requestSender) { - super(requestSender, "getMyDefaultAdministratorRights"); + super(requestSender, "getMyDefaultAdministratorRights", ChatAdministratorRights.class); } public GetMyDefaultAdministratorRights forChannel(boolean forChannel) { return add("for_channel", forChannel); } - @Override - public ChatAdministratorRights exec() { - return Util.parse(requestSender.makeRequest(this), ChatAdministratorRights.class); - } } diff --git a/src/main/java/et/telebof/requests/GetMyDescription.java b/src/main/java/et/telebof/requests/GetMyDescription.java index a5b3c73..2b9a86b 100644 --- a/src/main/java/et/telebof/requests/GetMyDescription.java +++ b/src/main/java/et/telebof/requests/GetMyDescription.java @@ -5,11 +5,7 @@ public class GetMyDescription extends AbstractBaseRequest { public GetMyDescription(RequestSender requestSender) { - super(requestSender, "getMyDescription"); + super(requestSender, "getMyDescription", BotDescription.class); } - @Override - public BotDescription exec() { - return Util.parse(requestSender.makeRequest(this), BotDescription.class); - } } diff --git a/src/main/java/et/telebof/requests/GetMyName.java b/src/main/java/et/telebof/requests/GetMyName.java index 77b25ec..e969264 100644 --- a/src/main/java/et/telebof/requests/GetMyName.java +++ b/src/main/java/et/telebof/requests/GetMyName.java @@ -5,11 +5,7 @@ public class GetMyName extends AbstractBaseRequest { public GetMyName(RequestSender requestSender){ - super(requestSender, "getMyName"); + super(requestSender, "getMyName", BotName.class); } - @Override - public BotName exec() { - return Util.parse(requestSender.makeRequest(this), BotName.class); - } } diff --git a/src/main/java/et/telebof/requests/GetStickerSet.java b/src/main/java/et/telebof/requests/GetStickerSet.java index 41201c3..cda9ac5 100644 --- a/src/main/java/et/telebof/requests/GetStickerSet.java +++ b/src/main/java/et/telebof/requests/GetStickerSet.java @@ -5,12 +5,8 @@ public class GetStickerSet extends AbstractBaseRequest { public GetStickerSet(String name, RequestSender requestSender) { - super(requestSender, "getStickerSet"); + super(requestSender, "getStickerSet", StickerSet.class); add("name", name); } - @Override - public StickerSet exec() { - return Util.parse(requestSender.makeRequest(this), StickerSet.class); - } } diff --git a/src/main/java/et/telebof/requests/GetUpdates.java b/src/main/java/et/telebof/requests/GetUpdates.java index 48884a8..d668e42 100644 --- a/src/main/java/et/telebof/requests/GetUpdates.java +++ b/src/main/java/et/telebof/requests/GetUpdates.java @@ -1,15 +1,19 @@ package et.telebof.requests; -import et.telebof.Util; +import com.google.gson.reflect.TypeToken; import et.telebof.types.Update; import et.telebof.enums.Updates; + +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; public class GetUpdates extends AbstractBaseRequest>{ + private static final Type responseType = TypeToken.getParameterized(List.class, Update.class).getType(); + public GetUpdates(RequestSender requestSender){ - super(requestSender, "getUpdates"); + super(requestSender, "getUpdates", responseType); } public GetUpdates limit(Integer limit){ @@ -37,12 +41,5 @@ public GetUpdates timeout(Integer timeout){ return this; } - @Override - @SuppressWarnings("unchecked") - public List exec() { - Object response = requestSender.makeRequest(this); - List updateList = Util.parse(response, List.class); - return Util.parseList(updateList, Update.class); - } } diff --git a/src/main/java/et/telebof/requests/GetUserChatBoosts.java b/src/main/java/et/telebof/requests/GetUserChatBoosts.java index 70e2bb7..6f32d7a 100644 --- a/src/main/java/et/telebof/requests/GetUserChatBoosts.java +++ b/src/main/java/et/telebof/requests/GetUserChatBoosts.java @@ -1,16 +1,11 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.UserChatBoosts; public class GetUserChatBoosts extends AbstractBaseRequest { public GetUserChatBoosts(Object chat_id, long user_id, RequestSender requestSender){ - super(chat_id, requestSender, "getUserChatBoosts"); + super(chat_id, requestSender, "getUserChatBoosts", UserChatBoosts.class); add("user_id", user_id); } - @Override - public UserChatBoosts exec() { - return Util.parse(requestSender.makeRequest(this), UserChatBoosts.class); - } } diff --git a/src/main/java/et/telebof/requests/GetUserProfilePhotos.java b/src/main/java/et/telebof/requests/GetUserProfilePhotos.java index 2f07160..75ee07b 100644 --- a/src/main/java/et/telebof/requests/GetUserProfilePhotos.java +++ b/src/main/java/et/telebof/requests/GetUserProfilePhotos.java @@ -1,12 +1,11 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.UserProfilePhotos; public class GetUserProfilePhotos extends AbstractBaseRequest { public GetUserProfilePhotos(long userId, RequestSender requestSender) { - super(requestSender, "getUserProfilePhotos"); + super(requestSender, "getUserProfilePhotos", UserProfilePhotos.class); add("user_id", userId); } @@ -18,8 +17,4 @@ public GetUserProfilePhotos limit(int limit) { return add("limit", limit); } - @Override - public UserProfilePhotos exec() { - return Util.parse(requestSender.makeRequest(this), UserProfilePhotos.class); - } } diff --git a/src/main/java/et/telebof/requests/GetWebhookInfo.java b/src/main/java/et/telebof/requests/GetWebhookInfo.java index 7f7a2ad..772b56f 100644 --- a/src/main/java/et/telebof/requests/GetWebhookInfo.java +++ b/src/main/java/et/telebof/requests/GetWebhookInfo.java @@ -1,15 +1,10 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.WebhookInfo; public class GetWebhookInfo extends AbstractBaseRequest { public GetWebhookInfo(RequestSender requestSender){ - super(requestSender, "getWebhookInfo"); + super(requestSender, "getWebhookInfo", WebhookInfo.class); } - @Override - public WebhookInfo exec() { - return Util.parse(requestSender.makeRequest(this), WebhookInfo.class); - } } diff --git a/src/main/java/et/telebof/requests/HideGeneralForumTopic.java b/src/main/java/et/telebof/requests/HideGeneralForumTopic.java index 9f06b65..a8e17e2 100644 --- a/src/main/java/et/telebof/requests/HideGeneralForumTopic.java +++ b/src/main/java/et/telebof/requests/HideGeneralForumTopic.java @@ -5,8 +5,4 @@ public HideGeneralForumTopic(Object chatId, RequestSender requestSender) { super(chatId, requestSender, "hideGeneralForumTopic"); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/LeaveChat.java b/src/main/java/et/telebof/requests/LeaveChat.java index 7e27a79..dd8f978 100644 --- a/src/main/java/et/telebof/requests/LeaveChat.java +++ b/src/main/java/et/telebof/requests/LeaveChat.java @@ -5,8 +5,4 @@ public LeaveChat(Object chatId, RequestSender requestSender) { super(chatId, requestSender, "leaveChat"); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/LogOut.java b/src/main/java/et/telebof/requests/LogOut.java index e0c5fca..fd3cdad 100644 --- a/src/main/java/et/telebof/requests/LogOut.java +++ b/src/main/java/et/telebof/requests/LogOut.java @@ -5,8 +5,4 @@ public LogOut(RequestSender requestSender) { super(requestSender, "logOut"); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/PinChatMessage.java b/src/main/java/et/telebof/requests/PinChatMessage.java index 920f5a0..009da9e 100644 --- a/src/main/java/et/telebof/requests/PinChatMessage.java +++ b/src/main/java/et/telebof/requests/PinChatMessage.java @@ -10,9 +10,4 @@ public PinChatMessage disableNotification(boolean disableNotification) { return add("disable_notification", disableNotification); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } - } diff --git a/src/main/java/et/telebof/requests/PromoteChatMember.java b/src/main/java/et/telebof/requests/PromoteChatMember.java index d32b26c..ebdabfb 100644 --- a/src/main/java/et/telebof/requests/PromoteChatMember.java +++ b/src/main/java/et/telebof/requests/PromoteChatMember.java @@ -68,8 +68,4 @@ public PromoteChatMember canDeleteStories(boolean canDeleteStories){ return add("can_delete_stories", canDeleteStories); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/RefundStarPayment.java b/src/main/java/et/telebof/requests/RefundStarPayment.java new file mode 100644 index 0000000..e205545 --- /dev/null +++ b/src/main/java/et/telebof/requests/RefundStarPayment.java @@ -0,0 +1,10 @@ +package et.telebof.requests; + +public class RefundStarPayment extends AbstractBaseRequest { + private RefundStarPayment(long user_id, String telegram_payment_charge_id, RequestSender requestSender){ + super(requestSender, "refundStarPayment"); + add("user_id", user_id); + add("telegram_payment_charge_id", telegram_payment_charge_id); + } + +} diff --git a/src/main/java/et/telebof/requests/ReopenForumTopic.java b/src/main/java/et/telebof/requests/ReopenForumTopic.java index 87fd230..e5af7f8 100644 --- a/src/main/java/et/telebof/requests/ReopenForumTopic.java +++ b/src/main/java/et/telebof/requests/ReopenForumTopic.java @@ -6,8 +6,4 @@ public ReopenForumTopic(Object chatId, int messageThreadId, RequestSender reques add("message_thread_id", messageThreadId); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/ReopenGeneralForumTopic.java b/src/main/java/et/telebof/requests/ReopenGeneralForumTopic.java index 20b30bb..f7a032a 100644 --- a/src/main/java/et/telebof/requests/ReopenGeneralForumTopic.java +++ b/src/main/java/et/telebof/requests/ReopenGeneralForumTopic.java @@ -5,8 +5,4 @@ public ReopenGeneralForumTopic(Object chatId, RequestSender requestSender) { super(chatId, requestSender, "reopenGeneralForumTopic"); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/ReplaceStickerInSet.java b/src/main/java/et/telebof/requests/ReplaceStickerInSet.java index b82d9c6..4c2f328 100644 --- a/src/main/java/et/telebof/requests/ReplaceStickerInSet.java +++ b/src/main/java/et/telebof/requests/ReplaceStickerInSet.java @@ -14,8 +14,4 @@ public ReplaceStickerInSet(long user_id, String name, String old_sticker, InputS add("sticker", sticker); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/RequestSender.java b/src/main/java/et/telebof/requests/RequestSender.java index 24aee80..97bdfcd 100644 --- a/src/main/java/et/telebof/requests/RequestSender.java +++ b/src/main/java/et/telebof/requests/RequestSender.java @@ -85,15 +85,14 @@ private String getUrl(AbstractBaseRequest baseRequest) { return String.format(URL, botToken, baseRequest.getMethodName()); } - public ApiResponse postRequest(AbstractBaseRequest baseRequest){ + public ApiResponse postRequest(AbstractBaseRequest baseRequest){ RequestBody requestBody = prepareRequest(baseRequest); Request request = builder.url(getUrl(baseRequest)) .post(requestBody).build(); try (Response response = client.newCall(request).execute()){ ResponseBody responseBody = response.body(); - String stringResponse = responseBody.string(); - return Util.parse(stringResponse, ApiResponse.class); + return Util.parseApiResponse(responseBody.string(), baseRequest.getResponseType()); } catch (UnknownHostException e){ throw new ConnectionError(String.format("Unable to send request to %s", request.url().url().getHost())); } catch (IOException e){ @@ -101,10 +100,10 @@ public ApiResponse postRequest(AbstractBaseRequest baseRequest){ } } - public Object makeRequest(AbstractBaseRequest abstractBase) { + public R makeRequest(AbstractBaseRequest abstractBase) { if (botToken == null || botToken.isEmpty()) throw new TelegramError("Undefined botToken"); BotLog.debug(String.format("Request: method=%s, url=%s", abstractBase.methodName, getUrl(abstractBase))); - ApiResponse response = postRequest(abstractBase); + ApiResponse response = postRequest(abstractBase); BotLog.debug(String.format("The server returned: %s", response.result)); if (!response.ok) throw new TelegramApiException(response); else return response.result; diff --git a/src/main/java/et/telebof/requests/RestrictChatMember.java b/src/main/java/et/telebof/requests/RestrictChatMember.java index bbb91be..c2d7eb9 100644 --- a/src/main/java/et/telebof/requests/RestrictChatMember.java +++ b/src/main/java/et/telebof/requests/RestrictChatMember.java @@ -16,8 +16,4 @@ public RestrictChatMember untilDate(long untilDate){ return this; } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/RevokeChatInviteLink.java b/src/main/java/et/telebof/requests/RevokeChatInviteLink.java index 53cd2a2..26207fd 100644 --- a/src/main/java/et/telebof/requests/RevokeChatInviteLink.java +++ b/src/main/java/et/telebof/requests/RevokeChatInviteLink.java @@ -1,16 +1,11 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.ChatInviteLink; public class RevokeChatInviteLink extends AbstractBaseRequest { public RevokeChatInviteLink(Object chatId, String inviteLink, RequestSender requestSender) { - super(chatId, requestSender, "revokeChatInviteLink"); + super(chatId, requestSender, "revokeChatInviteLink", ChatInviteLink.class); add("invite_link", inviteLink); } - @Override - public ChatInviteLink exec() { - return Util.parse(requestSender.makeRequest(this), ChatInviteLink.class); - } } diff --git a/src/main/java/et/telebof/requests/SendAnimation.java b/src/main/java/et/telebof/requests/SendAnimation.java index d0f2c71..ecdb8cc 100644 --- a/src/main/java/et/telebof/requests/SendAnimation.java +++ b/src/main/java/et/telebof/requests/SendAnimation.java @@ -1,6 +1,5 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Message; import et.telebof.types.MessageEntity; import java.io.File; @@ -52,8 +51,8 @@ public SendAnimation duration(int duration) { return add("duration", duration); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); + public SendAnimation showCaptionAboveMedia(boolean show_caption_above_media){ + return add("show_caption_above_media", show_caption_above_media); } + } diff --git a/src/main/java/et/telebof/requests/SendAudio.java b/src/main/java/et/telebof/requests/SendAudio.java index a837a1d..552c774 100644 --- a/src/main/java/et/telebof/requests/SendAudio.java +++ b/src/main/java/et/telebof/requests/SendAudio.java @@ -1,6 +1,5 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Message; import et.telebof.types.MessageEntity; import java.io.File; @@ -47,8 +46,4 @@ public SendAudio thumbnail(File thumbnail) { return add("thumbnail", thumbnail); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } } diff --git a/src/main/java/et/telebof/requests/SendChatAction.java b/src/main/java/et/telebof/requests/SendChatAction.java index cb2c89b..d0bd7ad 100644 --- a/src/main/java/et/telebof/requests/SendChatAction.java +++ b/src/main/java/et/telebof/requests/SendChatAction.java @@ -17,10 +17,5 @@ public SendChatAction messageThreadId(int messageThreadId) { public SendChatAction businessConnectionId(String business_connection_id){ return add("business_connection_id", business_connection_id); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } - } diff --git a/src/main/java/et/telebof/requests/SendContact.java b/src/main/java/et/telebof/requests/SendContact.java index 8cdb5d9..40b969e 100644 --- a/src/main/java/et/telebof/requests/SendContact.java +++ b/src/main/java/et/telebof/requests/SendContact.java @@ -1,6 +1,5 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Markup; import et.telebof.types.Message; import et.telebof.types.ReplyParameters; @@ -8,7 +7,7 @@ public class SendContact extends AbstractBaseRequest { public SendContact(Object chatId, String phoneNumber, String firstName, RequestSender requestSender) { - super(chatId, requestSender, "sendContact"); + super(chatId, requestSender, "sendContact", Message.class); add("phone_number", phoneNumber); add("first_name", firstName); } @@ -50,8 +49,8 @@ public SendContact replyMarkup(Markup replyMarkup) { public SendContact businessConnectionId(String business_connection_id){ return add("business_connection_id", business_connection_id); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); + + public SendContact messageEffectId(String message_effect_id ){ + return add("message_effect_id ", message_effect_id); } } diff --git a/src/main/java/et/telebof/requests/SendDice.java b/src/main/java/et/telebof/requests/SendDice.java index fdcaa87..20aa519 100644 --- a/src/main/java/et/telebof/requests/SendDice.java +++ b/src/main/java/et/telebof/requests/SendDice.java @@ -1,13 +1,12 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Markup; import et.telebof.types.Message; import et.telebof.types.ReplyParameters; public class SendDice extends AbstractBaseRequest { public SendDice(Object chatId, RequestSender requestSender) { - super(chatId, requestSender, "sendDice"); + super(chatId, requestSender, "sendDice", Message.class); } public SendDice emoji(String emoji) { @@ -40,8 +39,4 @@ public SendDice replyMarkup(Markup replyMarkup) { return add("reply_markup", replyMarkup); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } } diff --git a/src/main/java/et/telebof/requests/SendDocument.java b/src/main/java/et/telebof/requests/SendDocument.java index e1728b2..1e7bd95 100644 --- a/src/main/java/et/telebof/requests/SendDocument.java +++ b/src/main/java/et/telebof/requests/SendDocument.java @@ -1,6 +1,5 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Message; import et.telebof.types.MessageEntity; import java.io.File;import java.util.List; @@ -43,8 +42,4 @@ public SendDocument disableContentTypeDetection(boolean disableContentTypeDetect return add("disable_content_type_detection", disableContentTypeDetection); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } } diff --git a/src/main/java/et/telebof/requests/SendGame.java b/src/main/java/et/telebof/requests/SendGame.java index 95e5110..cbe4e18 100644 --- a/src/main/java/et/telebof/requests/SendGame.java +++ b/src/main/java/et/telebof/requests/SendGame.java @@ -1,6 +1,5 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Message; public class SendGame extends DefaultParameters { @@ -9,8 +8,4 @@ public SendGame(long chatId, String gameShortName, RequestSender requestSender) add("game_short_name", gameShortName); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } } diff --git a/src/main/java/et/telebof/requests/SendInvoice.java b/src/main/java/et/telebof/requests/SendInvoice.java index ea7229f..b770537 100644 --- a/src/main/java/et/telebof/requests/SendInvoice.java +++ b/src/main/java/et/telebof/requests/SendInvoice.java @@ -1,26 +1,23 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.LabeledPrice; import et.telebof.types.Message; - -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.Map; public class SendInvoice extends DefaultParameters { - public SendInvoice(Object chatId, String title, String description, String payload, String providerToken, + public SendInvoice(Object chatId, String title, String description, String payload, String currency, LabeledPrice[] prices, RequestSender requestSender) { super(chatId, requestSender, "sendInvoice"); add("title", title); add("description", description); add("payload", payload); - add("provider_token", providerToken); add("currency", currency); add("prices", prices); } + public SendInvoice providerToken(String providerToken){ + return add("provider_token", providerToken); + } public SendInvoice maxTipAmount(int maxTipAmount) { return add("max_tip_amount", maxTipAmount); } @@ -81,9 +78,4 @@ public SendInvoice isFlexible(boolean isFlexible) { return add("is_flexible", isFlexible); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } - } diff --git a/src/main/java/et/telebof/requests/SendLocation.java b/src/main/java/et/telebof/requests/SendLocation.java index d965e56..f92971e 100644 --- a/src/main/java/et/telebof/requests/SendLocation.java +++ b/src/main/java/et/telebof/requests/SendLocation.java @@ -1,18 +1,17 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Markup; import et.telebof.types.Message; import et.telebof.types.ReplyParameters; public class SendLocation extends AbstractBaseRequest { - public SendLocation(Object chatId, float latitude, float longitude, RequestSender requestSender) { - super(chatId, requestSender, "sendLocation"); + public SendLocation(Object chatId, double latitude, double longitude, RequestSender requestSender) { + super(chatId, requestSender, "sendLocation", Message.class); add("longitude", longitude); add("latitude", latitude); } - public SendLocation horizontalAccuracy(float horizontalAccuracy) { + public SendLocation horizontalAccuracy(double horizontalAccuracy) { return add("horizontal_accuracy", horizontalAccuracy); } @@ -57,8 +56,8 @@ public SendLocation replyMarkup(Markup replyMarkup) { public SendLocation businessConnectionId(String business_connection_id){ return add("business_connection_id", business_connection_id); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); + + public SendLocation messageEffectId(String message_effect_id ){ + return add("message_effect_id ", message_effect_id); } } diff --git a/src/main/java/et/telebof/requests/SendMediaGroup.java b/src/main/java/et/telebof/requests/SendMediaGroup.java index 3b62cee..a62df70 100644 --- a/src/main/java/et/telebof/requests/SendMediaGroup.java +++ b/src/main/java/et/telebof/requests/SendMediaGroup.java @@ -1,18 +1,21 @@ package et.telebof.requests; +import com.google.gson.reflect.TypeToken; import et.telebof.BotLog; import et.telebof.Util; import et.telebof.types.InputMedia; import et.telebof.types.Markup; import et.telebof.types.Message; +import java.lang.reflect.Type; import java.util.List; public class SendMediaGroup extends DefaultParameters> { + public static Type responseType = TypeToken.getParameterized(List.class, Message.class).getType(); public SendMediaGroup(Object chatId, T[] medias, RequestSender requestSender) { - super(chatId, requestSender, "sendMediaGroup"); + super(chatId, requestSender, "sendMediaGroup", responseType); add("media", medias); for (InputMedia im: medias){ if (im.isFile()){ @@ -25,17 +28,11 @@ public SendMediaGroup(Object chatId, T[] medias, RequestS } @Override - @Deprecated + @Deprecated(forRemoval = true) public SendMediaGroup replyMarkup(Markup replyMarkup) { BotLog.warn("`sendMediaGroup` method does not support replyMarkup option."); return this; } - @Override - @SuppressWarnings("unchecked") - public List exec() { - Object result = requestSender.makeRequest(this); - List objects = Util.parse(result, List.class); - return Util.parseList(objects, Message.class); - } + } diff --git a/src/main/java/et/telebof/requests/SendMessage.java b/src/main/java/et/telebof/requests/SendMessage.java index e88c17c..03d4e3c 100644 --- a/src/main/java/et/telebof/requests/SendMessage.java +++ b/src/main/java/et/telebof/requests/SendMessage.java @@ -1,11 +1,8 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Message; import et.telebof.types.MessageEntity; -import java.util.List; - public class SendMessage extends DefaultParameters { public SendMessage(Object chatId, String text, RequestSender requestSender) { super(chatId, requestSender, "sendMessage"); @@ -17,8 +14,4 @@ public SendMessage entities(MessageEntity[] entities) { return add("entities", entities); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } } diff --git a/src/main/java/et/telebof/requests/SendPhoto.java b/src/main/java/et/telebof/requests/SendPhoto.java index caec8bf..b9e87cc 100644 --- a/src/main/java/et/telebof/requests/SendPhoto.java +++ b/src/main/java/et/telebof/requests/SendPhoto.java @@ -1,6 +1,5 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Message; import et.telebof.types.MessageEntity; import java.io.File; @@ -32,8 +31,8 @@ public SendPhoto hasSpoiler(boolean hasSpoiler) { return this; } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); + public SendPhoto showCaptionAboveMedia(boolean show_caption_above_media){ + return add("show_caption_above_media", show_caption_above_media); } + } diff --git a/src/main/java/et/telebof/requests/SendPoll.java b/src/main/java/et/telebof/requests/SendPoll.java index 74bc963..c5ab13b 100644 --- a/src/main/java/et/telebof/requests/SendPoll.java +++ b/src/main/java/et/telebof/requests/SendPoll.java @@ -1,7 +1,6 @@ package et.telebof.requests; import et.telebof.enums.ParseMode; -import et.telebof.Util; import et.telebof.enums.PollType; import et.telebof.types.InputPollOption; import et.telebof.types.Markup; @@ -20,7 +19,7 @@ public class SendPoll extends AbstractBaseRequest { public SendPoll(Object chatId, String question, InputPollOption[] options, RequestSender requestSender) { - super(chatId, requestSender, "sendPoll"); + super(chatId, requestSender, "sendPoll", Message.class); add("question", question); add("options", List.of(options)); } @@ -45,7 +44,7 @@ public SendPoll explanation(String explanation){ return add("explanation", explanation); } - public SendPoll explanationParseMode(ParseMode explanationParseMode){ + public SendPoll explanationParseMode(@NotNull ParseMode explanationParseMode){ return add("explanation_parse_mode", explanationParseMode.name().toLowerCase()); } @@ -106,8 +105,8 @@ public SendPoll questionEntities(MessageEntity[] question_entities){ return add("question_entities", question_entities); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); + public SendPoll messageEffectId(String message_effect_id ){ + return add("message_effect_id ", message_effect_id); } + } diff --git a/src/main/java/et/telebof/requests/SendSticker.java b/src/main/java/et/telebof/requests/SendSticker.java index c173788..e379efc 100644 --- a/src/main/java/et/telebof/requests/SendSticker.java +++ b/src/main/java/et/telebof/requests/SendSticker.java @@ -1,9 +1,9 @@ package et.telebof.requests; import et.telebof.BotLog; -import et.telebof.Util; import et.telebof.enums.ParseMode; import et.telebof.types.Message; +import org.jetbrains.annotations.NotNull; import java.io.File; @@ -25,14 +25,9 @@ public SendSticker emoji(String emoji) { @Override @Deprecated(forRemoval = true) - public SendSticker parseMode(ParseMode parseM) { + public SendSticker parseMode(@NotNull ParseMode parseM) { BotLog.warn("`sendSticker` method does not support parseMode option."); return this; } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } - } diff --git a/src/main/java/et/telebof/requests/SendVenue.java b/src/main/java/et/telebof/requests/SendVenue.java index 7988069..afc2b6b 100644 --- a/src/main/java/et/telebof/requests/SendVenue.java +++ b/src/main/java/et/telebof/requests/SendVenue.java @@ -1,12 +1,12 @@ package et.telebof.requests; -import et.telebof.Util; + import et.telebof.types.Message; import et.telebof.types.ReplyParameters; public class SendVenue extends AbstractBaseRequest { - public SendVenue(Object chatId, float latitude, float longitude, String title, String address, RequestSender requestSender) { - super(chatId, requestSender, "sendVenue"); + public SendVenue(Object chatId, double latitude, double longitude, String title, String address, RequestSender requestSender) { + super(chatId, requestSender, "sendVenue", Message.class); add("latitude", latitude); add("longitude", longitude); add("title", title); @@ -54,8 +54,8 @@ public SendVenue replyParameters(ReplyParameters parameters){ public SendVenue businessConnectionId(String business_connection_id){ return add("business_connection_id", business_connection_id); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); + + public SendVenue messageEffectId(String message_effect_id ){ + return add("message_effect_id ", message_effect_id); } } diff --git a/src/main/java/et/telebof/requests/SendVideo.java b/src/main/java/et/telebof/requests/SendVideo.java index fa4a8aa..ac79c86 100644 --- a/src/main/java/et/telebof/requests/SendVideo.java +++ b/src/main/java/et/telebof/requests/SendVideo.java @@ -1,6 +1,5 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Message; import et.telebof.types.MessageEntity; import java.io.File; @@ -50,9 +49,8 @@ public SendVideo duration(Long duration) { return add("duration", duration); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); + public SendVideo showCaptionAboveMedia(boolean show_caption_above_media){ + return add("show_caption_above_media", show_caption_above_media); } } diff --git a/src/main/java/et/telebof/requests/SendVideoNote.java b/src/main/java/et/telebof/requests/SendVideoNote.java index 35b6396..2baa09b 100644 --- a/src/main/java/et/telebof/requests/SendVideoNote.java +++ b/src/main/java/et/telebof/requests/SendVideoNote.java @@ -1,6 +1,5 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Message; import et.telebof.types.MessageEntity; import java.io.File; @@ -38,9 +37,4 @@ public SendVideoNote duration(int duration) { return add("duration", duration); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } - } diff --git a/src/main/java/et/telebof/requests/SendVoice.java b/src/main/java/et/telebof/requests/SendVoice.java index 309fa25..408c023 100644 --- a/src/main/java/et/telebof/requests/SendVoice.java +++ b/src/main/java/et/telebof/requests/SendVoice.java @@ -1,6 +1,5 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.Message; import et.telebof.types.MessageEntity; import java.io.File; @@ -26,9 +25,4 @@ public SendVoice captionEntities(MessageEntity[] captionEntities) { return add("caption_entities", List.of(captionEntities)); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } - } diff --git a/src/main/java/et/telebof/requests/SetChatAdministratorCustomTitle.java b/src/main/java/et/telebof/requests/SetChatAdministratorCustomTitle.java index 3bf72d9..ac76862 100644 --- a/src/main/java/et/telebof/requests/SetChatAdministratorCustomTitle.java +++ b/src/main/java/et/telebof/requests/SetChatAdministratorCustomTitle.java @@ -7,8 +7,4 @@ public SetChatAdministratorCustomTitle(Object chatId, long userId, String custom add("custom_title", customTitle); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/SetChatDescription.java b/src/main/java/et/telebof/requests/SetChatDescription.java index 1fb7241..50084aa 100644 --- a/src/main/java/et/telebof/requests/SetChatDescription.java +++ b/src/main/java/et/telebof/requests/SetChatDescription.java @@ -6,9 +6,4 @@ public SetChatDescription(Object chatId, String title, RequestSender requestSend add("description", title); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetChatMenuButton.java b/src/main/java/et/telebof/requests/SetChatMenuButton.java index 2269ceb..54273de 100644 --- a/src/main/java/et/telebof/requests/SetChatMenuButton.java +++ b/src/main/java/et/telebof/requests/SetChatMenuButton.java @@ -15,9 +15,4 @@ public SetChatMenuButton menuButton(MenuButton menuButton) { return add("menu_button", menuButton); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetChatPermissions.java b/src/main/java/et/telebof/requests/SetChatPermissions.java index a2d0f6c..8b42132 100644 --- a/src/main/java/et/telebof/requests/SetChatPermissions.java +++ b/src/main/java/et/telebof/requests/SetChatPermissions.java @@ -8,9 +8,4 @@ public SetChatPermissions(Object chatId, ChatPermission permissions, RequestSend add("permissions", permissions); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetChatPhoto.java b/src/main/java/et/telebof/requests/SetChatPhoto.java index aa139e2..2023c12 100644 --- a/src/main/java/et/telebof/requests/SetChatPhoto.java +++ b/src/main/java/et/telebof/requests/SetChatPhoto.java @@ -9,9 +9,4 @@ public SetChatPhoto(Object chatId, File photo, RequestSender requestSender) { setContentType(MediaContentType.PHOTO); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetChatStickerSet.java b/src/main/java/et/telebof/requests/SetChatStickerSet.java index 5fb1e16..0538939 100644 --- a/src/main/java/et/telebof/requests/SetChatStickerSet.java +++ b/src/main/java/et/telebof/requests/SetChatStickerSet.java @@ -6,9 +6,4 @@ public SetChatStickerSet(Object chatId, String stickerSetName, RequestSender req add("sticker_set_name", stickerSetName); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetChatTitle.java b/src/main/java/et/telebof/requests/SetChatTitle.java index 7047988..3bea2a2 100644 --- a/src/main/java/et/telebof/requests/SetChatTitle.java +++ b/src/main/java/et/telebof/requests/SetChatTitle.java @@ -6,9 +6,4 @@ public SetChatTitle(Object chatId, String title, RequestSender requestSender) { add("title", title); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetCustomEmojiStickerSetThumbnail.java b/src/main/java/et/telebof/requests/SetCustomEmojiStickerSetThumbnail.java index dfa7a10..49bd9c6 100644 --- a/src/main/java/et/telebof/requests/SetCustomEmojiStickerSetThumbnail.java +++ b/src/main/java/et/telebof/requests/SetCustomEmojiStickerSetThumbnail.java @@ -7,9 +7,4 @@ public SetCustomEmojiStickerSetThumbnail(String name, String customEmojiId, Requ add("custom_emoji_id", customEmojiId); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetGameScore.java b/src/main/java/et/telebof/requests/SetGameScore.java index e275dc5..e3a3425 100644 --- a/src/main/java/et/telebof/requests/SetGameScore.java +++ b/src/main/java/et/telebof/requests/SetGameScore.java @@ -5,14 +5,14 @@ public class SetGameScore extends AbstractBaseRequest { public SetGameScore(long chatId, long userId, int score, int messageId, RequestSender requestSender) { - super(chatId, requestSender, "setGameScore"); + super(chatId, requestSender, "setGameScore", Message.class); add("user_id", userId); add("message_id", messageId); add("score",score); } public SetGameScore(String inlineMessageId, long userId, int score, RequestSender requestSender) { - super(requestSender, "setGameScore"); + super(requestSender, "setGameScore", Message.class); add("user_id", userId); add("inline_message_id", inlineMessageId); add("score",score); @@ -26,9 +26,4 @@ public SetGameScore disableEditMessage(boolean disableEditMessage) { return add("disable_edit_message", disableEditMessage); } - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } - } diff --git a/src/main/java/et/telebof/requests/SetMessageReaction.java b/src/main/java/et/telebof/requests/SetMessageReaction.java index c4451b7..4c15feb 100644 --- a/src/main/java/et/telebof/requests/SetMessageReaction.java +++ b/src/main/java/et/telebof/requests/SetMessageReaction.java @@ -17,8 +17,4 @@ public SetMessageReaction isBig(boolean is_big){ return add("is_big", is_big); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/SetMyCommands.java b/src/main/java/et/telebof/requests/SetMyCommands.java index 463f684..1c9322f 100644 --- a/src/main/java/et/telebof/requests/SetMyCommands.java +++ b/src/main/java/et/telebof/requests/SetMyCommands.java @@ -22,9 +22,4 @@ public SetMyCommands languageCode(String languageCode) { return add("language_code", languageCode); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetMyDefaultAdministratorRights.java b/src/main/java/et/telebof/requests/SetMyDefaultAdministratorRights.java index 5e9e8ec..dfbcbda 100644 --- a/src/main/java/et/telebof/requests/SetMyDefaultAdministratorRights.java +++ b/src/main/java/et/telebof/requests/SetMyDefaultAdministratorRights.java @@ -16,9 +16,4 @@ public SetMyDefaultAdministratorRights forChannel(boolean forChannel) { return add("for_channel", forChannel); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetMyDescription.java b/src/main/java/et/telebof/requests/SetMyDescription.java index 346b54d..fbf3a23 100644 --- a/src/main/java/et/telebof/requests/SetMyDescription.java +++ b/src/main/java/et/telebof/requests/SetMyDescription.java @@ -11,10 +11,4 @@ public SetMyDescription(String description, String languageCode, RequestSender r add("language_code", languageCode); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } - } diff --git a/src/main/java/et/telebof/requests/SetMyName.java b/src/main/java/et/telebof/requests/SetMyName.java index 8334f17..109b221 100644 --- a/src/main/java/et/telebof/requests/SetMyName.java +++ b/src/main/java/et/telebof/requests/SetMyName.java @@ -16,10 +16,4 @@ public SetMyName languageCode(String languageCode){ add("language_code", languageCode); return this; } - - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetPassportDataErrors.java b/src/main/java/et/telebof/requests/SetPassportDataErrors.java index 5ffbc89..71848ef 100644 --- a/src/main/java/et/telebof/requests/SetPassportDataErrors.java +++ b/src/main/java/et/telebof/requests/SetPassportDataErrors.java @@ -9,9 +9,4 @@ public SetPassportDataErrors(long userId, PassportElementError[] errors, Request add("errors", errors); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetStickerEmojiList.java b/src/main/java/et/telebof/requests/SetStickerEmojiList.java index 3d4948c..b45c519 100644 --- a/src/main/java/et/telebof/requests/SetStickerEmojiList.java +++ b/src/main/java/et/telebof/requests/SetStickerEmojiList.java @@ -9,9 +9,4 @@ public SetStickerEmojiList(String sticker, String[] emojiList, RequestSender req add("emoji_list", List.of(emojiList)); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetStickerKeywords.java b/src/main/java/et/telebof/requests/SetStickerKeywords.java index f07298a..71a4965 100644 --- a/src/main/java/et/telebof/requests/SetStickerKeywords.java +++ b/src/main/java/et/telebof/requests/SetStickerKeywords.java @@ -10,9 +10,4 @@ public SetStickerKeywords(String sticker, String[] keywords, RequestSender reque add("keywords", List.of(keywords)); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetStickerMaskPosition.java b/src/main/java/et/telebof/requests/SetStickerMaskPosition.java index 6db9e29..604be80 100644 --- a/src/main/java/et/telebof/requests/SetStickerMaskPosition.java +++ b/src/main/java/et/telebof/requests/SetStickerMaskPosition.java @@ -10,9 +10,4 @@ public SetStickerMaskPosition(String sticker, MaskPosition maskPosition, Request add("mask_position", maskPosition); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetStickerPositionInSet.java b/src/main/java/et/telebof/requests/SetStickerPositionInSet.java index 38766e2..9c24b65 100644 --- a/src/main/java/et/telebof/requests/SetStickerPositionInSet.java +++ b/src/main/java/et/telebof/requests/SetStickerPositionInSet.java @@ -8,9 +8,4 @@ public SetStickerPositionInSet(String sticker, int position, RequestSender reque add("position", position); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetStickerSetThumbnail.java b/src/main/java/et/telebof/requests/SetStickerSetThumbnail.java index 17a17fb..4c5b1b9 100644 --- a/src/main/java/et/telebof/requests/SetStickerSetThumbnail.java +++ b/src/main/java/et/telebof/requests/SetStickerSetThumbnail.java @@ -21,9 +21,4 @@ public SetStickerSetThumbnail(String name, long userId, String thumbnail, String add("format", format); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/SetStickerSetTitle.java b/src/main/java/et/telebof/requests/SetStickerSetTitle.java index 35a09ab..e9af95a 100644 --- a/src/main/java/et/telebof/requests/SetStickerSetTitle.java +++ b/src/main/java/et/telebof/requests/SetStickerSetTitle.java @@ -8,10 +8,4 @@ public SetStickerSetTitle(String sticker, String title, RequestSender requestSen add("title", title); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } - } diff --git a/src/main/java/et/telebof/requests/SetWebhook.java b/src/main/java/et/telebof/requests/SetWebhook.java index 422e0d2..daf8bda 100644 --- a/src/main/java/et/telebof/requests/SetWebhook.java +++ b/src/main/java/et/telebof/requests/SetWebhook.java @@ -10,9 +10,4 @@ public SetWebhook(Webhook webhook, RequestSender requestSender){ } } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/StopMessageLiveLocation.java b/src/main/java/et/telebof/requests/StopMessageLiveLocation.java index dc8bd79..5ababe5 100644 --- a/src/main/java/et/telebof/requests/StopMessageLiveLocation.java +++ b/src/main/java/et/telebof/requests/StopMessageLiveLocation.java @@ -1,38 +1,20 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.InlineKeyboardMarkup; import et.telebof.types.Message; public class StopMessageLiveLocation extends AbstractBaseRequest { public StopMessageLiveLocation(Object chatId, int messageId, RequestSender requestSender) { - super(chatId, requestSender, "stopMessageLiveLocation"); + super(chatId, requestSender, "stopMessageLiveLocation", Message.class); add("message_id", messageId); } public StopMessageLiveLocation(String inlineMessageId, RequestSender requestSender) { - super(requestSender, "stopMessageLiveLocation"); + super(requestSender, "stopMessageLiveLocation", Message.class); add("inline_message_id", inlineMessageId); } - public StopMessageLiveLocation chatId(Object chatId) { - return add("chat_id", chatId); - } - - public StopMessageLiveLocation messageId(int messageId){ - return add("message_id", messageId); - } - - public StopMessageLiveLocation inlineMessageId(String inlineMessageId){ - return add("inline_message_id", inlineMessageId); - } - public StopMessageLiveLocation replyMarkup(InlineKeyboardMarkup replyMarkup) { return add("reply_markup", replyMarkup); } - - @Override - public Message exec() { - return Util.parse(requestSender.makeRequest(this), Message.class); - } } diff --git a/src/main/java/et/telebof/requests/StopPoll.java b/src/main/java/et/telebof/requests/StopPoll.java index 1800e69..d335631 100644 --- a/src/main/java/et/telebof/requests/StopPoll.java +++ b/src/main/java/et/telebof/requests/StopPoll.java @@ -1,12 +1,11 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.InlineKeyboardMarkup; import et.telebof.types.Poll; public class StopPoll extends AbstractBaseRequest { public StopPoll(Object chatId, int messageId, RequestSender requestSender) { - super(chatId, requestSender, "stopPoll"); + super(chatId, requestSender, "stopPoll", Poll.class); add("message_id", messageId); } @@ -14,8 +13,4 @@ public StopPoll replyMarkup(InlineKeyboardMarkup replyMarkup) { return add("reply_markup", replyMarkup); } - @Override - public Poll exec() { - return Util.parse(requestSender.makeRequest(this), Poll.class); - } } diff --git a/src/main/java/et/telebof/requests/UnHideGeneralForumTopic.java b/src/main/java/et/telebof/requests/UnHideGeneralForumTopic.java index 5e9d621..ddc8302 100644 --- a/src/main/java/et/telebof/requests/UnHideGeneralForumTopic.java +++ b/src/main/java/et/telebof/requests/UnHideGeneralForumTopic.java @@ -5,9 +5,4 @@ public UnHideGeneralForumTopic(Object chatId, RequestSender requestSender) { super(chatId, requestSender, "unHideGeneralForumTopic"); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/UnbanChatMember.java b/src/main/java/et/telebof/requests/UnbanChatMember.java index 7ee3b6b..33cc978 100644 --- a/src/main/java/et/telebof/requests/UnbanChatMember.java +++ b/src/main/java/et/telebof/requests/UnbanChatMember.java @@ -10,9 +10,4 @@ public UnbanChatMember onlyIfBanned(boolean onlyIfBanned){ return add("only_if_banned", onlyIfBanned); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/UnbanChatSenderChat.java b/src/main/java/et/telebof/requests/UnbanChatSenderChat.java index 7bac13e..de69c4b 100644 --- a/src/main/java/et/telebof/requests/UnbanChatSenderChat.java +++ b/src/main/java/et/telebof/requests/UnbanChatSenderChat.java @@ -6,9 +6,4 @@ public UnbanChatSenderChat(Object chatId, long senderChatId, RequestSender reque add("sender_chat_id", senderChatId); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/UnpinAllChatMessages.java b/src/main/java/et/telebof/requests/UnpinAllChatMessages.java index dbdc1b7..064581f 100644 --- a/src/main/java/et/telebof/requests/UnpinAllChatMessages.java +++ b/src/main/java/et/telebof/requests/UnpinAllChatMessages.java @@ -5,9 +5,4 @@ public UnpinAllChatMessages(Object chatId, RequestSender requestSender) { super(chatId, requestSender, "unpinAllChatMessages"); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/UnpinAllForumTopicMessages.java b/src/main/java/et/telebof/requests/UnpinAllForumTopicMessages.java index db4c0dd..19fc432 100644 --- a/src/main/java/et/telebof/requests/UnpinAllForumTopicMessages.java +++ b/src/main/java/et/telebof/requests/UnpinAllForumTopicMessages.java @@ -6,9 +6,4 @@ public UnpinAllForumTopicMessages(Object chatId, int messageThreadId, RequestSen add("message_thread_id", messageThreadId); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/UnpinAllGeneralForumTopicMessages.java b/src/main/java/et/telebof/requests/UnpinAllGeneralForumTopicMessages.java index f20229f..b920c02 100644 --- a/src/main/java/et/telebof/requests/UnpinAllGeneralForumTopicMessages.java +++ b/src/main/java/et/telebof/requests/UnpinAllGeneralForumTopicMessages.java @@ -5,8 +5,4 @@ public UnpinAllGeneralForumTopicMessages(Object chat_id, RequestSender requestSe super(chat_id, requestSender, "unpinAllGeneralForumTopicMessages"); } - @Override - public Boolean exec() { - return (Boolean) requestSender.makeRequest(this); - } } diff --git a/src/main/java/et/telebof/requests/UnpinChatMessage.java b/src/main/java/et/telebof/requests/UnpinChatMessage.java index 855b095..9630fcb 100644 --- a/src/main/java/et/telebof/requests/UnpinChatMessage.java +++ b/src/main/java/et/telebof/requests/UnpinChatMessage.java @@ -9,9 +9,4 @@ public UnpinChatMessage messageId(int messageId) { return add("message_id", messageId); } - @Override - public Boolean exec() { - Object response = requestSender.makeRequest(this); - return (Boolean) response; - } } diff --git a/src/main/java/et/telebof/requests/UploadStickerFile.java b/src/main/java/et/telebof/requests/UploadStickerFile.java index cfdfa2b..6a4b961 100644 --- a/src/main/java/et/telebof/requests/UploadStickerFile.java +++ b/src/main/java/et/telebof/requests/UploadStickerFile.java @@ -1,19 +1,14 @@ package et.telebof.requests; -import et.telebof.Util; import et.telebof.types.File; public class UploadStickerFile extends AbstractBaseRequest { public UploadStickerFile(long userId, java.io.File sticker, String stickerFormat, RequestSender requestSender) { - super(requestSender, "uploadStickerFile"); + super(requestSender, "uploadStickerFile", File.class); add("user_id", userId); add("sticker", sticker); add("sticker_format", stickerFormat); setContentType(MediaContentType.PHOTO); } - @Override - public File exec() { - return Util.parse(requestSender.makeRequest(this), File.class); - } } diff --git a/src/main/java/et/telebof/types/Animation.java b/src/main/java/et/telebof/types/Animation.java index 06577f0..1ed4789 100644 --- a/src/main/java/et/telebof/types/Animation.java +++ b/src/main/java/et/telebof/types/Animation.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class Animation implements Serializable { public String file_id, file_unique_id, file_name, mime_type; @@ -8,5 +9,21 @@ public class Animation implements Serializable { public Integer file_size; public PhotoSize thumbnail; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Animation animation = (Animation) object; + return Objects.equals(file_id, animation.file_id) && Objects.equals(file_unique_id, animation.file_unique_id) && + Objects.equals(file_name, animation.file_name) && Objects.equals(mime_type, animation.mime_type) && + Objects.equals(width, animation.width) && Objects.equals(height, animation.height) && + Objects.equals(duration, animation.duration) && Objects.equals(file_size, animation.file_size) && + Objects.equals(thumbnail, animation.thumbnail); + } + + @Override + public int hashCode() { + return Objects.hash(file_id, file_unique_id, file_name, mime_type, width, height, duration, file_size, thumbnail); + } } diff --git a/src/main/java/et/telebof/types/Audio.java b/src/main/java/et/telebof/types/Audio.java index fd0d378..cf3598c 100644 --- a/src/main/java/et/telebof/types/Audio.java +++ b/src/main/java/et/telebof/types/Audio.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class Audio implements Serializable { public String file_id, file_unique_id, performer, title, file_name, mime_type; @@ -8,4 +9,24 @@ public class Audio implements Serializable { public Integer file_size; public PhotoSize thumbnail; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Audio audio = (Audio) object; + return Objects.equals(file_id, audio.file_id) && + Objects.equals(file_unique_id, audio.file_unique_id) && + Objects.equals(performer, audio.performer) && + Objects.equals(title, audio.title) && + Objects.equals(file_name, audio.file_name) && + Objects.equals(mime_type, audio.mime_type) && + Objects.equals(duration, audio.duration) && + Objects.equals(file_size, audio.file_size) && + Objects.equals(thumbnail, audio.thumbnail); + } + + @Override + public int hashCode() { + return Objects.hash(file_id, file_unique_id, performer, title, file_name, mime_type, duration, file_size, thumbnail); + } } diff --git a/src/main/java/et/telebof/types/BackgroundFill.java b/src/main/java/et/telebof/types/BackgroundFill.java index e5f3300..3b97379 100644 --- a/src/main/java/et/telebof/types/BackgroundFill.java +++ b/src/main/java/et/telebof/types/BackgroundFill.java @@ -1,10 +1,28 @@ package et.telebof.types; import java.util.List; +import java.util.Objects; public class BackgroundFill { public String type; public Integer color, top_color, bottom_color, rotation_angle; public List colors; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + BackgroundFill that = (BackgroundFill) object; + return Objects.equals(type, that.type) && + Objects.equals(color, that.color) && + Objects.equals(top_color, that.top_color) && + Objects.equals(bottom_color, that.bottom_color) && + Objects.equals(rotation_angle, that.rotation_angle) && + Objects.equals(colors, that.colors); + } + + @Override + public int hashCode() { + return Objects.hash(type, color, top_color, bottom_color, rotation_angle, colors); + } } diff --git a/src/main/java/et/telebof/types/BackgroundType.java b/src/main/java/et/telebof/types/BackgroundType.java index da25bcd..e3db2cd 100644 --- a/src/main/java/et/telebof/types/BackgroundType.java +++ b/src/main/java/et/telebof/types/BackgroundType.java @@ -1,9 +1,32 @@ package et.telebof.types; +import java.util.Objects; + public class BackgroundType { public String type, theme_name; public BackgroundFill fill; public Integer dark_theme_dimming, intensity; public Document document; - Boolean is_blurred, is_moving, is_inverted; + public Boolean is_blurred, is_moving, is_inverted; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + BackgroundType that = (BackgroundType) object; + return Objects.equals(type, that.type) && + Objects.equals(theme_name, that.theme_name) && + Objects.equals(fill, that.fill) && + Objects.equals(dark_theme_dimming, that.dark_theme_dimming) && + Objects.equals(intensity, that.intensity) && + Objects.equals(document, that.document) && + Objects.equals(is_blurred, that.is_blurred) && + Objects.equals(is_moving, that.is_moving) && + Objects.equals(is_inverted, that.is_inverted); + } + + @Override + public int hashCode() { + return Objects.hash(type, theme_name, fill, dark_theme_dimming, intensity, document, is_blurred, is_moving, is_inverted); + } } diff --git a/src/main/java/et/telebof/types/BotDescription.java b/src/main/java/et/telebof/types/BotDescription.java index 974958f..6785714 100644 --- a/src/main/java/et/telebof/types/BotDescription.java +++ b/src/main/java/et/telebof/types/BotDescription.java @@ -1,6 +1,21 @@ package et.telebof.types; +import java.util.Objects; + public class BotDescription { public String description; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + BotDescription that = (BotDescription) object; + return Objects.equals(description, that.description); + } + + @Override + public int hashCode() { + return Objects.hash(description); + } } diff --git a/src/main/java/et/telebof/types/BotName.java b/src/main/java/et/telebof/types/BotName.java index 5a9986c..50ed2a7 100644 --- a/src/main/java/et/telebof/types/BotName.java +++ b/src/main/java/et/telebof/types/BotName.java @@ -1,6 +1,20 @@ package et.telebof.types; +import java.util.Objects; + public class BotName { public String name; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + BotName botName = (BotName) object; + return Objects.equals(name, botName.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } } diff --git a/src/main/java/et/telebof/types/BotShortDescription.java b/src/main/java/et/telebof/types/BotShortDescription.java index 0d74e8a..0b20158 100644 --- a/src/main/java/et/telebof/types/BotShortDescription.java +++ b/src/main/java/et/telebof/types/BotShortDescription.java @@ -1,6 +1,20 @@ package et.telebof.types; +import java.util.Objects; + public class BotShortDescription { public String short_description; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + BotShortDescription that = (BotShortDescription) object; + return Objects.equals(short_description, that.short_description); + } + + @Override + public int hashCode() { + return Objects.hash(short_description); + } } diff --git a/src/main/java/et/telebof/types/BusinessConnection.java b/src/main/java/et/telebof/types/BusinessConnection.java index 388a5f6..0ceb662 100644 --- a/src/main/java/et/telebof/types/BusinessConnection.java +++ b/src/main/java/et/telebof/types/BusinessConnection.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class BusinessConnection implements Serializable{ public String id; @@ -8,4 +9,33 @@ public class BusinessConnection implements Serializable{ public Long user_Chat_id; public Integer date; public Boolean can_reply, is_enabled; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + BusinessConnection that = (BusinessConnection) object; + return Objects.equals(id, that.id) && + Objects.equals(user, that.user) && + Objects.equals(user_Chat_id, that.user_Chat_id) && + Objects.equals(date, that.date) && Objects.equals(can_reply, that.can_reply) && + Objects.equals(is_enabled, that.is_enabled); + } + + @Override + public int hashCode() { + return Objects.hash(id, user, user_Chat_id, date, can_reply, is_enabled); + } + + @Override + public String toString() { + return "BusinessConnection{" + + "id='" + id + '\'' + + ", user=" + user + + ", user_Chat_id=" + user_Chat_id + + ", date=" + date + + ", can_reply=" + can_reply + + ", is_enabled=" + is_enabled + + '}'; + } } \ No newline at end of file diff --git a/src/main/java/et/telebof/types/BusinessIntro.java b/src/main/java/et/telebof/types/BusinessIntro.java index b6d2b3f..87e288c 100644 --- a/src/main/java/et/telebof/types/BusinessIntro.java +++ b/src/main/java/et/telebof/types/BusinessIntro.java @@ -1,8 +1,24 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class BusinessIntro implements Serializable { public String title, message; public Sticker sticker; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + BusinessIntro that = (BusinessIntro) object; + return Objects.equals(title, that.title) && + Objects.equals(message, that.message) && + Objects.equals(sticker, that.sticker); + } + + @Override + public int hashCode() { + return Objects.hash(title, message, sticker); + } } diff --git a/src/main/java/et/telebof/types/BusinessLocation.java b/src/main/java/et/telebof/types/BusinessLocation.java index 84dbdfd..a351327 100644 --- a/src/main/java/et/telebof/types/BusinessLocation.java +++ b/src/main/java/et/telebof/types/BusinessLocation.java @@ -1,8 +1,22 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class BusinessLocation implements Serializable { public String address; public Location location; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + BusinessLocation that = (BusinessLocation) object; + return Objects.equals(address, that.address) && Objects.equals(location, that.location); + } + + @Override + public int hashCode() { + return Objects.hash(address, location); + } } diff --git a/src/main/java/et/telebof/types/BusinessMessagesDeleted.java b/src/main/java/et/telebof/types/BusinessMessagesDeleted.java index ae1262b..9212ae7 100644 --- a/src/main/java/et/telebof/types/BusinessMessagesDeleted.java +++ b/src/main/java/et/telebof/types/BusinessMessagesDeleted.java @@ -2,9 +2,33 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class BusinessMessagesDeleted implements Serializable { public String business_connection_id; public Chat chat; public List message_ids; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + BusinessMessagesDeleted that = (BusinessMessagesDeleted) object; + return Objects.equals(business_connection_id, that.business_connection_id) && + Objects.equals(chat, that.chat) && Objects.equals(message_ids, that.message_ids); + } + + @Override + public int hashCode() { + return Objects.hash(business_connection_id, chat, message_ids); + } + + @Override + public String toString() { + return "BusinessMessagesDeleted{" + + "business_connection_id='" + business_connection_id + '\'' + + ", chat=" + chat + + ", message_ids=" + message_ids + + '}'; + } } diff --git a/src/main/java/et/telebof/types/BusinessOpeningHours.java b/src/main/java/et/telebof/types/BusinessOpeningHours.java index 77474ab..fb2bf09 100644 --- a/src/main/java/et/telebof/types/BusinessOpeningHours.java +++ b/src/main/java/et/telebof/types/BusinessOpeningHours.java @@ -2,8 +2,22 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class BusinessOpeningHours implements Serializable { public String time_zone_name; public List opening_hours; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + BusinessOpeningHours that = (BusinessOpeningHours) object; + return Objects.equals(time_zone_name, that.time_zone_name) && Objects.equals(opening_hours, that.opening_hours); + } + + @Override + public int hashCode() { + return Objects.hash(time_zone_name, opening_hours); + } } diff --git a/src/main/java/et/telebof/types/BusinessOpeningHoursInterval.java b/src/main/java/et/telebof/types/BusinessOpeningHoursInterval.java index 2d66ac7..f1e9e4b 100644 --- a/src/main/java/et/telebof/types/BusinessOpeningHoursInterval.java +++ b/src/main/java/et/telebof/types/BusinessOpeningHoursInterval.java @@ -1,7 +1,21 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class BusinessOpeningHoursInterval implements Serializable { public Integer opening_minute, closing_minute; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + BusinessOpeningHoursInterval that = (BusinessOpeningHoursInterval) object; + return Objects.equals(opening_minute, that.opening_minute) && Objects.equals(closing_minute, that.closing_minute); + } + + @Override + public int hashCode() { + return Objects.hash(opening_minute, closing_minute); + } } diff --git a/src/main/java/et/telebof/types/CallbackQuery.java b/src/main/java/et/telebof/types/CallbackQuery.java index 390c95f..42c97d4 100644 --- a/src/main/java/et/telebof/types/CallbackQuery.java +++ b/src/main/java/et/telebof/types/CallbackQuery.java @@ -1,10 +1,40 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class CallbackQuery extends JsonSerializable implements Serializable { +public class CallbackQuery implements Serializable { public String id, inline_message_id, chat_instance, data, game_short_name; public User from; public Message message; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + CallbackQuery that = (CallbackQuery) object; + return Objects.equals(id, that.id) && + Objects.equals(inline_message_id, that.inline_message_id) && + Objects.equals(chat_instance, that.chat_instance) && + Objects.equals(data, that.data) && Objects.equals(game_short_name, that.game_short_name) && + Objects.equals(from, that.from) && Objects.equals(message, that.message); + } + + @Override + public int hashCode() { + return Objects.hash(id, inline_message_id, chat_instance, data, game_short_name, from, message); + } + + @Override + public String toString() { + return "CallbackQuery{" + + "id='" + id + '\'' + + ", inline_message_id='" + inline_message_id + '\'' + + ", chat_instance='" + chat_instance + '\'' + + ", data='" + data + '\'' + + ", game_short_name='" + game_short_name + '\'' + + ", from=" + from + + ", message=" + message + + '}'; + } } diff --git a/src/main/java/et/telebof/types/Chat.java b/src/main/java/et/telebof/types/Chat.java index 529cb55..729ea0f 100644 --- a/src/main/java/et/telebof/types/Chat.java +++ b/src/main/java/et/telebof/types/Chat.java @@ -2,11 +2,41 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; -public class Chat extends JsonSerializable implements Serializable { - +public class Chat implements Serializable { public long id; public String type, title, username, first_name, last_name; public Boolean is_forum; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Chat chat = (Chat) object; + return id == chat.id && Objects.equals(type, chat.type) && + Objects.equals(title, chat.title) && + Objects.equals(username, chat.username) && + Objects.equals(first_name, chat.first_name) && + Objects.equals(last_name, chat.last_name) && + Objects.equals(is_forum, chat.is_forum); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, title, username, first_name, last_name, is_forum); + } + + @Override + public String toString() { + return "Chat{" + + "id=" + id + + ", type='" + type + '\'' + + ", title='" + title + '\'' + + ", username='" + username + '\'' + + ", first_name='" + first_name + '\'' + + ", last_name='" + last_name + '\'' + + ", is_forum=" + is_forum + + '}'; + } } diff --git a/src/main/java/et/telebof/types/ChatAdministratorRights.java b/src/main/java/et/telebof/types/ChatAdministratorRights.java index 5995cb3..c715e7f 100644 --- a/src/main/java/et/telebof/types/ChatAdministratorRights.java +++ b/src/main/java/et/telebof/types/ChatAdministratorRights.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ChatAdministratorRights implements Serializable { @@ -84,4 +85,32 @@ public ChatAdministratorRights canDeleteStories(boolean can_delete_stories){ return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatAdministratorRights that = (ChatAdministratorRights) object; + return Objects.equals(is_anonymous, that.is_anonymous) && + Objects.equals(can_manage_chat, that.can_manage_chat) && + Objects.equals(can_delete_messages, that.can_delete_messages) && + Objects.equals(can_manage_video_chats, that.can_manage_video_chats) && + Objects.equals(can_restrict_members, that.can_restrict_members) && + Objects.equals(can_promote_members, that.can_promote_members) && + Objects.equals(can_change_info, that.can_change_info) && + Objects.equals(can_invite_users, that.can_invite_users) && + Objects.equals(can_post_messages, that.can_post_messages) && + Objects.equals(can_edit_messages, that.can_edit_messages) && + Objects.equals(can_pin_messages, that.can_pin_messages) && + Objects.equals(can_manage_topics, that.can_manage_topics) && + Objects.equals(can_post_stories, that.can_post_stories) && + Objects.equals(can_edit_stories, that.can_edit_stories) && + Objects.equals(can_delete_stories, that.can_delete_stories); + } + + @Override + public int hashCode() { + return Objects.hash(is_anonymous, can_manage_chat, can_delete_messages, can_manage_video_chats, + can_restrict_members, can_promote_members, can_change_info, can_invite_users, can_post_messages, + can_edit_messages, can_pin_messages, can_manage_topics, can_post_stories, can_edit_stories, can_delete_stories); + } } diff --git a/src/main/java/et/telebof/types/ChatBackground.java b/src/main/java/et/telebof/types/ChatBackground.java index 823b236..b1ef680 100644 --- a/src/main/java/et/telebof/types/ChatBackground.java +++ b/src/main/java/et/telebof/types/ChatBackground.java @@ -1,5 +1,20 @@ package et.telebof.types; +import java.util.Objects; + public class ChatBackground { public BackgroundType type; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatBackground that = (ChatBackground) object; + return Objects.equals(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hash(type); + } } diff --git a/src/main/java/et/telebof/types/ChatBoost.java b/src/main/java/et/telebof/types/ChatBoost.java index 22dd550..82f9044 100644 --- a/src/main/java/et/telebof/types/ChatBoost.java +++ b/src/main/java/et/telebof/types/ChatBoost.java @@ -1,10 +1,27 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ChatBoost implements Serializable { public String boost_id; public Integer add_date; public Integer expiration_data; public ChatBoostSource source; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatBoost chatBoost = (ChatBoost) object; + return Objects.equals(boost_id, chatBoost.boost_id) && + Objects.equals(add_date, chatBoost.add_date) && + Objects.equals(expiration_data, chatBoost.expiration_data) && + Objects.equals(source, chatBoost.source); + } + + @Override + public int hashCode() { + return Objects.hash(boost_id, add_date, expiration_data, source); + } } diff --git a/src/main/java/et/telebof/types/ChatBoostAdded.java b/src/main/java/et/telebof/types/ChatBoostAdded.java index dec60c4..593d9ee 100644 --- a/src/main/java/et/telebof/types/ChatBoostAdded.java +++ b/src/main/java/et/telebof/types/ChatBoostAdded.java @@ -1,7 +1,28 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ChatBoostAdded implements Serializable{ public Integer boost_count; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatBoostAdded that = (ChatBoostAdded) object; + return Objects.equals(boost_count, that.boost_count); + } + + @Override + public int hashCode() { + return Objects.hash(boost_count); + } + + @Override + public String toString() { + return "ChatBoostAdded{" + + "boost_count=" + boost_count + + '}'; + } } diff --git a/src/main/java/et/telebof/types/ChatBoostRemoved.java b/src/main/java/et/telebof/types/ChatBoostRemoved.java index 472767d..b4ee0be 100644 --- a/src/main/java/et/telebof/types/ChatBoostRemoved.java +++ b/src/main/java/et/telebof/types/ChatBoostRemoved.java @@ -1,10 +1,37 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ChatBoostRemoved implements Serializable { public Chat chat; public String boost_id; public Integer removed_date; public ChatBoostSource source; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatBoostRemoved that = (ChatBoostRemoved) object; + return Objects.equals(chat, that.chat) && + Objects.equals(boost_id, that.boost_id) && + Objects.equals(removed_date, that.removed_date) && + Objects.equals(source, that.source); + } + + @Override + public int hashCode() { + return Objects.hash(chat, boost_id, removed_date, source); + } + + @Override + public String toString() { + return "ChatBoostRemoved{" + + "chat=" + chat + + ", boost_id='" + boost_id + '\'' + + ", removed_date=" + removed_date + + ", source=" + source + + '}'; + } } diff --git a/src/main/java/et/telebof/types/ChatBoostSource.java b/src/main/java/et/telebof/types/ChatBoostSource.java index 345e5a5..9cbe8ae 100644 --- a/src/main/java/et/telebof/types/ChatBoostSource.java +++ b/src/main/java/et/telebof/types/ChatBoostSource.java @@ -1,9 +1,24 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ChatBoostSource implements Serializable { public String source, giveaway_message_id; public User user; public Boolean is_unclaimed; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatBoostSource that = (ChatBoostSource) object; + return Objects.equals(source, that.source) && Objects.equals(giveaway_message_id, that.giveaway_message_id) + && Objects.equals(user, that.user) && Objects.equals(is_unclaimed, that.is_unclaimed); + } + + @Override + public int hashCode() { + return Objects.hash(source, giveaway_message_id, user, is_unclaimed); + } } diff --git a/src/main/java/et/telebof/types/ChatBoostUpdated.java b/src/main/java/et/telebof/types/ChatBoostUpdated.java index e434961..c7b50e4 100644 --- a/src/main/java/et/telebof/types/ChatBoostUpdated.java +++ b/src/main/java/et/telebof/types/ChatBoostUpdated.java @@ -1,8 +1,30 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ChatBoostUpdated implements Serializable { public Chat chat; public ChatBoost boost; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatBoostUpdated that = (ChatBoostUpdated) object; + return Objects.equals(chat, that.chat) && Objects.equals(boost, that.boost); + } + + @Override + public int hashCode() { + return Objects.hash(chat, boost); + } + + @Override + public String toString() { + return "ChatBoostUpdated{" + + "chat=" + chat + + ", boost=" + boost + + '}'; + } } diff --git a/src/main/java/et/telebof/types/ChatFullInfo.java b/src/main/java/et/telebof/types/ChatFullInfo.java index b61545d..bf8ddfa 100644 --- a/src/main/java/et/telebof/types/ChatFullInfo.java +++ b/src/main/java/et/telebof/types/ChatFullInfo.java @@ -1,8 +1,9 @@ package et.telebof.types; import java.util.List; +import java.util.Objects; -public class ChatFullInfo extends JsonSerializable{ +public class ChatFullInfo{ public long id; public String type, title, username, first_name, last_name; public Boolean is_forum; @@ -33,4 +34,114 @@ public class ChatFullInfo extends JsonSerializable{ public BusinessOpeningHours business_opening_hours; public Chat personal_chat; public Birthdate birthdate; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatFullInfo that = (ChatFullInfo) object; + return id == that.id && Objects.equals(type, that.type) && + Objects.equals(title, that.title) && + Objects.equals(username, that.username) && + Objects.equals(first_name, that.first_name) && + Objects.equals(last_name, that.last_name) && + Objects.equals(is_forum, that.is_forum) && + Objects.equals(photo, that.photo) && + Objects.equals(active_usernames, that.active_usernames) && + Objects.equals(emoji_status_custom_emoji_id, that.emoji_status_custom_emoji_id) && + Objects.equals(bio, that.bio) && Objects.equals(has_private_forwards, that.has_private_forwards) && + Objects.equals(has_restricted_voice_and_video_messages, that.has_restricted_voice_and_video_messages) && + Objects.equals(join_to_send_messages, that.join_to_send_messages) && + Objects.equals(join_by_request, that.join_by_request) && + Objects.equals(description, that.description) && + Objects.equals(invite_link, that.invite_link) && + Objects.equals(pinned_message, that.pinned_message) && + Objects.equals(permissions, that.permissions) && + Objects.equals(slow_mode_delay, that.slow_mode_delay) && + Objects.equals(message_auto_delete_time, that.message_auto_delete_time) && + Objects.equals(has_aggressive_anti_spam_enabled, that.has_aggressive_anti_spam_enabled) && + Objects.equals(has_hidden_members, that.has_hidden_members) && + Objects.equals(has_protected_content, that.has_protected_content) && + Objects.equals(sticker_set_name, that.sticker_set_name) && + Objects.equals(can_set_sticker_set, that.can_set_sticker_set) && + Objects.equals(linked_chat_id, that.linked_chat_id) && + Objects.equals(location, that.location) && + Objects.equals(emoji_status_expiration_date, that.emoji_status_expiration_date) && + Objects.equals(available_reactions, that.available_reactions) && + Objects.equals(has_visible_history, that.has_visible_history) && + Objects.equals(accent_color_id, that.accent_color_id) && + Objects.equals(max_reaction_count, that.max_reaction_count) && + Objects.equals(background_custom_emoji_id, that.background_custom_emoji_id) && + Objects.equals(profile_accent_color_id, that.profile_accent_color_id) && + Objects.equals(profile_background_custom_emoji_id, that.profile_background_custom_emoji_id) && + Objects.equals(unrestrict_boost_count, that.unrestrict_boost_count) && + Objects.equals(custom_emoji_sticker_set_name, that.custom_emoji_sticker_set_name) && + Objects.equals(business_intro, that.business_intro) && + Objects.equals(business_location, that.business_location) && + Objects.equals(business_opening_hours, that.business_opening_hours) && + Objects.equals(personal_chat, that.personal_chat) && + Objects.equals(birthdate, that.birthdate); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, title, username, first_name, last_name, is_forum, photo, active_usernames, + emoji_status_custom_emoji_id, bio, has_private_forwards, has_restricted_voice_and_video_messages, + join_to_send_messages, join_by_request, description, invite_link, pinned_message, permissions, + slow_mode_delay, message_auto_delete_time, has_aggressive_anti_spam_enabled, has_hidden_members, + has_protected_content, sticker_set_name, can_set_sticker_set, linked_chat_id, location, + emoji_status_expiration_date, available_reactions, has_visible_history, accent_color_id, + max_reaction_count, background_custom_emoji_id, profile_accent_color_id, profile_background_custom_emoji_id, + unrestrict_boost_count, custom_emoji_sticker_set_name, business_intro, business_location, + business_opening_hours, personal_chat, birthdate); + } + + @Override + public String toString() { + return "ChatFullInfo{" + + "id=" + id + + ", type='" + type + '\'' + + ", title='" + title + '\'' + + ", username='" + username + '\'' + + ", first_name='" + first_name + '\'' + + ", last_name='" + last_name + '\'' + + ", is_forum=" + is_forum + + ", photo=" + photo + + ", active_usernames=" + active_usernames + + ", emoji_status_custom_emoji_id='" + emoji_status_custom_emoji_id + '\'' + + ", bio='" + bio + '\'' + + ", has_private_forwards=" + has_private_forwards + + ", has_restricted_voice_and_video_messages=" + has_restricted_voice_and_video_messages + + ", join_to_send_messages=" + join_to_send_messages + + ", join_by_request=" + join_by_request + + ", description='" + description + '\'' + + ", invite_link='" + invite_link + '\'' + + ", pinned_message=" + pinned_message + + ", permissions=" + permissions + + ", slow_mode_delay=" + slow_mode_delay + + ", message_auto_delete_time=" + message_auto_delete_time + + ", has_aggressive_anti_spam_enabled=" + has_aggressive_anti_spam_enabled + + ", has_hidden_members=" + has_hidden_members + + ", has_protected_content=" + has_protected_content + + ", sticker_set_name='" + sticker_set_name + '\'' + + ", can_set_sticker_set=" + can_set_sticker_set + + ", linked_chat_id=" + linked_chat_id + + ", location=" + location + + ", emoji_status_expiration_date=" + emoji_status_expiration_date + + ", available_reactions=" + available_reactions + + ", has_visible_history=" + has_visible_history + + ", accent_color_id=" + accent_color_id + + ", max_reaction_count=" + max_reaction_count + + ", background_custom_emoji_id='" + background_custom_emoji_id + '\'' + + ", profile_accent_color_id=" + profile_accent_color_id + + ", profile_background_custom_emoji_id='" + profile_background_custom_emoji_id + '\'' + + ", unrestrict_boost_count=" + unrestrict_boost_count + + ", custom_emoji_sticker_set_name='" + custom_emoji_sticker_set_name + '\'' + + ", business_intro=" + business_intro + + ", business_location=" + business_location + + ", business_opening_hours=" + business_opening_hours + + ", personal_chat=" + personal_chat + + ", birthdate=" + birthdate + + '}'; + } } diff --git a/src/main/java/et/telebof/types/ChatInviteLink.java b/src/main/java/et/telebof/types/ChatInviteLink.java index cfcbe0f..18ad778 100644 --- a/src/main/java/et/telebof/types/ChatInviteLink.java +++ b/src/main/java/et/telebof/types/ChatInviteLink.java @@ -1,11 +1,31 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class ChatInviteLink extends JsonSerializable implements Serializable { +public class ChatInviteLink implements Serializable { public String invite_link, name; public User creator; public Integer expire_date, member_limit, pending_join_request_count; public Boolean is_primary, is_revoked, creates_join_request; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatInviteLink that = (ChatInviteLink) object; + return Objects.equals(invite_link, that.invite_link) && + Objects.equals(name, that.name) && Objects.equals(creator, that.creator) && + Objects.equals(expire_date, that.expire_date) && + Objects.equals(member_limit, that.member_limit) && + Objects.equals(pending_join_request_count, that.pending_join_request_count) && + Objects.equals(is_primary, that.is_primary) && Objects.equals(is_revoked, that.is_revoked) && + Objects.equals(creates_join_request, that.creates_join_request); + } + + @Override + public int hashCode() { + return Objects.hash(invite_link, name, creator, expire_date, member_limit, pending_join_request_count, + is_primary, is_revoked, creates_join_request); + } } diff --git a/src/main/java/et/telebof/types/ChatJoinRequest.java b/src/main/java/et/telebof/types/ChatJoinRequest.java index 76101b9..124ddaa 100644 --- a/src/main/java/et/telebof/types/ChatJoinRequest.java +++ b/src/main/java/et/telebof/types/ChatJoinRequest.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ChatJoinRequest implements Serializable { public Chat chat; @@ -9,4 +10,34 @@ public class ChatJoinRequest implements Serializable { public Integer date; public String bio; public ChatInviteLink invite_link; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatJoinRequest that = (ChatJoinRequest) object; + return Objects.equals(chat, that.chat) && + Objects.equals(from, that.from) && + Objects.equals(user_chat_id, that.user_chat_id) && + Objects.equals(date, that.date) && + Objects.equals(bio, that.bio) && + Objects.equals(invite_link, that.invite_link); + } + + @Override + public int hashCode() { + return Objects.hash(chat, from, user_chat_id, date, bio, invite_link); + } + + @Override + public String toString() { + return "ChatJoinRequest{" + + "chat=" + chat + + ", from=" + from + + ", user_chat_id=" + user_chat_id + + ", date=" + date + + ", bio='" + bio + '\'' + + ", invite_link=" + invite_link + + '}'; + } } diff --git a/src/main/java/et/telebof/types/ChatLocation.java b/src/main/java/et/telebof/types/ChatLocation.java index 4796977..65130f3 100644 --- a/src/main/java/et/telebof/types/ChatLocation.java +++ b/src/main/java/et/telebof/types/ChatLocation.java @@ -2,9 +2,22 @@ import java.io.Serializable; +import java.util.Objects; public class ChatLocation implements Serializable { public Location location; public String address; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatLocation that = (ChatLocation) object; + return Objects.equals(location, that.location) && Objects.equals(address, that.address); + } + + @Override + public int hashCode() { + return Objects.hash(location, address); + } } diff --git a/src/main/java/et/telebof/types/ChatMember.java b/src/main/java/et/telebof/types/ChatMember.java index 4f6a830..b9062c7 100644 --- a/src/main/java/et/telebof/types/ChatMember.java +++ b/src/main/java/et/telebof/types/ChatMember.java @@ -2,8 +2,9 @@ import java.io.Serializable; +import java.util.Objects; -public class ChatMember extends JsonSerializable implements Serializable { +public class ChatMember implements Serializable { public String status, custom_title; public User user; @@ -19,6 +20,54 @@ public class ChatMember extends JsonSerializable implements Serializable { public Integer until_date; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatMember that = (ChatMember) object; + return Objects.equals(status, that.status) && + Objects.equals(custom_title, that.custom_title) && + Objects.equals(user, that.user) && + Objects.equals(can_be_edited, that.can_be_edited) && + Objects.equals(is_anonymous, that.is_anonymous) && + Objects.equals(can_manage_chat, that.can_manage_chat) && + Objects.equals(can_delete_messages, that.can_delete_messages) && + Objects.equals(can_manage_video_chats, that.can_manage_video_chats) && + Objects.equals(can_restrict_members, that.can_restrict_members) && + Objects.equals(can_promote_members, that.can_promote_members) && + Objects.equals(can_change_info, that.can_change_info) && + Objects.equals(can_invite_users, that.can_invite_users) && + Objects.equals(can_post_messages, that.can_post_messages) && + Objects.equals(can_edit_messages, that.can_edit_messages) && + Objects.equals(can_pin_messages, that.can_pin_messages) && + Objects.equals(can_manage_topics, that.can_manage_topics) && + Objects.equals(is_member, that.is_member) && + Objects.equals(can_send_messages, that.can_send_messages) && + Objects.equals(can_send_audios, that.can_send_audios) && + Objects.equals(can_send_documents, that.can_send_documents) && + Objects.equals(can_send_photos, that.can_send_photos) && + Objects.equals(can_send_videos, that.can_send_videos) && + Objects.equals(can_send_video_notes, that.can_send_video_notes) && + Objects.equals(can_send_voice_votes, that.can_send_voice_votes) && + Objects.equals(can_send_polls, that.can_send_polls) && + Objects.equals(can_send_other_messages, that.can_send_other_messages) && + Objects.equals(can_add_web_page_previews, that.can_add_web_page_previews) && + Objects.equals(can_post_stories, that.can_post_stories) && + Objects.equals(can_edit_stories, that.can_edit_stories) && + Objects.equals(can_delete_stories, that.can_delete_stories) && + Objects.equals(until_date, that.until_date); + } + + @Override + public int hashCode() { + return Objects.hash(status, custom_title, user, can_be_edited, is_anonymous, can_manage_chat, + can_delete_messages, can_manage_video_chats, can_restrict_members, can_promote_members, + can_change_info, can_invite_users, can_post_messages, can_edit_messages, can_pin_messages, + can_manage_topics, is_member, can_send_messages, can_send_audios, can_send_documents, + can_send_photos, can_send_videos, can_send_video_notes, can_send_voice_votes, can_send_polls, + can_send_other_messages, can_add_web_page_previews, can_post_stories, can_edit_stories, + can_delete_stories, until_date); + } } diff --git a/src/main/java/et/telebof/types/ChatMemberUpdated.java b/src/main/java/et/telebof/types/ChatMemberUpdated.java index 48e7afe..4e5a917 100644 --- a/src/main/java/et/telebof/types/ChatMemberUpdated.java +++ b/src/main/java/et/telebof/types/ChatMemberUpdated.java @@ -1,5 +1,7 @@ package et.telebof.types; +import java.util.Objects; + public class ChatMemberUpdated { public Chat chat; public User from; @@ -8,4 +10,36 @@ public class ChatMemberUpdated { public ChatInviteLink invite_link; public Boolean via_chat_folder_invite_link, via_join_request; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatMemberUpdated that = (ChatMemberUpdated) object; + return Objects.equals(chat, that.chat) && Objects.equals(from, that.from) && + Objects.equals(date, that.date) && Objects.equals(old_chat_member, that.old_chat_member) && + Objects.equals(new_chat_member, that.new_chat_member) && + Objects.equals(invite_link, that.invite_link) && + Objects.equals(via_chat_folder_invite_link, that.via_chat_folder_invite_link) && + Objects.equals(via_join_request, that.via_join_request); + } + + @Override + public int hashCode() { + return Objects.hash(chat, from, date, old_chat_member, new_chat_member, invite_link, + via_chat_folder_invite_link, via_join_request); + } + + @Override + public String toString() { + return "ChatMemberUpdated{" + + "chat=" + chat + + ", from=" + from + + ", date=" + date + + ", old_chat_member=" + old_chat_member + + ", new_chat_member=" + new_chat_member + + ", invite_link=" + invite_link + + ", via_chat_folder_invite_link=" + via_chat_folder_invite_link + + ", via_join_request=" + via_join_request + + '}'; + } } diff --git a/src/main/java/et/telebof/types/ChatPermission.java b/src/main/java/et/telebof/types/ChatPermission.java index e24fb1c..97789c6 100644 --- a/src/main/java/et/telebof/types/ChatPermission.java +++ b/src/main/java/et/telebof/types/ChatPermission.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ChatPermission implements Serializable { @@ -77,4 +78,31 @@ public ChatPermission canManageTopics(boolean canManageTopics) { return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatPermission that = (ChatPermission) object; + return Objects.equals(can_send_messages, that.can_send_messages) && + Objects.equals(can_send_audios, that.can_send_audios) && + Objects.equals(can_send_documents, that.can_send_documents) && + Objects.equals(can_send_photos, that.can_send_photos) && + Objects.equals(can_send_videos, that.can_send_videos) && + Objects.equals(can_send_video_notes, that.can_send_video_notes) && + Objects.equals(can_send_voice_notes, that.can_send_voice_notes) && + Objects.equals(can_send_polls, that.can_send_polls) && + Objects.equals(can_send_other_messages, that.can_send_other_messages) && + Objects.equals(can_add_web_page_previews, that.can_add_web_page_previews) && + Objects.equals(can_change_info, that.can_change_info) && + Objects.equals(can_invite_users, that.can_invite_users) && + Objects.equals(can_pin_messages, that.can_pin_messages) && + Objects.equals(can_manage_topics, that.can_manage_topics); + } + + @Override + public int hashCode() { + return Objects.hash(can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, + can_send_video_notes, can_send_voice_notes, can_send_polls, can_send_other_messages, can_add_web_page_previews, + can_change_info, can_invite_users, can_pin_messages, can_manage_topics); + } } diff --git a/src/main/java/et/telebof/types/ChatPhoto.java b/src/main/java/et/telebof/types/ChatPhoto.java index 7f0cebc..b7b5a99 100644 --- a/src/main/java/et/telebof/types/ChatPhoto.java +++ b/src/main/java/et/telebof/types/ChatPhoto.java @@ -1,8 +1,24 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ChatPhoto implements Serializable { public String small_file_id, small_file_unique_id, big_file_id, big_file_unique_id; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatPhoto chatPhoto = (ChatPhoto) object; + return Objects.equals(small_file_id, chatPhoto.small_file_id) && + Objects.equals(small_file_unique_id, chatPhoto.small_file_unique_id) && + Objects.equals(big_file_id, chatPhoto.big_file_id) && + Objects.equals(big_file_unique_id, chatPhoto.big_file_unique_id); + } + + @Override + public int hashCode() { + return Objects.hash(small_file_id, small_file_unique_id, big_file_id, big_file_unique_id); + } } diff --git a/src/main/java/et/telebof/types/ChatShared.java b/src/main/java/et/telebof/types/ChatShared.java index 8ff5842..bd36673 100644 --- a/src/main/java/et/telebof/types/ChatShared.java +++ b/src/main/java/et/telebof/types/ChatShared.java @@ -2,10 +2,25 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; -public class ChatShared extends JsonSerializable implements Serializable { +public class ChatShared implements Serializable { public Integer request_id; public Long chat_id; public String title, username; public List photo; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChatShared that = (ChatShared) object; + return Objects.equals(request_id, that.request_id) && Objects.equals(chat_id, that.chat_id) && + Objects.equals(title, that.title) && Objects.equals(username, that.username) && Objects.equals(photo, that.photo); + } + + @Override + public int hashCode() { + return Objects.hash(request_id, chat_id, title, username, photo); + } } diff --git a/src/main/java/et/telebof/types/ChosenInlineResult.java b/src/main/java/et/telebof/types/ChosenInlineResult.java index c96f02e..31e364d 100644 --- a/src/main/java/et/telebof/types/ChosenInlineResult.java +++ b/src/main/java/et/telebof/types/ChosenInlineResult.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ChosenInlineResult implements Serializable { public String result_id; @@ -8,4 +9,29 @@ public class ChosenInlineResult implements Serializable { public Location location; public String inline_message_id, query; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ChosenInlineResult that = (ChosenInlineResult) object; + return Objects.equals(result_id, that.result_id) && Objects.equals(from, that.from) && + Objects.equals(location, that.location) && Objects.equals(inline_message_id, that.inline_message_id) && + Objects.equals(query, that.query); + } + + @Override + public int hashCode() { + return Objects.hash(result_id, from, location, inline_message_id, query); + } + + @Override + public String toString() { + return "ChosenInlineResult{" + + "result_id='" + result_id + '\'' + + ", from=" + from + + ", location=" + location + + ", inline_message_id='" + inline_message_id + '\'' + + ", query='" + query + '\'' + + '}'; + } } diff --git a/src/main/java/et/telebof/types/Contact.java b/src/main/java/et/telebof/types/Contact.java index 98f7838..3d4ed68 100644 --- a/src/main/java/et/telebof/types/Contact.java +++ b/src/main/java/et/telebof/types/Contact.java @@ -2,9 +2,24 @@ import java.io.Serializable; +import java.util.Objects; public class Contact implements Serializable { public String phone_number, first_name, last_name, vcard; public Long user_id; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Contact contact = (Contact) object; + return Objects.equals(phone_number, contact.phone_number) && Objects.equals(first_name, contact.first_name) && + Objects.equals(last_name, contact.last_name) && Objects.equals(vcard, contact.vcard) && + Objects.equals(user_id, contact.user_id); + } + + @Override + public int hashCode() { + return Objects.hash(phone_number, first_name, last_name, vcard, user_id); + } } diff --git a/src/main/java/et/telebof/types/Dice.java b/src/main/java/et/telebof/types/Dice.java index a83d3cb..a744197 100644 --- a/src/main/java/et/telebof/types/Dice.java +++ b/src/main/java/et/telebof/types/Dice.java @@ -1,9 +1,22 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class Dice implements Serializable { public String emoji; public Integer value; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Dice dice = (Dice) object; + return Objects.equals(emoji, dice.emoji) && Objects.equals(value, dice.value); + } + + @Override + public int hashCode() { + return Objects.hash(emoji, value); + } } diff --git a/src/main/java/et/telebof/types/Document.java b/src/main/java/et/telebof/types/Document.java index bac48bc..bf12d6a 100644 --- a/src/main/java/et/telebof/types/Document.java +++ b/src/main/java/et/telebof/types/Document.java @@ -2,9 +2,25 @@ import java.io.Serializable; +import java.util.Objects; public class Document implements Serializable { public String file_id, file_unique_id, file_name, mime_type; public Integer file_size; public PhotoSize thumbnail; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Document document = (Document) object; + return Objects.equals(file_id, document.file_id) && Objects.equals(file_unique_id, document.file_unique_id) && + Objects.equals(file_name, document.file_name) && Objects.equals(mime_type, document.mime_type) && + Objects.equals(file_size, document.file_size) && Objects.equals(thumbnail, document.thumbnail); + } + + @Override + public int hashCode() { + return Objects.hash(file_id, file_unique_id, file_name, mime_type, file_size, thumbnail); + } } diff --git a/src/main/java/et/telebof/types/EncryptedCredentials.java b/src/main/java/et/telebof/types/EncryptedCredentials.java index a2d41dd..1945ae4 100644 --- a/src/main/java/et/telebof/types/EncryptedCredentials.java +++ b/src/main/java/et/telebof/types/EncryptedCredentials.java @@ -1,8 +1,21 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class EncryptedCredentials implements Serializable { public String data, hash, secret; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + EncryptedCredentials that = (EncryptedCredentials) object; + return Objects.equals(data, that.data) && Objects.equals(hash, that.hash) && Objects.equals(secret, that.secret); + } + + @Override + public int hashCode() { + return Objects.hash(data, hash, secret); + } } diff --git a/src/main/java/et/telebof/types/EncryptedPassportElement.java b/src/main/java/et/telebof/types/EncryptedPassportElement.java index d0f7a0a..2de9175 100644 --- a/src/main/java/et/telebof/types/EncryptedPassportElement.java +++ b/src/main/java/et/telebof/types/EncryptedPassportElement.java @@ -2,12 +2,29 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; -public class EncryptedPassportElement extends JsonSerializable implements Serializable { +public class EncryptedPassportElement implements Serializable { public String type, data, phone_number, email; public List files; public PassportFile front_side, reverse_side, selfie; public List translation; public String hash; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + EncryptedPassportElement that = (EncryptedPassportElement) object; + return Objects.equals(type, that.type) && Objects.equals(data, that.data) && + Objects.equals(phone_number, that.phone_number) && Objects.equals(email, that.email) && + Objects.equals(files, that.files) && Objects.equals(front_side, that.front_side) && + Objects.equals(reverse_side, that.reverse_side) && Objects.equals(selfie, that.selfie) && + Objects.equals(translation, that.translation) && Objects.equals(hash, that.hash); + } + + @Override + public int hashCode() { + return Objects.hash(type, data, phone_number, email, files, front_side, reverse_side, selfie, translation, hash); + } } diff --git a/src/main/java/et/telebof/types/ExternalReplyInfo.java b/src/main/java/et/telebof/types/ExternalReplyInfo.java index f95679d..2f4366f 100644 --- a/src/main/java/et/telebof/types/ExternalReplyInfo.java +++ b/src/main/java/et/telebof/types/ExternalReplyInfo.java @@ -2,6 +2,7 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class ExternalReplyInfo implements Serializable { public MessageOrigin origin; @@ -26,5 +27,37 @@ public class ExternalReplyInfo implements Serializable { public Invoice invoice; public Boolean has_media_spoiler; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ExternalReplyInfo that = (ExternalReplyInfo) object; + return Objects.equals(origin, that.origin) && + Objects.equals(chat, that.chat) && + Objects.equals(message_id, that.message_id) && + Objects.equals(link_preview_options, that.link_preview_options) && + Objects.equals(animation, that.animation) && + Objects.equals(audio, that.audio) && + Objects.equals(document, that.document) && + Objects.equals(photo, that.photo) && + Objects.equals(sticker, that.sticker) && + Objects.equals(story, that.story) && + Objects.equals(video, that.video) && + Objects.equals(video_note, that.video_note) && + Objects.equals(voice, that.voice) && + Objects.equals(contact, that.contact) && + Objects.equals(dice, that.dice) && + Objects.equals(game, that.game) && + Objects.equals(poll, that.poll) && + Objects.equals(venue, that.venue) && + Objects.equals(location, that.location) && + Objects.equals(invoice, that.invoice) && + Objects.equals(has_media_spoiler, that.has_media_spoiler); + } + @Override + public int hashCode() { + return Objects.hash(origin, chat, message_id, link_preview_options, animation, audio, document, photo, sticker, + story, video, video_note, voice, contact, dice, game, poll, venue, location, invoice, has_media_spoiler); + } } diff --git a/src/main/java/et/telebof/types/File.java b/src/main/java/et/telebof/types/File.java index 8c0adc6..60b82e6 100644 --- a/src/main/java/et/telebof/types/File.java +++ b/src/main/java/et/telebof/types/File.java @@ -1,9 +1,23 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class File extends JsonSerializable implements Serializable { +public class File implements Serializable { public String file_id, file_unique_id, file_path; public Integer file_size; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + File file = (File) object; + return Objects.equals(file_id, file.file_id) && Objects.equals(file_unique_id, file.file_unique_id) && + Objects.equals(file_path, file.file_path) && Objects.equals(file_size, file.file_size); + } + + @Override + public int hashCode() { + return Objects.hash(file_id, file_unique_id, file_path, file_size); + } } diff --git a/src/main/java/et/telebof/types/ForceReply.java b/src/main/java/et/telebof/types/ForceReply.java index d34708a..b0a621b 100644 --- a/src/main/java/et/telebof/types/ForceReply.java +++ b/src/main/java/et/telebof/types/ForceReply.java @@ -3,6 +3,7 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import java.util.Objects; public class ForceReply implements Markup, Serializable { public final boolean force_reply; @@ -23,4 +24,18 @@ public ForceReply selective(boolean selective) { return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ForceReply that = (ForceReply) object; + return force_reply == that.force_reply && + Objects.equals(selective, that.selective) && + Objects.equals(input_field_placeholder, that.input_field_placeholder); + } + + @Override + public int hashCode() { + return Objects.hash(force_reply, selective, input_field_placeholder); + } } diff --git a/src/main/java/et/telebof/types/ForumTopic.java b/src/main/java/et/telebof/types/ForumTopic.java index 7b085b6..6cf77e3 100644 --- a/src/main/java/et/telebof/types/ForumTopic.java +++ b/src/main/java/et/telebof/types/ForumTopic.java @@ -1,7 +1,24 @@ package et.telebof.types; +import java.util.Objects; + public class ForumTopic { public Integer message_thread_id, icon_color; public String name, icon_custom_emoji_id; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ForumTopic that = (ForumTopic) object; + return Objects.equals(message_thread_id, that.message_thread_id) && + Objects.equals(icon_color, that.icon_color) && + Objects.equals(name, that.name) && + Objects.equals(icon_custom_emoji_id, that.icon_custom_emoji_id); + } + + @Override + public int hashCode() { + return Objects.hash(message_thread_id, icon_color, name, icon_custom_emoji_id); + } } diff --git a/src/main/java/et/telebof/types/ForumTopicClosed.java b/src/main/java/et/telebof/types/ForumTopicClosed.java index 926b12a..4454ff4 100644 --- a/src/main/java/et/telebof/types/ForumTopicClosed.java +++ b/src/main/java/et/telebof/types/ForumTopicClosed.java @@ -2,6 +2,6 @@ import java.io.Serializable; -public class ForumTopicClosed extends JsonSerializable implements Serializable { +public class ForumTopicClosed implements Serializable { // not implemented } diff --git a/src/main/java/et/telebof/types/ForumTopicCreated.java b/src/main/java/et/telebof/types/ForumTopicCreated.java index 187d423..ccb1a8c 100644 --- a/src/main/java/et/telebof/types/ForumTopicCreated.java +++ b/src/main/java/et/telebof/types/ForumTopicCreated.java @@ -1,10 +1,25 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class ForumTopicCreated extends JsonSerializable implements Serializable { +public class ForumTopicCreated implements Serializable { public String name, icon_custom_emoji_id; public Integer icon_color; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ForumTopicCreated that = (ForumTopicCreated) object; + return Objects.equals(name, that.name) && + Objects.equals(icon_custom_emoji_id, that.icon_custom_emoji_id) && + Objects.equals(icon_color, that.icon_color); + } + + @Override + public int hashCode() { + return Objects.hash(name, icon_custom_emoji_id, icon_color); + } } diff --git a/src/main/java/et/telebof/types/ForumTopicEdited.java b/src/main/java/et/telebof/types/ForumTopicEdited.java index e337aea..de0bb92 100644 --- a/src/main/java/et/telebof/types/ForumTopicEdited.java +++ b/src/main/java/et/telebof/types/ForumTopicEdited.java @@ -1,8 +1,22 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class ForumTopicEdited extends JsonSerializable implements Serializable { +public class ForumTopicEdited implements Serializable { public String name, icon_custom_emoji_id; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ForumTopicEdited that = (ForumTopicEdited) object; + return Objects.equals(name, that.name) && Objects.equals(icon_custom_emoji_id, that.icon_custom_emoji_id); + } + + @Override + public int hashCode() { + return Objects.hash(name, icon_custom_emoji_id); + } } diff --git a/src/main/java/et/telebof/types/ForumTopicReopened.java b/src/main/java/et/telebof/types/ForumTopicReopened.java index 0cd9763..b3c9110 100644 --- a/src/main/java/et/telebof/types/ForumTopicReopened.java +++ b/src/main/java/et/telebof/types/ForumTopicReopened.java @@ -2,6 +2,6 @@ import java.io.Serializable; -public class ForumTopicReopened extends JsonSerializable implements Serializable { +public class ForumTopicReopened implements Serializable { // not implemented } diff --git a/src/main/java/et/telebof/types/Game.java b/src/main/java/et/telebof/types/Game.java index 9a6f8e2..7dfb980 100644 --- a/src/main/java/et/telebof/types/Game.java +++ b/src/main/java/et/telebof/types/Game.java @@ -2,12 +2,27 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; -public class Game extends JsonSerializable implements Serializable { +public class Game implements Serializable { public String title, description; public List photo; public String text; public List text_entities; public Animation animation; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Game game = (Game) object; + return Objects.equals(title, game.title) && Objects.equals(description, game.description) && + Objects.equals(photo, game.photo) && Objects.equals(text, game.text) && + Objects.equals(text_entities, game.text_entities) && Objects.equals(animation, game.animation); + } + + @Override + public int hashCode() { + return Objects.hash(title, description, photo, text, text_entities, animation); + } } diff --git a/src/main/java/et/telebof/types/GameHighScore.java b/src/main/java/et/telebof/types/GameHighScore.java index 6ec038c..fc54d20 100644 --- a/src/main/java/et/telebof/types/GameHighScore.java +++ b/src/main/java/et/telebof/types/GameHighScore.java @@ -1,9 +1,22 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class GameHighScore implements Serializable { public Integer position, score; public User user; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + GameHighScore that = (GameHighScore) object; + return Objects.equals(position, that.position) && Objects.equals(score, that.score) && Objects.equals(user, that.user); + } + + @Override + public int hashCode() { + return Objects.hash(position, score, user); + } } diff --git a/src/main/java/et/telebof/types/GeneralForumTopicHidden.java b/src/main/java/et/telebof/types/GeneralForumTopicHidden.java index 6b4a5c7..62e31af 100644 --- a/src/main/java/et/telebof/types/GeneralForumTopicHidden.java +++ b/src/main/java/et/telebof/types/GeneralForumTopicHidden.java @@ -2,6 +2,6 @@ import java.io.Serializable; -public class GeneralForumTopicHidden extends JsonSerializable implements Serializable { +public class GeneralForumTopicHidden implements Serializable { // not implemented } diff --git a/src/main/java/et/telebof/types/GeneralForumTopicUnhidden.java b/src/main/java/et/telebof/types/GeneralForumTopicUnhidden.java index 2ed3f62..fa80ba8 100644 --- a/src/main/java/et/telebof/types/GeneralForumTopicUnhidden.java +++ b/src/main/java/et/telebof/types/GeneralForumTopicUnhidden.java @@ -2,6 +2,6 @@ import java.io.Serializable; -public class GeneralForumTopicUnhidden extends JsonSerializable implements Serializable { +public class GeneralForumTopicUnhidden implements Serializable { // not implemented } diff --git a/src/main/java/et/telebof/types/Giveaway.java b/src/main/java/et/telebof/types/Giveaway.java index 6e1d3d6..893479e 100644 --- a/src/main/java/et/telebof/types/Giveaway.java +++ b/src/main/java/et/telebof/types/Giveaway.java @@ -2,6 +2,7 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class Giveaway implements Serializable { public List chats; @@ -12,4 +13,22 @@ public class Giveaway implements Serializable { public List country_codes; public Integer premium_subscription_month_count; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Giveaway giveaway = (Giveaway) object; + return winners_selection_date == giveaway.winners_selection_date && winner_count == giveaway.winner_count && + Objects.equals(chats, giveaway.chats) && Objects.equals(only_new_members, giveaway.only_new_members) && + Objects.equals(has_public_winners, giveaway.has_public_winners) && + Objects.equals(prize_description, giveaway.prize_description) && + Objects.equals(country_codes, giveaway.country_codes) && + Objects.equals(premium_subscription_month_count, giveaway.premium_subscription_month_count); + } + + @Override + public int hashCode() { + return Objects.hash(chats, winners_selection_date, winner_count, only_new_members, has_public_winners, + prize_description, country_codes, premium_subscription_month_count); + } } diff --git a/src/main/java/et/telebof/types/GiveawayCompleted.java b/src/main/java/et/telebof/types/GiveawayCompleted.java index 0d79fcd..f1c33eb 100644 --- a/src/main/java/et/telebof/types/GiveawayCompleted.java +++ b/src/main/java/et/telebof/types/GiveawayCompleted.java @@ -1,7 +1,23 @@ package et.telebof.types; +import java.util.Objects; + public class GiveawayCompleted { public int winner_count; public Integer unclaimed_prize_count; public Message giveaway_message; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + GiveawayCompleted that = (GiveawayCompleted) object; + return winner_count == that.winner_count && Objects.equals(unclaimed_prize_count, that.unclaimed_prize_count) + && Objects.equals(giveaway_message, that.giveaway_message); + } + + @Override + public int hashCode() { + return Objects.hash(winner_count, unclaimed_prize_count, giveaway_message); + } } diff --git a/src/main/java/et/telebof/types/GiveawayWinners.java b/src/main/java/et/telebof/types/GiveawayWinners.java index e043791..0a54e6f 100644 --- a/src/main/java/et/telebof/types/GiveawayWinners.java +++ b/src/main/java/et/telebof/types/GiveawayWinners.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.util.List; +import java.util.Objects; public class GiveawayWinners { public Chat chat; @@ -11,4 +12,25 @@ public class GiveawayWinners { public Integer additional_chat_count, premium_subscription_month_count, unclaimed_prize_count; public Boolean only_new_members, was_refunded; public String prize_description; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + GiveawayWinners that = (GiveawayWinners) object; + return giveaway_message_id == that.giveaway_message_id && winners_selection_date == that.winners_selection_date + && winner_count == that.winner_count && Objects.equals(chat, that.chat) && + Objects.equals(winners, that.winners) && Objects.equals(additional_chat_count, that.additional_chat_count) && + Objects.equals(premium_subscription_month_count, that.premium_subscription_month_count) && + Objects.equals(unclaimed_prize_count, that.unclaimed_prize_count) && + Objects.equals(only_new_members, that.only_new_members) && Objects.equals(was_refunded, that.was_refunded) && + Objects.equals(prize_description, that.prize_description); + } + + @Override + public int hashCode() { + return Objects.hash(chat, giveaway_message_id, winners_selection_date, winner_count, winners, + additional_chat_count, premium_subscription_month_count, unclaimed_prize_count, only_new_members, + was_refunded, prize_description); + } } diff --git a/src/main/java/et/telebof/types/InlineKeyboardButton.java b/src/main/java/et/telebof/types/InlineKeyboardButton.java index 16a11ef..2b1ec57 100644 --- a/src/main/java/et/telebof/types/InlineKeyboardButton.java +++ b/src/main/java/et/telebof/types/InlineKeyboardButton.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class InlineKeyboardButton implements Serializable { public String text, url, callback_data, switch_inline_query_current_chat; @@ -53,4 +54,26 @@ public InlineKeyboardButton switchInlineQueryChosenChat(SwitchInlineQueryChosenC this.switch_inline_query_chosen_chat = chosenChat; return this; } + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + InlineKeyboardButton button = (InlineKeyboardButton) object; + return Objects.equals(text, button.text) && + Objects.equals(url, button.url) && + Objects.equals(callback_data, button.callback_data) && + Objects.equals(switch_inline_query_current_chat, button.switch_inline_query_current_chat) && + Objects.equals(wep_app, button.wep_app) && + Objects.equals(login_url, button.login_url) && + Objects.equals(pay, button.pay) && + Objects.equals(callback_game, button.callback_game) && + Objects.equals(switch_inline_query_chosen_chat, button.switch_inline_query_chosen_chat); + } + + @Override + public int hashCode() { + return Objects.hash(text, url, callback_data, switch_inline_query_current_chat, wep_app, login_url, pay, + callback_game, switch_inline_query_chosen_chat); + } } diff --git a/src/main/java/et/telebof/types/InlineQuery.java b/src/main/java/et/telebof/types/InlineQuery.java index a15b9e1..7b200a1 100644 --- a/src/main/java/et/telebof/types/InlineQuery.java +++ b/src/main/java/et/telebof/types/InlineQuery.java @@ -1,9 +1,40 @@ package et.telebof.types; -public class InlineQuery extends JsonSerializable { +import java.util.Objects; + +public class InlineQuery { public String id; public User from; public String query, offset, chat_type; public Location location; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + InlineQuery that = (InlineQuery) object; + return Objects.equals(id, that.id) && + Objects.equals(from, that.from) && + Objects.equals(query, that.query) && + Objects.equals(offset, that.offset) && + Objects.equals(chat_type, that.chat_type) && + Objects.equals(location, that.location); + } + + @Override + public int hashCode() { + return Objects.hash(id, from, query, offset, chat_type, location); + } + + @Override + public String toString() { + return "InlineQuery{" + + "id='" + id + '\'' + + ", from=" + from + + ", query='" + query + '\'' + + ", offset='" + offset + '\'' + + ", chat_type='" + chat_type + '\'' + + ", location=" + location + + '}'; + } } diff --git a/src/main/java/et/telebof/types/InlineQueryMediaResult.java b/src/main/java/et/telebof/types/InlineQueryMediaResult.java index 45fcb57..530436f 100644 --- a/src/main/java/et/telebof/types/InlineQueryMediaResult.java +++ b/src/main/java/et/telebof/types/InlineQueryMediaResult.java @@ -1,12 +1,14 @@ package et.telebof.types; import et.telebof.enums.ParseMode; +import org.jetbrains.annotations.NotNull; + import java.io.Serializable; import java.util.List; @SuppressWarnings("unchecked") class InlineQueryMediaResult implements Serializable, InlineQueryResult { - public String type, id, caption, thumbnail_url, parse_mode, title; + public String type, id, caption, parse_mode, title; public List caption_entities; public InputTextMessageContent input_message_content; public InlineKeyboardMarkup reply_markup; @@ -20,7 +22,6 @@ public T title(String title) { this.title = title; return thisT; } - public T inputMessageContent(InputTextMessageContent inputTextMessageContent) { this.input_message_content = inputTextMessageContent; return thisT; @@ -36,18 +37,14 @@ public T caption(String caption) { return thisT; } - public T thumbnailUrl(String thumbnailUrl) { - this.thumbnail_url = thumbnailUrl; - return thisT; - } public T captionEntities(MessageEntity[] captionEntities) { this.caption_entities = List.of(captionEntities); return thisT; } - public T parseMode(ParseMode parseMode) { - this.parse_mode = parseMode != null ? parseMode.name().toLowerCase() : null; + public T parseMode(@NotNull ParseMode parseMode) { + this.parse_mode = parseMode.name().toLowerCase(); return thisT; } diff --git a/src/main/java/et/telebof/types/InlineQueryResultArticle.java b/src/main/java/et/telebof/types/InlineQueryResultArticle.java index 567bb01..7341236 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultArticle.java +++ b/src/main/java/et/telebof/types/InlineQueryResultArticle.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class InlineQueryResultArticle implements Serializable, InlineQueryResult { private String id, type, url, description, thumbnail_url, title; @@ -59,5 +60,27 @@ public InlineQueryResultArticle thumbnailHeight(int thumbnailHeight) { return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + InlineQueryResultArticle article = (InlineQueryResultArticle) object; + return Objects.equals(id, article.id) && + Objects.equals(type, article.type) && + Objects.equals(url, article.url) && + Objects.equals(description, article.description) && + Objects.equals(thumbnail_url, article.thumbnail_url) && + Objects.equals(title, article.title) && + Objects.equals(thumbnail_width, article.thumbnail_width) && + Objects.equals(thumbnail_height, article.thumbnail_height) && + Objects.equals(input_message_content, article.input_message_content) && + Objects.equals(reply_markup, article.reply_markup) && + Objects.equals(hide_url, article.hide_url); + } + @Override + public int hashCode() { + return Objects.hash(id, type, url, description, thumbnail_url, title, thumbnail_width, + thumbnail_height, input_message_content, reply_markup, hide_url); + } } diff --git a/src/main/java/et/telebof/types/InlineQueryResultAudio.java b/src/main/java/et/telebof/types/InlineQueryResultAudio.java index e9462bb..517dab0 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultAudio.java +++ b/src/main/java/et/telebof/types/InlineQueryResultAudio.java @@ -2,17 +2,12 @@ import java.io.Serializable; -public class InlineQueryResultAudio implements Serializable, InlineQueryResult { +public class InlineQueryResultAudio extends InlineQueryMediaResult implements Serializable, InlineQueryResult { private String id, type, audio_url, performer; private Integer audio_duration; - public InlineQueryResultAudio(String id) { - this.type = "audio"; - this.id = id; - } - - public InlineQueryResultAudio audioUrl(String audioUrl) { - this.audio_url = audioUrl; - return this; + public InlineQueryResultAudio(String id, String audio_url) { + super(id, "audio"); + this.audio_url = audio_url; } public InlineQueryResultAudio performer(String performer) { diff --git a/src/main/java/et/telebof/types/InlineQueryResultCachedAudio.java b/src/main/java/et/telebof/types/InlineQueryResultCachedAudio.java index 3e86021..06ca4b8 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultCachedAudio.java +++ b/src/main/java/et/telebof/types/InlineQueryResultCachedAudio.java @@ -6,13 +6,9 @@ public class InlineQueryResultCachedAudio extends InlineQueryMediaResult implements Serializable { private String audio_file_id, description; - public InlineQueryResultCachedAudio(String id) { + public InlineQueryResultCachedAudio(String id, String audioFileId) { super("audio", id); - } - - public InlineQueryResultCachedAudio audioFileId(String audioFileId) { this.audio_file_id = audioFileId; - return this; } public InlineQueryResultCachedAudio description(String description) { @@ -20,10 +16,4 @@ public InlineQueryResultCachedAudio description(String description) { return this; } - @Override - @Deprecated(forRemoval = true) - public InlineQueryResultCachedAudio thumbnailUrl(String thumbnailUrl) { - BotLog.warn("type InlineQueryResultCachedAudio does not support thumbnailUrl option"); - return this; - } } diff --git a/src/main/java/et/telebof/types/InlineQueryResultCachedDocument.java b/src/main/java/et/telebof/types/InlineQueryResultCachedDocument.java index 6fdf883..aa0a755 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultCachedDocument.java +++ b/src/main/java/et/telebof/types/InlineQueryResultCachedDocument.java @@ -7,25 +7,13 @@ public class InlineQueryResultCachedDocument extends InlineQueryMediaResult implements Serializable { private String document_file_id, description; - public InlineQueryResultCachedDocument(String id) { + public InlineQueryResultCachedDocument(String id, String document_file_id) { super("document", id); - } - - public InlineQueryResultCachedDocument documentFileId(String documentFileId) { - this.document_file_id = documentFileId; - return this; + this.document_file_id = document_file_id; } public InlineQueryResultCachedDocument description(String description) { this.description = description; return this; } - - @Override - @Deprecated(forRemoval = true) - public InlineQueryResultCachedDocument thumbnailUrl(String thumbnailUrl) { - BotLog.warn("type InlineQueryResultCachedDocument does not support thumbnailUrl option"); - return this; - } - } diff --git a/src/main/java/et/telebof/types/InlineQueryResultCachedGif.java b/src/main/java/et/telebof/types/InlineQueryResultCachedGif.java index 49da212..3f37d15 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultCachedGif.java +++ b/src/main/java/et/telebof/types/InlineQueryResultCachedGif.java @@ -6,18 +6,14 @@ public class InlineQueryResultCachedGif extends InlineQueryMediaResult implements Serializable { private String gif_file_id; - public InlineQueryResultCachedGif(String id) { + private Boolean show_caption_above_media; + public InlineQueryResultCachedGif(String id, String gif_file_id) { super("gif", id); + this.gif_file_id = gif_file_id; } - public InlineQueryResultCachedGif gifFileId(String gifFileId) { - this.gif_file_id = gifFileId; - return this; - } - - @Deprecated(forRemoval = true) - public InlineQueryResultCachedGif thumbnailUrl(String thumbnailUrl) { - BotLog.warn("type InlineQueryResultCachedGif does not support thumbnailUrl option"); + public InlineQueryResultCachedGif showCaptionAboveMedia(boolean show_caption_above_media){ + this.show_caption_above_media = show_caption_above_media; return this; } diff --git a/src/main/java/et/telebof/types/InlineQueryResultCachedMpeg4Gif.java b/src/main/java/et/telebof/types/InlineQueryResultCachedMpeg4Gif.java index 6b472a5..018df90 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultCachedMpeg4Gif.java +++ b/src/main/java/et/telebof/types/InlineQueryResultCachedMpeg4Gif.java @@ -7,18 +7,15 @@ public class InlineQueryResultCachedMpeg4Gif extends InlineQueryMediaResult implements Serializable { private String mpeg4_file_id; - public InlineQueryResultCachedMpeg4Gif(String id) { + private Boolean show_caption_above_media; + public InlineQueryResultCachedMpeg4Gif(String id, String mpeg4_file_id) { super("mpeg4", id); + this.mpeg4_file_id = mpeg4_file_id; } - public InlineQueryResultCachedMpeg4Gif mpeg4FileId(String mpeg4FileId) { - this.mpeg4_file_id = mpeg4FileId; + public InlineQueryResultCachedMpeg4Gif showCaptionAboveMedia(boolean show_caption_above_media){ + this.show_caption_above_media = show_caption_above_media; return this; } - @Deprecated(forRemoval = true) - public InlineQueryResultCachedMpeg4Gif thumbnailUrl(String thumbnailUrl) { - BotLog.warn("type InlineQueryResultCachedMpeg4Gif does not support thumbnailUrl option"); - return this; - } } diff --git a/src/main/java/et/telebof/types/InlineQueryResultCachedPhoto.java b/src/main/java/et/telebof/types/InlineQueryResultCachedPhoto.java index f77916a..52e8733 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultCachedPhoto.java +++ b/src/main/java/et/telebof/types/InlineQueryResultCachedPhoto.java @@ -1,18 +1,13 @@ package et.telebof.types; -import et.telebof.BotLog; - import java.io.Serializable; public class InlineQueryResultCachedPhoto extends InlineQueryMediaResult implements Serializable { private String photo_file_id, description; - public InlineQueryResultCachedPhoto(String id) { + private Boolean show_caption_above_media; + public InlineQueryResultCachedPhoto(String id, String photo_file_id) { super("photo", id); - } - - public InlineQueryResultCachedPhoto photoFileId(String photoFileId) { - this.photo_file_id = photoFileId; - return this; + this.photo_file_id = photo_file_id; } public InlineQueryResultCachedPhoto description(String description) { @@ -20,9 +15,8 @@ public InlineQueryResultCachedPhoto description(String description) { return this; } - @Deprecated(forRemoval = true) - public InlineQueryResultCachedPhoto thumbnailUrl(String thumbnailUrl) { - BotLog.warn("InlineQueryResultCachedPhoto does not support thumbnailUrl option"); + public InlineQueryResultCachedPhoto showCaptionAboveMedia(boolean show_caption_above_media){ + this.show_caption_above_media = show_caption_above_media; return this; } } diff --git a/src/main/java/et/telebof/types/InlineQueryResultCachedSticker.java b/src/main/java/et/telebof/types/InlineQueryResultCachedSticker.java index 83929f9..896e236 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultCachedSticker.java +++ b/src/main/java/et/telebof/types/InlineQueryResultCachedSticker.java @@ -7,16 +7,11 @@ public class InlineQueryResultCachedSticker implements Serializable, InlineQuery private InputTextMessageContent input_message_content; private InlineKeyboardMarkup reply_markup; - public InlineQueryResultCachedSticker(String id) { + public InlineQueryResultCachedSticker(String id, String sticker_file_id) { this.type = "sticker"; this.id = id; + this.sticker_file_id = sticker_file_id; } - - public InlineQueryResultCachedSticker stickerFileId(String stickerFileId) { - this.sticker_file_id = stickerFileId; - return this; - } - public InlineQueryResultCachedSticker inputMessageContent(InputTextMessageContent inputTextMessageContent) { this.input_message_content = inputTextMessageContent; return this; diff --git a/src/main/java/et/telebof/types/InlineQueryResultCachedVideo.java b/src/main/java/et/telebof/types/InlineQueryResultCachedVideo.java index c256dda..8008a77 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultCachedVideo.java +++ b/src/main/java/et/telebof/types/InlineQueryResultCachedVideo.java @@ -7,14 +7,11 @@ public class InlineQueryResultCachedVideo extends InlineQueryMediaResult implements Serializable { private String video_file_id, description; + private Boolean show_caption_above_media; - public InlineQueryResultCachedVideo(String id) { + public InlineQueryResultCachedVideo(String id, String video_file_id) { super("video", id); - } - - public InlineQueryResultCachedVideo videoFileId(String videoFileId) { - this.video_file_id = videoFileId; - return this; + this.video_file_id = video_file_id; } public InlineQueryResultCachedVideo description(String description) { @@ -22,10 +19,8 @@ public InlineQueryResultCachedVideo description(String description) { return this; } - @Override - @Deprecated(forRemoval = true) - public InlineQueryResultCachedVideo thumbnailUrl(String thumbnailUrl) { - BotLog.warn("type InlineQueryResultCachedVideo does not support thumbnailUrl option"); + public InlineQueryResultCachedVideo showCaptionAboveMedia(boolean show_caption_above_media){ + this.show_caption_above_media = show_caption_above_media; return this; } } diff --git a/src/main/java/et/telebof/types/InlineQueryResultCachedVoice.java b/src/main/java/et/telebof/types/InlineQueryResultCachedVoice.java index 9fb41e0..8013df2 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultCachedVoice.java +++ b/src/main/java/et/telebof/types/InlineQueryResultCachedVoice.java @@ -7,24 +7,13 @@ public class InlineQueryResultCachedVoice extends InlineQueryMediaResult implements Serializable { private String voice_file_id, description; - public InlineQueryResultCachedVoice(String id) { + public InlineQueryResultCachedVoice(String id, String voiceFileId) { super("voice", id); - } - - public InlineQueryResultCachedVoice voiceFileId(String voiceFileId) { this.voice_file_id = voiceFileId; - return this; } public InlineQueryResultCachedVoice description(String description) { this.description = description; return this; } - - @Override - @Deprecated(forRemoval = true) - public InlineQueryResultCachedVoice thumbnailUrl(String thumbnailUrl) { - BotLog.warn("type InlineQueryResultCachedVoice does not support thumbnailUrl option"); - return this; - } } diff --git a/src/main/java/et/telebof/types/InlineQueryResultContact.java b/src/main/java/et/telebof/types/InlineQueryResultContact.java index 0c30854..2d679a9 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultContact.java +++ b/src/main/java/et/telebof/types/InlineQueryResultContact.java @@ -7,21 +7,12 @@ public class InlineQueryResultContact implements Serializable, InlineQueryResult private Integer thumbnail_width, thumbnail_height; private InlineKeyboardMarkup reply_markup; private InputTextMessageContent input_message_content; - public InlineQueryResultContact(String id) { + public InlineQueryResultContact(String id, String phone_number, String first_name) { this.type = "contact"; this.id = id; + this.phone_number = phone_number; + this.first_name = first_name; } - - public InlineQueryResultContact phoneNumber(String phoneNumber) { - this.phone_number = phoneNumber; - return this; - } - - public InlineQueryResultContact firstName(String firstName) { - this.first_name = firstName; - return this; - } - public InlineQueryResultContact lastName(String lastName) { this.last_name = lastName; return this; diff --git a/src/main/java/et/telebof/types/InlineQueryResultDocument.java b/src/main/java/et/telebof/types/InlineQueryResultDocument.java index 582c321..6b8a152 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultDocument.java +++ b/src/main/java/et/telebof/types/InlineQueryResultDocument.java @@ -1,13 +1,18 @@ package et.telebof.types; +import et.telebof.enums.MimeType; +import et.telebof.requests.MediaContentType; + import java.io.Serializable; public class InlineQueryResultDocument extends InlineQueryMediaResult implements Serializable { private String document_url, document, description, mime_type; private Integer thumbnail_width, thumbnail_height; - public InlineQueryResultDocument(String id) { + public InlineQueryResultDocument(String id, String document_url, MimeType mimeType) { super("document", id); + this.document_url = document_url; + this.mime_type = String.format("application/%s", mimeType.name().toLowerCase()); } public InlineQueryResultDocument documentUrl(String documentUrl) { @@ -30,8 +35,4 @@ public InlineQueryResultDocument description(String description) { return this; } - public InlineQueryResultDocument mimeType(String mimeType) { - this.mime_type = mimeType; - return this; - } } diff --git a/src/main/java/et/telebof/types/InlineQueryResultGame.java b/src/main/java/et/telebof/types/InlineQueryResultGame.java index 301763a..5ec3a87 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultGame.java +++ b/src/main/java/et/telebof/types/InlineQueryResultGame.java @@ -5,16 +5,11 @@ public class InlineQueryResultGame implements Serializable, InlineQueryResult { private String id, type, game_short_name; private InlineKeyboardMarkup reply_markup; - public InlineQueryResultGame(String id) { + public InlineQueryResultGame(String id, String game_short_name) { this.type = "game"; this.id = id; + this.game_short_name = game_short_name; } - - public InlineQueryResultGame gameShortName(String gameShortName) { - this.game_short_name = gameShortName; - return this; - } - public InlineQueryResultGame replyMarkup(InlineKeyboardMarkup keyboard) { this.reply_markup = keyboard; return this; diff --git a/src/main/java/et/telebof/types/InlineQueryResultGif.java b/src/main/java/et/telebof/types/InlineQueryResultGif.java index 8826b33..b700757 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultGif.java +++ b/src/main/java/et/telebof/types/InlineQueryResultGif.java @@ -4,18 +4,36 @@ public class InlineQueryResultGif extends InlineQueryMediaResult implements Serializable { private String gif_url, thumbnail_mime_type; - private Integer gif_width; - public InlineQueryResultGif(String id) { + private Integer gif_width, gif_height, gif_duration; + private Boolean show_caption_above_media; + private String thumbnail_url; + + public InlineQueryResultGif(String id, String gif_url) { super("gif", id); + this.gif_url = gif_url; + } + public InlineQueryResultGif gifWidth(int gifWidth) { + this.gif_width = gifWidth; + return this; } - public InlineQueryResultGif gifUrl(String gifUrl) { - this.gif_url = gifUrl; + public InlineQueryResultGif gifHeight(int gif_height) { + this.gif_height = gif_height; return this; } - public InlineQueryResultGif gifWidth(int gifWidth) { - this.gif_width = gifWidth; + public InlineQueryResultGif gifDuration(int gif_duration) { + this.gif_duration = gif_duration; + return this; + } + + public InlineQueryResultGif thumbnailUrl(String thumbnailUrl) { + this.thumbnail_url = thumbnailUrl; + return this; + } + + public InlineQueryResultGif showCaptionAboveMedia(boolean showCaptionAboveMedia){ + this.show_caption_above_media = showCaptionAboveMedia; return this; } diff --git a/src/main/java/et/telebof/types/InlineQueryResultLocation.java b/src/main/java/et/telebof/types/InlineQueryResultLocation.java index 0568737..bc28f5e 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultLocation.java +++ b/src/main/java/et/telebof/types/InlineQueryResultLocation.java @@ -5,26 +5,18 @@ public class InlineQueryResultLocation implements Serializable, InlineQueryResult { private String id, type, location, thumbnail_url; private Integer live_period, heading, proximity_alert_radius, thumbnail_width, thumbnail_height; - private Float latitude, longitude, horizontal_accuracy; + private double latitude, longitude, horizontal_accuracy; private InputTextMessageContent input_message_content; private InlineKeyboardMarkup reply_markup; - public InlineQueryResultLocation(String id) { + public InlineQueryResultLocation(String id, double latitude, double longitude) { this.type = "location"; this.id = id; - } - - public InlineQueryResultLocation latitude(float latitude) { this.latitude = latitude; - return this; - } - - public InlineQueryResultLocation longitude(float longitude) { this.longitude = longitude; - return this; } - public InlineQueryResultLocation horizontalAccuracy(float horizontalAccuracy) { + public InlineQueryResultLocation horizontalAccuracy(double horizontalAccuracy) { this.horizontal_accuracy = horizontalAccuracy; return this; } diff --git a/src/main/java/et/telebof/types/InlineQueryResultMpeg4Gif.java b/src/main/java/et/telebof/types/InlineQueryResultMpeg4Gif.java index 2b4e44c..29d6df8 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultMpeg4Gif.java +++ b/src/main/java/et/telebof/types/InlineQueryResultMpeg4Gif.java @@ -5,14 +5,12 @@ public class InlineQueryResultMpeg4Gif extends InlineQueryMediaResult implements Serializable { private String mpeg4_url, thumbnail_mime_type; private Integer mpeg4_width, mpeg4_height, mpeg4_duration; + private Boolean show_caption_above_media; + private String thumbnail_url; - public InlineQueryResultMpeg4Gif(String id) { + public InlineQueryResultMpeg4Gif(String id, String mpeg4_url) { super("mpeg4_url", id); - } - - public InlineQueryResultMpeg4Gif mpeg4Url(String mpeg4Url) { - this.mpeg4_url = mpeg4Url; - return this; + this.mpeg4_url = mpeg4_url; } public InlineQueryResultMpeg4Gif mpeg4Width(int mpeg4Width) { @@ -30,9 +28,18 @@ public InlineQueryResultMpeg4Gif mpeg4Duration(int mpeg4Duration) { return this; } + public InlineQueryResultMpeg4Gif thumbnailUrl(String thumbnailUrl) { + this.thumbnail_url = thumbnailUrl; + return this; + } public InlineQueryResultMpeg4Gif thumbnailMimeType(String thumbnailMimeType) { this.thumbnail_mime_type = thumbnailMimeType; return this; } + public InlineQueryResultMpeg4Gif showCaptionAboveMedia(boolean showCaptionAboveMedia){ + this.show_caption_above_media = showCaptionAboveMedia; + return this; + } + } diff --git a/src/main/java/et/telebof/types/InlineQueryResultPhoto.java b/src/main/java/et/telebof/types/InlineQueryResultPhoto.java index 089e949..5f0daad 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultPhoto.java +++ b/src/main/java/et/telebof/types/InlineQueryResultPhoto.java @@ -3,18 +3,14 @@ import java.io.Serializable; public class InlineQueryResultPhoto extends InlineQueryMediaResult implements Serializable { - private String photo_url, description; + private String photo_url, description, thumbnail_url; private Integer photo_width, photo_height; - - public InlineQueryResultPhoto(String id) { + private Boolean show_caption_above_media; + public InlineQueryResultPhoto(String id, String photo_url, String thumbnail_url) { super("photo", id); + this.photo_url = photo_url; + this.thumbnail_url = thumbnail_url; } - - public InlineQueryResultPhoto photoUrl(String photoUrl) { - this.photo_url = photoUrl; - return this; - } - public InlineQueryResultPhoto photoWidth(int photoWidth) { this.photo_width = photoWidth; return this; @@ -25,6 +21,10 @@ public InlineQueryResultPhoto description(String description) { return this; } + public InlineQueryResultPhoto showCaptionAboveMedia(boolean showCaptionAboveMedia){ + this.show_caption_above_media = showCaptionAboveMedia; + return this; + } public InlineQueryResultPhoto photoHeight(int photoHeight) { this.photo_height = photoHeight; return this; diff --git a/src/main/java/et/telebof/types/InlineQueryResultVenue.java b/src/main/java/et/telebof/types/InlineQueryResultVenue.java index 5216847..dbd743a 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultVenue.java +++ b/src/main/java/et/telebof/types/InlineQueryResultVenue.java @@ -3,19 +3,23 @@ import java.io.Serializable; public class InlineQueryResultVenue implements Serializable, InlineQueryResult { - private String id, type, location, thumbnail_url, title, address, foursquare_id, foursquare_type, + private String id, type, thumbnail_url, title, address, foursquare_id, foursquare_type, google_place_id, google_place_type; private Integer thumbnail_width, thumbnail_height; - private Float latitude, longitude, horizontal_accuracy; + private double latitude, longitude, horizontal_accuracy; private InputTextMessageContent input_message_content; private InlineKeyboardMarkup reply_markup; - public InlineQueryResultVenue(String id) { + public InlineQueryResultVenue(String id, double latitude, double longitude, String address) { this.type = "venue"; this.id = id; + this.latitude = latitude; + this.longitude = longitude; + this.address = address; } - public InlineQueryResultVenue latitude(float latitude) { + + public InlineQueryResultVenue latitude(double latitude) { this.latitude = latitude; return this; } @@ -30,21 +34,11 @@ public InlineQueryResultVenue thumbnailHeight(int thumbnailHeight) { return this; } - public InlineQueryResultVenue longitude(float longitude) { - this.longitude = longitude; - return this; - } - public InlineQueryResultVenue title(String title) { this.title = title; return this; } - public InlineQueryResultVenue address(String address) { - this.address = address; - return this; - } - public InlineQueryResultVenue foursquareId(String foursquareId) { this.foursquare_id = foursquareId; return this; @@ -80,4 +74,6 @@ public InlineQueryResultVenue thumbnailUrl(String thumbnailUrl) { return this; } + + } diff --git a/src/main/java/et/telebof/types/InlineQueryResultVideo.java b/src/main/java/et/telebof/types/InlineQueryResultVideo.java index bcd5cec..47b0cc6 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultVideo.java +++ b/src/main/java/et/telebof/types/InlineQueryResultVideo.java @@ -3,17 +3,14 @@ import java.io.Serializable; public class InlineQueryResultVideo extends InlineQueryMediaResult implements Serializable { - private String video_url, description, mime_type; + private String video_url, description, mime_type, thumbnail_url; private Integer video_width, video_height, video_duration; + private Boolean show_caption_above_media; - - public InlineQueryResultVideo(String id) { + public InlineQueryResultVideo(String id, String video_url, String mime_type) { super("video", id); - } - - public InlineQueryResultVideo videoUrl(String videoUrl) { - this.video_url = videoUrl; - return this; + this.video_url = video_url; + this.mime_type = mime_type; } public InlineQueryResultVideo videoWidth(int videoWidth) { @@ -36,8 +33,13 @@ public InlineQueryResultVideo description(String description) { return this; } - public InlineQueryResultVideo mimeType(String mimeType) { - this.mime_type = mimeType; + public InlineQueryResultVideo thumbnailUrl(String thumbnailUrl) { + this.thumbnail_url = thumbnailUrl; + return this; + } + + public InlineQueryResultVideo showCaptionAboveMedia(boolean show_caption_above_media){ + this.show_caption_above_media = show_caption_above_media; return this; } } diff --git a/src/main/java/et/telebof/types/InlineQueryResultVoice.java b/src/main/java/et/telebof/types/InlineQueryResultVoice.java index bea3b11..00b1838 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultVoice.java +++ b/src/main/java/et/telebof/types/InlineQueryResultVoice.java @@ -5,15 +5,11 @@ public class InlineQueryResultVoice extends InlineQueryMediaResult implements Serializable { private String voice_url; private Integer voice_duration; - public InlineQueryResultVoice(String id) { - super("voice", id); - } - public InlineQueryResultVoice voiceUrl(String voiceUrl) { - this.voice_url = voiceUrl; - return this; + public InlineQueryResultVoice(String id, String voice_url) { + super("voice", id); + this.voice_url = voice_url; } - public InlineQueryResultVoice voiceDuration(int voiceDuration) { this.voice_duration = voiceDuration; return this; diff --git a/src/main/java/et/telebof/types/InlineQueryResultsButton.java b/src/main/java/et/telebof/types/InlineQueryResultsButton.java index 59cf906..1d5b2e5 100644 --- a/src/main/java/et/telebof/types/InlineQueryResultsButton.java +++ b/src/main/java/et/telebof/types/InlineQueryResultsButton.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class InlineQueryResultsButton implements Serializable { private String text, start_parameter; @@ -19,4 +20,19 @@ public InlineQueryResultsButton startParameter(String startParameter){ this.start_parameter = startParameter; return this; } + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + InlineQueryResultsButton that = (InlineQueryResultsButton) object; + return Objects.equals(text, that.text) && + Objects.equals(start_parameter, that.start_parameter) && + Objects.equals(web_app_info, that.web_app_info); + } + + @Override + public int hashCode() { + return Objects.hash(text, start_parameter, web_app_info); + } } diff --git a/src/main/java/et/telebof/types/InputContactMessageContent.java b/src/main/java/et/telebof/types/InputContactMessageContent.java index 00469dc..7953c00 100644 --- a/src/main/java/et/telebof/types/InputContactMessageContent.java +++ b/src/main/java/et/telebof/types/InputContactMessageContent.java @@ -6,16 +6,10 @@ public class InputContactMessageContent implements Serializable { private String phone_number, first_name, last_name, vcard; - public InputContactMessageContent phoneNumber(String phoneNumber) { - this.phone_number = phoneNumber; - return this; + public InputContactMessageContent(String phone_number, String first_name){ + this.phone_number = phone_number; + this.first_name = first_name; } - - public InputContactMessageContent firstName(String firstName) { - this.first_name = firstName; - return this; - } - public InputContactMessageContent lastName(String lastName) { this.last_name = lastName; return this; diff --git a/src/main/java/et/telebof/types/InputInvoiceMessageContent.java b/src/main/java/et/telebof/types/InputInvoiceMessageContent.java index 54a1b17..95ccf15 100644 --- a/src/main/java/et/telebof/types/InputInvoiceMessageContent.java +++ b/src/main/java/et/telebof/types/InputInvoiceMessageContent.java @@ -12,27 +12,19 @@ public class InputInvoiceMessageContent implements Serializable { private Boolean need_name, need_phone_number, need_email, is_flexible, send_phone_number_to_provider, need_shipping_address, send_email_to_provider; - - public InputInvoiceMessageContent title(String title) { + public InputInvoiceMessageContent(String title, String description, String payload, + String currency, LabeledPrice[] prices){ this.title = title; - return this; - } - - public InputInvoiceMessageContent payload(String payload) { + this.description = description; this.payload = payload; - return this; - } - - public InputInvoiceMessageContent currency(String currency) { this.currency = currency; - return this; + this.prices = List.of(prices); } - public InputInvoiceMessageContent prices(LabeledPrice[] prices) { - this.prices = List.of(prices); + public InputInvoiceMessageContent providerToken(String providerToken){ + this.provider_token = providerToken; return this; } - public InputInvoiceMessageContent maxTipAmount(int maxTipAmount) { this.max_tip_amount = maxTipAmount; return this; diff --git a/src/main/java/et/telebof/types/InputLocationMessageContent.java b/src/main/java/et/telebof/types/InputLocationMessageContent.java index fbb7bb2..b3fda21 100644 --- a/src/main/java/et/telebof/types/InputLocationMessageContent.java +++ b/src/main/java/et/telebof/types/InputLocationMessageContent.java @@ -3,20 +3,14 @@ import java.io.Serializable; public class InputLocationMessageContent implements Serializable { - private Float latitude, longitude, horizontal_accuracy; + private double latitude, longitude, horizontal_accuracy; private Integer live_period, heading, proximity_alert_radius; - public InputLocationMessageContent latitude(float latitude) { + public InputLocationMessageContent(double latitude, double longitude){ this.latitude = latitude; - return this; - } - - public InputLocationMessageContent longitude(float longitude) { this.longitude = longitude; - return this; } - - public InputLocationMessageContent horizontalAccuracy(float horizontalAccuracy) { + public InputLocationMessageContent horizontalAccuracy(double horizontalAccuracy) { this.horizontal_accuracy = horizontalAccuracy; return this; } diff --git a/src/main/java/et/telebof/types/InputPollOption.java b/src/main/java/et/telebof/types/InputPollOption.java index b05f1c1..6aa8d19 100644 --- a/src/main/java/et/telebof/types/InputPollOption.java +++ b/src/main/java/et/telebof/types/InputPollOption.java @@ -1,8 +1,42 @@ package et.telebof.types; +import et.telebof.enums.ParseMode; +import org.jetbrains.annotations.NotNull; + +import java.io.Serializable; import java.util.List; +import java.util.Objects; + +public class InputPollOption implements Serializable { + private String text, text_parse_mode; + private List text_entities; + + public InputPollOption(String text){ + this.text = text; + } + + public InputPollOption textParseMode(@NotNull ParseMode text_parse_mode){ + this.text_parse_mode = text_parse_mode.name().toLowerCase(); + return this; + } + + public InputPollOption textEntities(MessageEntity[] text_entities){ + this.text_entities = List.of(text_entities); + return this; + } + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + InputPollOption that = (InputPollOption) object; + return Objects.equals(text, that.text) && + Objects.equals(text_parse_mode, that.text_parse_mode) && + Objects.equals(text_entities, that.text_entities); + } -public class InputPollOption { - public String text, text_parse_mode; - public List text_entities; + @Override + public int hashCode() { + return Objects.hash(text, text_parse_mode, text_entities); + } } diff --git a/src/main/java/et/telebof/types/InputSticker.java b/src/main/java/et/telebof/types/InputSticker.java index 46ea653..b5c82db 100644 --- a/src/main/java/et/telebof/types/InputSticker.java +++ b/src/main/java/et/telebof/types/InputSticker.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.Serializable; import java.util.List; +import java.util.Objects; public class InputSticker implements InputMedia, Serializable { private String sticker, format; @@ -51,4 +52,18 @@ public InputFile getInputFile() { return null; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + InputSticker that = (InputSticker) object; + return Objects.equals(sticker, that.sticker) && Objects.equals(format, that.format) && + Objects.equals(emoji_list, that.emoji_list) && Objects.equals(keywords, that.keywords) && + Objects.equals(mask_position, that.mask_position) && Objects.equals(inputFile, that.inputFile); + } + + @Override + public int hashCode() { + return Objects.hash(sticker, format, emoji_list, keywords, mask_position, inputFile); + } } \ No newline at end of file diff --git a/src/main/java/et/telebof/types/InputTextMessageContent.java b/src/main/java/et/telebof/types/InputTextMessageContent.java index ad6d51d..31548f5 100644 --- a/src/main/java/et/telebof/types/InputTextMessageContent.java +++ b/src/main/java/et/telebof/types/InputTextMessageContent.java @@ -1,13 +1,15 @@ package et.telebof.types; import et.telebof.enums.ParseMode; +import org.jetbrains.annotations.NotNull; import java.io.Serializable; import java.util.List; +import java.util.Objects; public class InputTextMessageContent implements Serializable { private String message_text, parse_mode; - List entities; + private List entities; private Boolean disable_web_page_preview; private LinkPreviewOptions link_preview_options; @@ -15,8 +17,8 @@ public InputTextMessageContent(String text) { this.message_text = text; } - public InputTextMessageContent parseMode(ParseMode parseMode) { - this.parse_mode = parseMode != null? parseMode.name().toLowerCase() : null; + public InputTextMessageContent parseMode(@NotNull ParseMode parseMode) { + this.parse_mode = parseMode.name().toLowerCase(); return this; } @@ -35,4 +37,20 @@ public InputTextMessageContent linkPreviewOptions(LinkPreviewOptions linkPreview this.link_preview_options = linkPreviewOptions; return this; } + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + InputTextMessageContent that = (InputTextMessageContent) object; + return Objects.equals(message_text, that.message_text) && Objects.equals(parse_mode, that.parse_mode) && + Objects.equals(entities, that.entities) && + Objects.equals(disable_web_page_preview, that.disable_web_page_preview) && + Objects.equals(link_preview_options, that.link_preview_options); + } + + @Override + public int hashCode() { + return Objects.hash(message_text, parse_mode, entities, disable_web_page_preview, link_preview_options); + } } diff --git a/src/main/java/et/telebof/types/InputVenueMessageContent.java b/src/main/java/et/telebof/types/InputVenueMessageContent.java index 5b5d3fa..284d227 100644 --- a/src/main/java/et/telebof/types/InputVenueMessageContent.java +++ b/src/main/java/et/telebof/types/InputVenueMessageContent.java @@ -1,31 +1,18 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class InputVenueMessageContent implements InputMedia, Serializable { - private Float latitude, longitude; + private double latitude, longitude; private String address, title, foursquare_id, foursquare_type, google_place_id, google_place_type; - public InputVenueMessageContent latitude(float latitude) { + public InputVenueMessageContent(double latitude, double longitude, String title, String address){ this.latitude = latitude; - return this; - } - - public InputVenueMessageContent longitude(float longitude) { this.longitude = longitude; - return this; - } - - public InputVenueMessageContent title(String title) { - this.title = title; - return this; - } - - public InputVenueMessageContent address(String address) { this.title = title; - return this; + this.address = address; } - public InputVenueMessageContent foursquareId(String foursquareId) { this.foursquare_id = foursquareId; return this; @@ -55,4 +42,22 @@ public boolean isFile() { public InputFile getInputFile() { return null; } + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + InputVenueMessageContent that = (InputVenueMessageContent) object; + return Double.compare(latitude, that.latitude) == 0 && Double.compare(longitude, that.longitude) == 0 && + Objects.equals(address, that.address) && Objects.equals(title, that.title) && + Objects.equals(foursquare_id, that.foursquare_id) && + Objects.equals(foursquare_type, that.foursquare_type) && + Objects.equals(google_place_id, that.google_place_id) && + Objects.equals(google_place_type, that.google_place_type); + } + + @Override + public int hashCode() { + return Objects.hash(latitude, longitude, address, title, foursquare_id, foursquare_type, google_place_id, google_place_type); + } } diff --git a/src/main/java/et/telebof/types/Invoice.java b/src/main/java/et/telebof/types/Invoice.java index ec0a4e4..51d8590 100644 --- a/src/main/java/et/telebof/types/Invoice.java +++ b/src/main/java/et/telebof/types/Invoice.java @@ -1,9 +1,24 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class Invoice implements Serializable { public String title, description, start_parameter, currency; public Integer total_amount; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Invoice invoice = (Invoice) object; + return Objects.equals(title, invoice.title) && Objects.equals(description, invoice.description) && + Objects.equals(start_parameter, invoice.start_parameter) && Objects.equals(currency, invoice.currency) && + Objects.equals(total_amount, invoice.total_amount); + } + + @Override + public int hashCode() { + return Objects.hash(title, description, start_parameter, currency, total_amount); + } } diff --git a/src/main/java/et/telebof/types/JsonSerializable.java b/src/main/java/et/telebof/types/JsonSerializable.java deleted file mode 100644 index f08b86c..0000000 --- a/src/main/java/et/telebof/types/JsonSerializable.java +++ /dev/null @@ -1,27 +0,0 @@ -package et.telebof.types; - -abstract public class JsonSerializable { - - @Override - public final String toString() { - StringBuilder str = new StringBuilder(this.getClass().getSimpleName() + "={"); - int count = 0; - for (Object ob : getClass().getDeclaredFields()) { - int len = ob.toString().split(" ")[2].split("\\.").length; - String type = ob.toString().split(" ")[1]; - String obj = ob.toString().split(" ")[2].split("\\.")[len-1];{ - count++; - - String cm = count == this.getClass().getDeclaredFields().length ? "}" : ", "; - try { - Object ftr = (this.getClass().getDeclaredField(obj).get(this)); - if (type.equals("java.lang.String") && ftr != null) - ftr = String.format("%s", ftr); - str.append(String.format("%s", obj + ": " + ftr + cm)); - } catch (Exception ignored) {} - - } - } return str.toString().equals("{")?"{}": str.toString(); - } - -} diff --git a/src/main/java/et/telebof/types/KeyboardButton.java b/src/main/java/et/telebof/types/KeyboardButton.java index c98ed3f..b0b4f25 100644 --- a/src/main/java/et/telebof/types/KeyboardButton.java +++ b/src/main/java/et/telebof/types/KeyboardButton.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class KeyboardButton implements Serializable { private String text; @@ -45,4 +46,19 @@ public KeyboardButton webApp(WebAppInfo webApp) { return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + KeyboardButton that = (KeyboardButton) object; + return Objects.equals(text, that.text) && Objects.equals(request_users, that.request_users) && + Objects.equals(request_chat, that.request_chat) && Objects.equals(request_poll, that.request_poll) && + Objects.equals(request_contact, that.request_contact) && + Objects.equals(request_location, that.request_location) && Objects.equals(wep_app, that.wep_app); + } + + @Override + public int hashCode() { + return Objects.hash(text, request_users, request_chat, request_poll, request_contact, request_location, wep_app); + } } diff --git a/src/main/java/et/telebof/types/KeyboardButtonPollType.java b/src/main/java/et/telebof/types/KeyboardButtonPollType.java index eecf2a9..11da59f 100644 --- a/src/main/java/et/telebof/types/KeyboardButtonPollType.java +++ b/src/main/java/et/telebof/types/KeyboardButtonPollType.java @@ -1,13 +1,28 @@ package et.telebof.types; import et.telebof.enums.PollType; +import org.jetbrains.annotations.NotNull; + import java.io.Serializable; +import java.util.Objects; public class KeyboardButtonPollType implements Serializable { private String type; - public KeyboardButtonPollType(PollType type) { + public KeyboardButtonPollType(@NotNull PollType type) { this.type = type.name().toLowerCase(); } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + KeyboardButtonPollType that = (KeyboardButtonPollType) object; + return Objects.equals(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hash(type); + } } diff --git a/src/main/java/et/telebof/types/KeyboardButtonRequestChat.java b/src/main/java/et/telebof/types/KeyboardButtonRequestChat.java index 6943fcc..83c09d5 100644 --- a/src/main/java/et/telebof/types/KeyboardButtonRequestChat.java +++ b/src/main/java/et/telebof/types/KeyboardButtonRequestChat.java @@ -1,9 +1,10 @@ package et.telebof.types; import java.util.Map; +import java.util.Objects; import java.util.TreeMap; -public class KeyboardButtonRequestChat extends JsonSerializable { +public class KeyboardButtonRequestChat { private ChatAdministratorRights user_administrator_rights, bot_administrator_rights; private Boolean bot_is_member, chat_is_forum, chat_has_username, chat_is_created, chat_is_channel, request_name, request_title, request_username, request_photo; @@ -68,4 +69,24 @@ public KeyboardButtonRequestChat requestPhoto(boolean request_photo){ return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + KeyboardButtonRequestChat that = (KeyboardButtonRequestChat) object; + return Objects.equals(user_administrator_rights, that.user_administrator_rights) && + Objects.equals(bot_administrator_rights, that.bot_administrator_rights) && + Objects.equals(bot_is_member, that.bot_is_member) && Objects.equals(chat_is_forum, that.chat_is_forum) && + Objects.equals(chat_has_username, that.chat_has_username) && Objects.equals(chat_is_created, that.chat_is_created) && + Objects.equals(chat_is_channel, that.chat_is_channel) && Objects.equals(request_name, that.request_name) && + Objects.equals(request_title, that.request_title) && Objects.equals(request_username, that.request_username) && + Objects.equals(request_photo, that.request_photo) && Objects.equals(request_id, that.request_id); + } + + @Override + public int hashCode() { + return Objects.hash(user_administrator_rights, bot_administrator_rights, bot_is_member, chat_is_forum, + chat_has_username, chat_is_created, chat_is_channel, request_name, request_title, request_username, + request_photo, request_id); + } } diff --git a/src/main/java/et/telebof/types/KeyboardButtonRequestUsers.java b/src/main/java/et/telebof/types/KeyboardButtonRequestUsers.java index b76a787..02ce203 100644 --- a/src/main/java/et/telebof/types/KeyboardButtonRequestUsers.java +++ b/src/main/java/et/telebof/types/KeyboardButtonRequestUsers.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class KeyboardButtonRequestUsers implements Serializable { @@ -42,4 +43,19 @@ public KeyboardButtonRequestUsers requestPhoto(boolean request_photo){ return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + KeyboardButtonRequestUsers that = (KeyboardButtonRequestUsers) object; + return Objects.equals(request_id, that.request_id) && Objects.equals(user_is_bot, that.user_is_bot) && + Objects.equals(user_is_premium, that.user_is_premium) && Objects.equals(request_name, that.request_name) && + Objects.equals(request_username, that.request_username) && Objects.equals(request_photo, that.request_photo) && + Objects.equals(max_quantity, that.max_quantity); + } + + @Override + public int hashCode() { + return Objects.hash(request_id, user_is_bot, user_is_premium, request_name, request_username, request_photo, max_quantity); + } } diff --git a/src/main/java/et/telebof/types/LabeledPrice.java b/src/main/java/et/telebof/types/LabeledPrice.java index 48b7492..9e53c09 100644 --- a/src/main/java/et/telebof/types/LabeledPrice.java +++ b/src/main/java/et/telebof/types/LabeledPrice.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class LabeledPrice implements Serializable { @@ -11,4 +12,17 @@ public LabeledPrice(String label, int amount){ this.label = label; this.amount = amount; } + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + LabeledPrice that = (LabeledPrice) object; + return Objects.equals(label, that.label) && Objects.equals(amount, that.amount); + } + + @Override + public int hashCode() { + return Objects.hash(label, amount); + } } diff --git a/src/main/java/et/telebof/types/LinkPreviewOptions.java b/src/main/java/et/telebof/types/LinkPreviewOptions.java index c206162..4676b21 100644 --- a/src/main/java/et/telebof/types/LinkPreviewOptions.java +++ b/src/main/java/et/telebof/types/LinkPreviewOptions.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class LinkPreviewOptions implements Serializable { public Boolean is_disabled, prefer_small_media, prefer_large_media, show_above_text; @@ -31,4 +32,18 @@ public LinkPreviewOptions url(String url){ return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + LinkPreviewOptions that = (LinkPreviewOptions) object; + return Objects.equals(is_disabled, that.is_disabled) && Objects.equals(prefer_small_media, that.prefer_small_media) && + Objects.equals(prefer_large_media, that.prefer_large_media) && Objects.equals(show_above_text, that.show_above_text) && + Objects.equals(url, that.url); + } + + @Override + public int hashCode() { + return Objects.hash(is_disabled, prefer_small_media, prefer_large_media, show_above_text, url); + } } diff --git a/src/main/java/et/telebof/types/Location.java b/src/main/java/et/telebof/types/Location.java index 16cfb6b..555706d 100644 --- a/src/main/java/et/telebof/types/Location.java +++ b/src/main/java/et/telebof/types/Location.java @@ -1,9 +1,25 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class Location implements Serializable { - public Float longitude, latitude, horizontal_accuracy; + public Double longitude, latitude, horizontal_accuracy; public Integer live_period, heading, proximity_alert_radius; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Location location = (Location) object; + return Objects.equals(longitude, location.longitude) && Objects.equals(latitude, location.latitude) && + Objects.equals(horizontal_accuracy, location.horizontal_accuracy) && + Objects.equals(live_period, location.live_period) && Objects.equals(heading, location.heading) && + Objects.equals(proximity_alert_radius, location.proximity_alert_radius); + } + + @Override + public int hashCode() { + return Objects.hash(longitude, latitude, horizontal_accuracy, live_period, heading, proximity_alert_radius); + } } diff --git a/src/main/java/et/telebof/types/LoginUrl.java b/src/main/java/et/telebof/types/LoginUrl.java index af5d307..eb54503 100644 --- a/src/main/java/et/telebof/types/LoginUrl.java +++ b/src/main/java/et/telebof/types/LoginUrl.java @@ -1,13 +1,13 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class LoginUrl implements Serializable { public String url, forward_text, bot_username; public Boolean request_write_access; - public LoginUrl url(String url){ this.url = url; return this; @@ -28,4 +28,17 @@ public LoginUrl requestWriteAccess(boolean requestWriteAccess){ return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + LoginUrl loginUrl = (LoginUrl) object; + return Objects.equals(url, loginUrl.url) && Objects.equals(forward_text, loginUrl.forward_text) && + Objects.equals(bot_username, loginUrl.bot_username) && Objects.equals(request_write_access, loginUrl.request_write_access); + } + + @Override + public int hashCode() { + return Objects.hash(url, forward_text, bot_username, request_write_access); + } } diff --git a/src/main/java/et/telebof/types/MaskPosition.java b/src/main/java/et/telebof/types/MaskPosition.java index b14121a..2ebccee 100644 --- a/src/main/java/et/telebof/types/MaskPosition.java +++ b/src/main/java/et/telebof/types/MaskPosition.java @@ -1,30 +1,44 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class MaskPosition implements Serializable { public String point; - public Float x_shift, y_shift, scale; + public Double x_shift, y_shift, scale; public MaskPosition point(String point){ this.point = point; return this; } - public MaskPosition xShift(float xShift){ + public MaskPosition xShift(double xShift){ this.x_shift = xShift; return this; } - public MaskPosition yShift(float yShift){ + public MaskPosition yShift(double yShift){ this.y_shift = yShift; return this; } - public MaskPosition scale(float scale){ + public MaskPosition scale(double scale){ this.scale= scale; return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + MaskPosition that = (MaskPosition) object; + return Objects.equals(point, that.point) && Objects.equals(x_shift, that.x_shift) && + Objects.equals(y_shift, that.y_shift) && Objects.equals(scale, that.scale); + } + + @Override + public int hashCode() { + return Objects.hash(point, x_shift, y_shift, scale); + } } diff --git a/src/main/java/et/telebof/types/MenuButton.java b/src/main/java/et/telebof/types/MenuButton.java index 0d4d11a..e6723f3 100644 --- a/src/main/java/et/telebof/types/MenuButton.java +++ b/src/main/java/et/telebof/types/MenuButton.java @@ -1,13 +1,34 @@ package et.telebof.types; -import java.io.Serializable; +import et.telebof.enums.MenuButtonType; +import org.jetbrains.annotations.NotNull; +import java.io.Serializable; +import java.util.Objects; -abstract public class MenuButton implements Serializable { +public class MenuButton implements Serializable { public String type; + public WebAppInfo web_app; + + public MenuButton(@NotNull MenuButtonType type) { + this.type = type.name().toLowerCase(); + } - public MenuButton(String type) { - this.type = type; + public MenuButton webApp(WebAppInfo web_app) { + this.web_app = web_app; + return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + MenuButton that = (MenuButton) object; + return Objects.equals(type, that.type) && Objects.equals(web_app, that.web_app); + } + + @Override + public int hashCode() { + return Objects.hash(type, web_app); + } } diff --git a/src/main/java/et/telebof/types/MenuButtonCommands.java b/src/main/java/et/telebof/types/MenuButtonCommands.java deleted file mode 100644 index 9cabaa2..0000000 --- a/src/main/java/et/telebof/types/MenuButtonCommands.java +++ /dev/null @@ -1,9 +0,0 @@ -package et.telebof.types; - -import java.io.Serializable; - -public class MenuButtonCommands extends MenuButton implements Serializable { - public MenuButtonCommands() { - super("commands"); - } -} diff --git a/src/main/java/et/telebof/types/MenuButtonDefault.java b/src/main/java/et/telebof/types/MenuButtonDefault.java deleted file mode 100644 index 3a6e89d..0000000 --- a/src/main/java/et/telebof/types/MenuButtonDefault.java +++ /dev/null @@ -1,7 +0,0 @@ -package et.telebof.types; - -public class MenuButtonDefault extends MenuButton { - public MenuButtonDefault() { - super("default"); - } -} diff --git a/src/main/java/et/telebof/types/MenuButtonWebApp.java b/src/main/java/et/telebof/types/MenuButtonWebApp.java deleted file mode 100644 index 4f40efb..0000000 --- a/src/main/java/et/telebof/types/MenuButtonWebApp.java +++ /dev/null @@ -1,12 +0,0 @@ -package et.telebof.types; - -import java.io.Serializable; - -public class MenuButtonWebApp extends MenuButton implements Serializable { - public WebAppInfo web_app; - public MenuButtonWebApp(String text, WebAppInfo webApp) { - super("web_app"); - this.web_app = webApp; - - } -} diff --git a/src/main/java/et/telebof/types/Message.java b/src/main/java/et/telebof/types/Message.java index 428d642..fb67cce 100644 --- a/src/main/java/et/telebof/types/Message.java +++ b/src/main/java/et/telebof/types/Message.java @@ -2,12 +2,13 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; /** Message class. * @author Natanim Negash */ -public class Message extends JsonSerializable implements Serializable { +public class Message implements Serializable { public Integer message_id, message_thread_id, date, edit_date; public Long migrate_to_chat_id, migrate_from_chat_id; public String author_signature, text, caption, @@ -66,4 +67,191 @@ public class Message extends JsonSerializable implements Serializable { public Integer sender_boost_count; public Story reply_to_story; public ChatBackground chat_background_set; + public String effect_id; + public Boolean show_caption_above_media; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Message message = (Message) object; + return Objects.equals(message_id, message.message_id) && + Objects.equals(message_thread_id, message.message_thread_id) && + Objects.equals(date, message.date) && Objects.equals(edit_date, message.edit_date) && + Objects.equals(migrate_to_chat_id, message.migrate_to_chat_id) && + Objects.equals(migrate_from_chat_id, message.migrate_from_chat_id) && + Objects.equals(author_signature, message.author_signature) && Objects.equals(text, message.text) && + Objects.equals(caption, message.caption) && Objects.equals(new_chat_title, message.new_chat_title) && + Objects.equals(connected_website, message.connected_website) && + Objects.equals(media_group_id, message.media_group_id) && + Objects.equals(business_connection_id, message.business_connection_id) && + Objects.equals(from, message.from) && Objects.equals(via_bot, message.via_bot) && + Objects.equals(left_chat_member, message.left_chat_member) && + Objects.equals(sender_business_bot, message.sender_business_bot) && + Objects.equals(new_chat_members, message.new_chat_members) && + Objects.equals(sender_chat, message.sender_chat) && Objects.equals(chat, message.chat) && + Objects.equals(is_topic, message.is_topic) && + Objects.equals(is_topic_message, message.is_topic_message) && + Objects.equals(is_automatic_forward, message.is_automatic_forward) && + Objects.equals(has_protected_content, message.has_protected_content) && + Objects.equals(is_from_online, message.is_from_online) && + Objects.equals(has_media_spoiler, message.has_media_spoiler) && + Objects.equals(delete_chat_photo, message.delete_chat_photo) && + Objects.equals(group_chat_created, message.group_chat_created) && + Objects.equals(supergroup_chat_created, message.supergroup_chat_created) && + Objects.equals(channel_chat_created, message.channel_chat_created) && + Objects.equals(reply_to_message, message.reply_to_message) && + Objects.equals(pinned_message, message.pinned_message) && + Objects.equals(entities, message.entities) && + Objects.equals(caption_entities, message.caption_entities) && + Objects.equals(animation, message.animation) && Objects.equals(audio, message.audio) && + Objects.equals(document, message.document) && Objects.equals(photo, message.photo) && + Objects.equals(new_chat_photo, message.new_chat_photo) && Objects.equals(sticker, message.sticker) && + Objects.equals(video, message.video) && Objects.equals(video_note, message.video_note) && + Objects.equals(voice, message.voice) && Objects.equals(contact, message.contact) && + Objects.equals(dice, message.dice) && Objects.equals(game, message.game) && + Objects.equals(poll, message.poll) && Objects.equals(story, message.story) && + Objects.equals(venue, message.venue) && Objects.equals(location, message.location) && + Objects.equals(message_auto_delete_timer_changed, message.message_auto_delete_timer_changed) && + Objects.equals(invoice, message.invoice) && + Objects.equals(successful_payment, message.successful_payment) && + Objects.equals(users_shared, message.users_shared) && + Objects.equals(chat_shared, message.chat_shared) && + Objects.equals(write_access_allowed, message.write_access_allowed) && + Objects.equals(passport_data, message.passport_data) && + Objects.equals(proximity_alert_triggered, message.proximity_alert_triggered) && + Objects.equals(forum_topic_created, message.forum_topic_created) && + Objects.equals(forum_topic_edited, message.forum_topic_edited) && + Objects.equals(forum_topic_closed, message.forum_topic_closed) && + Objects.equals(forum_topic_reopened, message.forum_topic_reopened) && + Objects.equals(general_forum_topic_hidden, message.general_forum_topic_hidden) && + Objects.equals(general_forum_topic_unhidden, message.general_forum_topic_unhidden) && + Objects.equals(video_chat_scheduled, message.video_chat_scheduled) && + Objects.equals(video_chat_started, message.video_chat_started) && + Objects.equals(video_chat_ended, message.video_chat_ended) && + Objects.equals(video_chat_participants_invited, message.video_chat_participants_invited) && + Objects.equals(web_app_data, message.web_app_data) && + Objects.equals(reply_markup, message.reply_markup) && + Objects.equals(external_reply, message.external_reply) && + Objects.equals(quote, message.quote) && + Objects.equals(link_preview_options, message.link_preview_options) && + Objects.equals(giveaway, message.giveaway) && + Objects.equals(giveaway_created, message.giveaway_created) && + Objects.equals(giveaway_winners, message.giveaway_winners) && + Objects.equals(giveaway_completed, message.giveaway_completed) && + Objects.equals(forward_origin, message.forward_origin) && + Objects.equals(boost_added, message.boost_added) && + Objects.equals(sender_boost_count, message.sender_boost_count) && + Objects.equals(reply_to_story, message.reply_to_story) && + Objects.equals(chat_background_set, message.chat_background_set) && + Objects.equals(effect_id, message.effect_id) && + Objects.equals(show_caption_above_media, message.show_caption_above_media); + } + + @Override + public int hashCode() { + return Objects.hash(message_id, message_thread_id, date, edit_date, migrate_to_chat_id, migrate_from_chat_id, + author_signature, text, caption, new_chat_title, connected_website, media_group_id, business_connection_id, + from, via_bot, left_chat_member, sender_business_bot, new_chat_members, sender_chat, chat, is_topic, is_topic_message, + is_automatic_forward, has_protected_content, is_from_online, has_media_spoiler, delete_chat_photo, group_chat_created, + supergroup_chat_created, channel_chat_created, reply_to_message, pinned_message, entities, caption_entities, animation, + audio, document, photo, new_chat_photo, sticker, video, video_note, voice, contact, dice, game, poll, story, venue, + location, message_auto_delete_timer_changed, invoice, successful_payment, users_shared, chat_shared, write_access_allowed, + passport_data, proximity_alert_triggered, forum_topic_created, forum_topic_edited, forum_topic_closed, forum_topic_reopened, + general_forum_topic_hidden, general_forum_topic_unhidden, video_chat_scheduled, video_chat_started, video_chat_ended, + video_chat_participants_invited, web_app_data, reply_markup, external_reply, quote, link_preview_options, giveaway, + giveaway_created, giveaway_winners, giveaway_completed, forward_origin, boost_added, sender_boost_count, reply_to_story, + chat_background_set, effect_id, show_caption_above_media); + } + + + @Override + public String toString() { + return "Message{" + + "message_id=" + message_id + + ", message_thread_id=" + message_thread_id + + ", date=" + date + + ", edit_date=" + edit_date + + ", migrate_to_chat_id=" + migrate_to_chat_id + + ", migrate_from_chat_id=" + migrate_from_chat_id + + ", author_signature='" + author_signature + '\'' + + ", text='" + text + '\'' + + ", caption='" + caption + '\'' + + ", new_chat_title='" + new_chat_title + '\'' + + ", connected_website='" + connected_website + '\'' + + ", media_group_id='" + media_group_id + '\'' + + ", business_connection_id='" + business_connection_id + '\'' + + ", from=" + from + + ", via_bot=" + via_bot + + ", left_chat_member=" + left_chat_member + + ", sender_business_bot=" + sender_business_bot + + ", new_chat_members=" + new_chat_members + + ", sender_chat=" + sender_chat + + ", chat=" + chat + + ", is_topic=" + is_topic + + ", is_topic_message=" + is_topic_message + + ", is_automatic_forward=" + is_automatic_forward + + ", has_protected_content=" + has_protected_content + + ", is_from_online=" + is_from_online + + ", has_media_spoiler=" + has_media_spoiler + + ", delete_chat_photo=" + delete_chat_photo + + ", group_chat_created=" + group_chat_created + + ", supergroup_chat_created=" + supergroup_chat_created + + ", channel_chat_created=" + channel_chat_created + + ", reply_to_message=" + reply_to_message + + ", pinned_message=" + pinned_message + + ", entities=" + entities + + ", caption_entities=" + caption_entities + + ", animation=" + animation + + ", audio=" + audio + + ", document=" + document + + ", photo=" + photo + + ", new_chat_photo=" + new_chat_photo + + ", sticker=" + sticker + + ", video=" + video + + ", video_note=" + video_note + + ", voice=" + voice + + ", contact=" + contact + + ", dice=" + dice + + ", game=" + game + + ", poll=" + poll + + ", story=" + story + + ", venue=" + venue + + ", location=" + location + + ", message_auto_delete_timer_changed=" + message_auto_delete_timer_changed + + ", invoice=" + invoice + + ", successful_payment=" + successful_payment + + ", users_shared=" + users_shared + + ", chat_shared=" + chat_shared + + ", write_access_allowed=" + write_access_allowed + + ", passport_data=" + passport_data + + ", proximity_alert_triggered=" + proximity_alert_triggered + + ", forum_topic_created=" + forum_topic_created + + ", forum_topic_edited=" + forum_topic_edited + + ", forum_topic_closed=" + forum_topic_closed + + ", forum_topic_reopened=" + forum_topic_reopened + + ", general_forum_topic_hidden=" + general_forum_topic_hidden + + ", general_forum_topic_unhidden=" + general_forum_topic_unhidden + + ", video_chat_scheduled=" + video_chat_scheduled + + ", video_chat_started=" + video_chat_started + + ", video_chat_ended=" + video_chat_ended + + ", video_chat_participants_invited=" + video_chat_participants_invited + + ", web_app_data=" + web_app_data + + ", reply_markup=" + reply_markup + + ", external_reply=" + external_reply + + ", quote=" + quote + + ", link_preview_options=" + link_preview_options + + ", giveaway=" + giveaway + + ", giveaway_created=" + giveaway_created + + ", giveaway_winners=" + giveaway_winners + + ", giveaway_completed=" + giveaway_completed + + ", forward_origin=" + forward_origin + + ", boost_added=" + boost_added + + ", sender_boost_count=" + sender_boost_count + + ", reply_to_story=" + reply_to_story + + ", chat_background_set=" + chat_background_set + + ", effect_id='" + effect_id + '\'' + + ", show_caption_above_media=" + show_caption_above_media + + '}'; + } } diff --git a/src/main/java/et/telebof/types/MessageAutoDeleteTimerChanged.java b/src/main/java/et/telebof/types/MessageAutoDeleteTimerChanged.java index a2d2b55..4eadd38 100644 --- a/src/main/java/et/telebof/types/MessageAutoDeleteTimerChanged.java +++ b/src/main/java/et/telebof/types/MessageAutoDeleteTimerChanged.java @@ -1,6 +1,20 @@ package et.telebof.types; -public class MessageAutoDeleteTimerChanged extends JsonSerializable { +import java.util.Objects; + +public class MessageAutoDeleteTimerChanged { public Integer messageAutoDeleteTimerChanged; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + MessageAutoDeleteTimerChanged that = (MessageAutoDeleteTimerChanged) object; + return Objects.equals(messageAutoDeleteTimerChanged, that.messageAutoDeleteTimerChanged); + } + + @Override + public int hashCode() { + return Objects.hash(messageAutoDeleteTimerChanged); + } } diff --git a/src/main/java/et/telebof/types/MessageEntity.java b/src/main/java/et/telebof/types/MessageEntity.java index 0bdb94e..35d4a3f 100644 --- a/src/main/java/et/telebof/types/MessageEntity.java +++ b/src/main/java/et/telebof/types/MessageEntity.java @@ -2,6 +2,7 @@ import et.telebof.enums.EntityType; import java.io.Serializable; +import java.util.Objects; /** @@ -9,7 +10,7 @@ */ -public class MessageEntity extends JsonSerializable implements Serializable { +public class MessageEntity implements Serializable { public String url, language, type; public Integer offset, length; public User user; @@ -51,4 +52,19 @@ public MessageEntity customEmojiId(String customEmojiId) { return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + MessageEntity entity = (MessageEntity) object; + return Objects.equals(url, entity.url) && Objects.equals(language, entity.language) && + Objects.equals(type, entity.type) && Objects.equals(offset, entity.offset) && + Objects.equals(length, entity.length) && Objects.equals(user, entity.user) && + Objects.equals(custom_emoji_id, entity.custom_emoji_id); + } + + @Override + public int hashCode() { + return Objects.hash(url, language, type, offset, length, user, custom_emoji_id); + } } \ No newline at end of file diff --git a/src/main/java/et/telebof/types/MessageId.java b/src/main/java/et/telebof/types/MessageId.java index bb87fd0..cdbcc4b 100644 --- a/src/main/java/et/telebof/types/MessageId.java +++ b/src/main/java/et/telebof/types/MessageId.java @@ -1,5 +1,20 @@ package et.telebof.types; +import java.util.Objects; + public class MessageId { public Integer message_id; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + MessageId messageId = (MessageId) object; + return Objects.equals(message_id, messageId.message_id); + } + + @Override + public int hashCode() { + return Objects.hash(message_id); + } } diff --git a/src/main/java/et/telebof/types/MessageOrigin.java b/src/main/java/et/telebof/types/MessageOrigin.java index ecdb09c..37ac46c 100644 --- a/src/main/java/et/telebof/types/MessageOrigin.java +++ b/src/main/java/et/telebof/types/MessageOrigin.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class MessageOrigin implements Serializable { public String type; @@ -10,4 +11,19 @@ public class MessageOrigin implements Serializable { public Chat sender_chat; public String author_signature; public Integer message_id; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + MessageOrigin that = (MessageOrigin) object; + return Objects.equals(type, that.type) && Objects.equals(date, that.date) && Objects.equals(sender_user, that.sender_user) && + Objects.equals(sender_user_name, that.sender_user_name) && Objects.equals(sender_chat, that.sender_chat) && + Objects.equals(author_signature, that.author_signature) && Objects.equals(message_id, that.message_id); + } + + @Override + public int hashCode() { + return Objects.hash(type, date, sender_user, sender_user_name, sender_chat, author_signature, message_id); + } } diff --git a/src/main/java/et/telebof/types/MessageReactionCountUpdated.java b/src/main/java/et/telebof/types/MessageReactionCountUpdated.java index 1bcade6..7696c20 100644 --- a/src/main/java/et/telebof/types/MessageReactionCountUpdated.java +++ b/src/main/java/et/telebof/types/MessageReactionCountUpdated.java @@ -2,10 +2,35 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class MessageReactionCountUpdated implements Serializable { public Chat chat; public int message_id; public int date; public List reactions; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + MessageReactionCountUpdated that = (MessageReactionCountUpdated) object; + return message_id == that.message_id && date == that.date && Objects.equals(chat, that.chat) && + Objects.equals(reactions, that.reactions); + } + + @Override + public int hashCode() { + return Objects.hash(chat, message_id, date, reactions); + } + + @Override + public String toString() { + return "MessageReactionCountUpdated{" + + "chat=" + chat + + ", message_id=" + message_id + + ", date=" + date + + ", reactions=" + reactions + + '}'; + } } diff --git a/src/main/java/et/telebof/types/MessageReactionUpdated.java b/src/main/java/et/telebof/types/MessageReactionUpdated.java index c385fe4..ca2d48a 100644 --- a/src/main/java/et/telebof/types/MessageReactionUpdated.java +++ b/src/main/java/et/telebof/types/MessageReactionUpdated.java @@ -2,6 +2,7 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class MessageReactionUpdated implements Serializable { public Chat chat; @@ -11,4 +12,32 @@ public class MessageReactionUpdated implements Serializable { public int date; public List old_reaction; public List new_reaction; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + MessageReactionUpdated that = (MessageReactionUpdated) object; + return message_id == that.message_id && date == that.date && Objects.equals(chat, that.chat) && + Objects.equals(user, that.user) && Objects.equals(actor_chat, that.actor_chat) && + Objects.equals(old_reaction, that.old_reaction) && Objects.equals(new_reaction, that.new_reaction); + } + + @Override + public int hashCode() { + return Objects.hash(chat, message_id, user, actor_chat, date, old_reaction, new_reaction); + } + + @Override + public String toString() { + return "MessageReactionUpdated{" + + "chat=" + chat + + ", message_id=" + message_id + + ", user=" + user + + ", actor_chat=" + actor_chat + + ", date=" + date + + ", old_reaction=" + old_reaction + + ", new_reaction=" + new_reaction + + '}'; + } } diff --git a/src/main/java/et/telebof/types/OrderInfo.java b/src/main/java/et/telebof/types/OrderInfo.java index d94a4fd..8700abe 100644 --- a/src/main/java/et/telebof/types/OrderInfo.java +++ b/src/main/java/et/telebof/types/OrderInfo.java @@ -1,9 +1,23 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class OrderInfo extends JsonSerializable implements Serializable { +public class OrderInfo implements Serializable { public String name, phone_number, email; public ShippingAddress shipping_address; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + OrderInfo orderInfo = (OrderInfo) object; + return Objects.equals(name, orderInfo.name) && Objects.equals(phone_number, orderInfo.phone_number) && + Objects.equals(email, orderInfo.email) && Objects.equals(shipping_address, orderInfo.shipping_address); + } + + @Override + public int hashCode() { + return Objects.hash(name, phone_number, email, shipping_address); + } } diff --git a/src/main/java/et/telebof/types/PassportData.java b/src/main/java/et/telebof/types/PassportData.java index 1617e12..a3cf6a9 100644 --- a/src/main/java/et/telebof/types/PassportData.java +++ b/src/main/java/et/telebof/types/PassportData.java @@ -2,8 +2,22 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; -public class PassportData extends JsonSerializable implements Serializable { +public class PassportData implements Serializable { public List data; public EncryptedCredentials credentials; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + PassportData that = (PassportData) object; + return Objects.equals(data, that.data) && Objects.equals(credentials, that.credentials); + } + + @Override + public int hashCode() { + return Objects.hash(data, credentials); + } } diff --git a/src/main/java/et/telebof/types/PassportElementErrorUnspecified.java b/src/main/java/et/telebof/types/PassportElementErrorUnspecified.java index cf17e16..4c30fe3 100644 --- a/src/main/java/et/telebof/types/PassportElementErrorUnspecified.java +++ b/src/main/java/et/telebof/types/PassportElementErrorUnspecified.java @@ -1,9 +1,24 @@ package et.telebof.types; +import java.util.Objects; + public class PassportElementErrorUnspecified extends PassportElementError { private String element_hash; public PassportElementErrorUnspecified(String source, String type, String elementHash, String message) { super(source, type, message); this.element_hash = elementHash; } + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + PassportElementErrorUnspecified that = (PassportElementErrorUnspecified) object; + return Objects.equals(element_hash, that.element_hash); + } + + @Override + public int hashCode() { + return Objects.hash(element_hash); + } } diff --git a/src/main/java/et/telebof/types/PassportFile.java b/src/main/java/et/telebof/types/PassportFile.java index 22c69c9..35dc657 100644 --- a/src/main/java/et/telebof/types/PassportFile.java +++ b/src/main/java/et/telebof/types/PassportFile.java @@ -1,8 +1,23 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class PassportFile implements Serializable { public String file_id, file_unique_id; public Integer file_size, file_date; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + PassportFile that = (PassportFile) object; + return Objects.equals(file_id, that.file_id) && Objects.equals(file_unique_id, that.file_unique_id) && + Objects.equals(file_size, that.file_size) && Objects.equals(file_date, that.file_date); + } + + @Override + public int hashCode() { + return Objects.hash(file_id, file_unique_id, file_size, file_date); + } } diff --git a/src/main/java/et/telebof/types/PhotoSize.java b/src/main/java/et/telebof/types/PhotoSize.java index bb182c8..bc8de95 100644 --- a/src/main/java/et/telebof/types/PhotoSize.java +++ b/src/main/java/et/telebof/types/PhotoSize.java @@ -1,10 +1,36 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class PhotoSize implements Serializable { public String file_id, file_unique_id; public Integer width, height; public Integer file_size; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + PhotoSize photoSize = (PhotoSize) object; + return Objects.equals(file_id, photoSize.file_id) && Objects.equals(file_unique_id, photoSize.file_unique_id) && + Objects.equals(width, photoSize.width) && Objects.equals(height, photoSize.height) && + Objects.equals(file_size, photoSize.file_size); + } + + @Override + public int hashCode() { + return Objects.hash(file_id, file_unique_id, width, height, file_size); + } + + @Override + public String toString() { + return "PhotoSize{" + + "file_id='" + file_id + '\'' + + ", file_unique_id='" + file_unique_id + '\'' + + ", width=" + width + + ", height=" + height + + ", file_size=" + file_size + + '}'; + } } diff --git a/src/main/java/et/telebof/types/Poll.java b/src/main/java/et/telebof/types/Poll.java index a287311..153020e 100644 --- a/src/main/java/et/telebof/types/Poll.java +++ b/src/main/java/et/telebof/types/Poll.java @@ -2,12 +2,55 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; -public class Poll extends JsonSerializable implements Serializable { +public class Poll implements Serializable { public String id, question, type, explanation; public List options; public Integer total_voter_count, correct_option_id, open_period, close_date; public Boolean is_closed, is_anonymous, allows_multiple_answers; public List explanation_entities, question_entities; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Poll poll = (Poll) object; + return Objects.equals(id, poll.id) && Objects.equals(question, poll.question) && Objects.equals(type, poll.type) && + Objects.equals(explanation, poll.explanation) && Objects.equals(options, poll.options) && + Objects.equals(total_voter_count, poll.total_voter_count) && + Objects.equals(correct_option_id, poll.correct_option_id) && Objects.equals(open_period, poll.open_period) && + Objects.equals(close_date, poll.close_date) && Objects.equals(is_closed, poll.is_closed) && + Objects.equals(is_anonymous, poll.is_anonymous) && + Objects.equals(allows_multiple_answers, poll.allows_multiple_answers) && + Objects.equals(explanation_entities, poll.explanation_entities) && + Objects.equals(question_entities, poll.question_entities); + } + + @Override + public int hashCode() { + return Objects.hash(id, question, type, explanation, options, total_voter_count, correct_option_id, open_period, + close_date, is_closed, is_anonymous, allows_multiple_answers, explanation_entities, question_entities); + } + + + @Override + public String toString() { + return "Poll{" + + "id='" + id + '\'' + + ", question='" + question + '\'' + + ", type='" + type + '\'' + + ", explanation='" + explanation + '\'' + + ", options=" + options + + ", total_voter_count=" + total_voter_count + + ", correct_option_id=" + correct_option_id + + ", open_period=" + open_period + + ", close_date=" + close_date + + ", is_closed=" + is_closed + + ", is_anonymous=" + is_anonymous + + ", allows_multiple_answers=" + allows_multiple_answers + + ", explanation_entities=" + explanation_entities + + ", question_entities=" + question_entities + + '}'; + } } diff --git a/src/main/java/et/telebof/types/PollAnswer.java b/src/main/java/et/telebof/types/PollAnswer.java index b1c4ca5..d5714aa 100644 --- a/src/main/java/et/telebof/types/PollAnswer.java +++ b/src/main/java/et/telebof/types/PollAnswer.java @@ -2,6 +2,7 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class PollAnswer implements Serializable { public String poll_id; @@ -9,4 +10,27 @@ public class PollAnswer implements Serializable { public List options_id; public Chat voter_chat; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + PollAnswer that = (PollAnswer) object; + return Objects.equals(poll_id, that.poll_id) && Objects.equals(user, that.user) && + Objects.equals(options_id, that.options_id) && Objects.equals(voter_chat, that.voter_chat); + } + + @Override + public int hashCode() { + return Objects.hash(poll_id, user, options_id, voter_chat); + } + + @Override + public String toString() { + return "PollAnswer{" + + "poll_id='" + poll_id + '\'' + + ", user=" + user + + ", options_id=" + options_id + + ", voter_chat=" + voter_chat + + '}'; + } } diff --git a/src/main/java/et/telebof/types/PollOption.java b/src/main/java/et/telebof/types/PollOption.java index d104be4..5f09dd0 100644 --- a/src/main/java/et/telebof/types/PollOption.java +++ b/src/main/java/et/telebof/types/PollOption.java @@ -2,10 +2,24 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class PollOption implements Serializable { public String text; public Integer voter_count; public List text_entities; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + PollOption that = (PollOption) object; + return Objects.equals(text, that.text) && Objects.equals(voter_count, that.voter_count) && + Objects.equals(text_entities, that.text_entities); + } + + @Override + public int hashCode() { + return Objects.hash(text, voter_count, text_entities); + } } diff --git a/src/main/java/et/telebof/types/PreCheckoutQuery.java b/src/main/java/et/telebof/types/PreCheckoutQuery.java index e4c0d38..b81712f 100644 --- a/src/main/java/et/telebof/types/PreCheckoutQuery.java +++ b/src/main/java/et/telebof/types/PreCheckoutQuery.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class PreCheckoutQuery implements Serializable { public String id; @@ -10,4 +11,32 @@ public class PreCheckoutQuery implements Serializable { public String invoice_payload, shipping_option_id; public OrderInfo order_info; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + PreCheckoutQuery that = (PreCheckoutQuery) object; + return Objects.equals(id, that.id) && Objects.equals(from, that.from) && Objects.equals(currency, that.currency) && + Objects.equals(total_amount, that.total_amount) && Objects.equals(invoice_payload, that.invoice_payload) && + Objects.equals(shipping_option_id, that.shipping_option_id) && Objects.equals(order_info, that.order_info); + } + + @Override + public int hashCode() { + return Objects.hash(id, from, currency, total_amount, invoice_payload, shipping_option_id, order_info); + } + + + @Override + public String toString() { + return "PreCheckoutQuery{" + + "id='" + id + '\'' + + ", from=" + from + + ", currency='" + currency + '\'' + + ", total_amount=" + total_amount + + ", invoice_payload='" + invoice_payload + '\'' + + ", shipping_option_id='" + shipping_option_id + '\'' + + ", order_info=" + order_info + + '}'; + } } diff --git a/src/main/java/et/telebof/types/ProximityAlertTriggered.java b/src/main/java/et/telebof/types/ProximityAlertTriggered.java index 1e61d0d..557abb4 100644 --- a/src/main/java/et/telebof/types/ProximityAlertTriggered.java +++ b/src/main/java/et/telebof/types/ProximityAlertTriggered.java @@ -1,9 +1,33 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class ProximityAlertTriggered extends JsonSerializable implements Serializable { +public class ProximityAlertTriggered implements Serializable { public User traveler, watcher; public Integer distance; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ProximityAlertTriggered that = (ProximityAlertTriggered) object; + return Objects.equals(traveler, that.traveler) && Objects.equals(watcher, that.watcher) && + Objects.equals(distance, that.distance); + } + + @Override + public int hashCode() { + return Objects.hash(traveler, watcher, distance); + } + + + @Override + public String toString() { + return "ProximityAlertTriggered{" + + "traveler=" + traveler + + ", watcher=" + watcher + + ", distance=" + distance + + '}'; + } } diff --git a/src/main/java/et/telebof/types/ReactionCount.java b/src/main/java/et/telebof/types/ReactionCount.java index c926c0f..ee238ff 100644 --- a/src/main/java/et/telebof/types/ReactionCount.java +++ b/src/main/java/et/telebof/types/ReactionCount.java @@ -1,8 +1,22 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ReactionCount implements Serializable { public ReactionType type; public int total_count; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ReactionCount that = (ReactionCount) object; + return total_count == that.total_count && Objects.equals(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hash(type, total_count); + } } diff --git a/src/main/java/et/telebof/types/ReactionType.java b/src/main/java/et/telebof/types/ReactionType.java index fb06edd..68298b9 100644 --- a/src/main/java/et/telebof/types/ReactionType.java +++ b/src/main/java/et/telebof/types/ReactionType.java @@ -3,6 +3,7 @@ import et.telebof.enums.TypeReaction; import java.io.Serializable; +import java.util.Objects; public class ReactionType implements Serializable { public String type; @@ -20,4 +21,18 @@ public void emoji(String emoji){ public void customEmojiId(String custom_emoji_id){ this.custom_emoji_id = custom_emoji_id; } + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ReactionType that = (ReactionType) object; + return Objects.equals(type, that.type) && Objects.equals(emoji, that.emoji) && + Objects.equals(custom_emoji_id, that.custom_emoji_id); + } + + @Override + public int hashCode() { + return Objects.hash(type, emoji, custom_emoji_id); + } } diff --git a/src/main/java/et/telebof/types/ReplyKeyboardMarkup.java b/src/main/java/et/telebof/types/ReplyKeyboardMarkup.java index c35c689..a1c0c49 100644 --- a/src/main/java/et/telebof/types/ReplyKeyboardMarkup.java +++ b/src/main/java/et/telebof/types/ReplyKeyboardMarkup.java @@ -5,6 +5,7 @@ import java.io.Serializable; import java.util.Arrays; import java.util.Map; +import java.util.Objects; import java.util.TreeMap; import java.util.ArrayList; import java.util.List; @@ -130,4 +131,21 @@ public void add(KeyboardButton ... keyboardButton) { } } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ReplyKeyboardMarkup markup = (ReplyKeyboardMarkup) object; + return Objects.equals(is_persistent, markup.is_persistent) && + Objects.equals(resize_keyboard, markup.resize_keyboard) && + Objects.equals(one_time_keyboard, markup.one_time_keyboard) && + Objects.equals(selective, markup.selective) && + Objects.equals(input_field_placeholder, markup.input_field_placeholder) && + Objects.equals(keyboard, markup.keyboard); + } + + @Override + public int hashCode() { + return Objects.hash(is_persistent, resize_keyboard, one_time_keyboard, selective, input_field_placeholder, keyboard); + } } diff --git a/src/main/java/et/telebof/types/ReplyKeyboardRemove.java b/src/main/java/et/telebof/types/ReplyKeyboardRemove.java index 5cce4c4..789e6f8 100644 --- a/src/main/java/et/telebof/types/ReplyKeyboardRemove.java +++ b/src/main/java/et/telebof/types/ReplyKeyboardRemove.java @@ -1,8 +1,8 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -@SuppressWarnings("unused") public class ReplyKeyboardRemove implements Markup, Serializable { private final boolean remove_keyboard; private boolean selective; @@ -16,4 +16,16 @@ public ReplyKeyboardRemove selective(boolean selective) { return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ReplyKeyboardRemove that = (ReplyKeyboardRemove) object; + return remove_keyboard == that.remove_keyboard && selective == that.selective; + } + + @Override + public int hashCode() { + return Objects.hash(remove_keyboard, selective); + } } diff --git a/src/main/java/et/telebof/types/ReplyParameters.java b/src/main/java/et/telebof/types/ReplyParameters.java index c8a31ae..5bd6709 100644 --- a/src/main/java/et/telebof/types/ReplyParameters.java +++ b/src/main/java/et/telebof/types/ReplyParameters.java @@ -3,7 +3,9 @@ import et.telebof.enums.ParseMode; import java.io.Serializable; +import java.util.Arrays; import java.util.List; +import java.util.Objects; public class ReplyParameters implements Serializable { private int message_id; @@ -48,4 +50,21 @@ public ReplyParameters quotePosition(Integer quote_position){ return this; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ReplyParameters that = (ReplyParameters) object; + return message_id == that.message_id && Objects.equals(chat_id, that.chat_id) && + Objects.equals(allow_sending_without_reply, that.allow_sending_without_reply) && + Objects.equals(quote, that.quote) && quote_parse_mode == that.quote_parse_mode && + Arrays.equals(quote_entities, that.quote_entities) && Objects.equals(quote_position, that.quote_position); + } + + @Override + public int hashCode() { + int result = Objects.hash(message_id, chat_id, allow_sending_without_reply, quote, quote_parse_mode, quote_position); + result = 31 * result + Arrays.hashCode(quote_entities); + return result; + } } diff --git a/src/main/java/et/telebof/types/SentWebAppMessage.java b/src/main/java/et/telebof/types/SentWebAppMessage.java index 4de6bb1..b080be4 100644 --- a/src/main/java/et/telebof/types/SentWebAppMessage.java +++ b/src/main/java/et/telebof/types/SentWebAppMessage.java @@ -1,8 +1,21 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class SentWebAppMessage implements Serializable { public String inline_message_id; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + SentWebAppMessage that = (SentWebAppMessage) object; + return Objects.equals(inline_message_id, that.inline_message_id); + } + + @Override + public int hashCode() { + return Objects.hash(inline_message_id); + } } diff --git a/src/main/java/et/telebof/types/SharedUser.java b/src/main/java/et/telebof/types/SharedUser.java index fc97f4b..5b86a2b 100644 --- a/src/main/java/et/telebof/types/SharedUser.java +++ b/src/main/java/et/telebof/types/SharedUser.java @@ -2,9 +2,25 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class SharedUser implements Serializable { public Long user_id; public String first_name, last_name, username; public List photo; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + SharedUser that = (SharedUser) object; + return Objects.equals(user_id, that.user_id) && Objects.equals(first_name, that.first_name) && + Objects.equals(last_name, that.last_name) && Objects.equals(username, that.username) && + Objects.equals(photo, that.photo); + } + + @Override + public int hashCode() { + return Objects.hash(user_id, first_name, last_name, username, photo); + } } diff --git a/src/main/java/et/telebof/types/ShippingAddress.java b/src/main/java/et/telebof/types/ShippingAddress.java index fa81436..0d876c2 100644 --- a/src/main/java/et/telebof/types/ShippingAddress.java +++ b/src/main/java/et/telebof/types/ShippingAddress.java @@ -1,8 +1,23 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class ShippingAddress implements Serializable { public String country_code, state, city, street_line1, street_line2, post_code; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ShippingAddress that = (ShippingAddress) object; + return Objects.equals(country_code, that.country_code) && Objects.equals(state, that.state) && + Objects.equals(city, that.city) && Objects.equals(street_line1, that.street_line1) && + Objects.equals(street_line2, that.street_line2) && Objects.equals(post_code, that.post_code); + } + + @Override + public int hashCode() { + return Objects.hash(country_code, state, city, street_line1, street_line2, post_code); + } } diff --git a/src/main/java/et/telebof/types/ShippingOption.java b/src/main/java/et/telebof/types/ShippingOption.java index 5197893..699c62f 100644 --- a/src/main/java/et/telebof/types/ShippingOption.java +++ b/src/main/java/et/telebof/types/ShippingOption.java @@ -2,6 +2,7 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class ShippingOption implements Serializable { private String id, title; @@ -13,4 +14,16 @@ public ShippingOption(String id, String title, List prices){ this.prices = prices; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ShippingOption that = (ShippingOption) object; + return Objects.equals(id, that.id) && Objects.equals(title, that.title) && Objects.equals(prices, that.prices); + } + + @Override + public int hashCode() { + return Objects.hash(id, title, prices); + } } diff --git a/src/main/java/et/telebof/types/ShippingQuery.java b/src/main/java/et/telebof/types/ShippingQuery.java index 1a8b721..7486a01 100644 --- a/src/main/java/et/telebof/types/ShippingQuery.java +++ b/src/main/java/et/telebof/types/ShippingQuery.java @@ -1,11 +1,36 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class ShippingQuery extends JsonSerializable implements Serializable { +public class ShippingQuery implements Serializable { public String id; public User from; public String invoice_payload; public ShippingAddress shipping_address; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + ShippingQuery that = (ShippingQuery) object; + return Objects.equals(id, that.id) && Objects.equals(from, that.from) && + Objects.equals(invoice_payload, that.invoice_payload) && + Objects.equals(shipping_address, that.shipping_address); + } + + @Override + public int hashCode() { + return Objects.hash(id, from, invoice_payload, shipping_address); + } + + @Override + public String toString() { + return "ShippingQuery{" + + "id='" + id + '\'' + + ", from=" + from + + ", invoice_payload='" + invoice_payload + '\'' + + ", shipping_address=" + shipping_address + + '}'; + } } diff --git a/src/main/java/et/telebof/types/Sticker.java b/src/main/java/et/telebof/types/Sticker.java index 202e5b2..5f9a871 100644 --- a/src/main/java/et/telebof/types/Sticker.java +++ b/src/main/java/et/telebof/types/Sticker.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class Sticker implements Serializable { public String file_id, file_unique_id, type; @@ -14,4 +15,25 @@ public class Sticker implements Serializable { public Boolean needs_repainting; public Integer file_size; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Sticker sticker = (Sticker) object; + return Objects.equals(file_id, sticker.file_id) && Objects.equals(file_unique_id, sticker.file_unique_id) && + Objects.equals(type, sticker.type) && Objects.equals(width, sticker.width) && + Objects.equals(height, sticker.height) && Objects.equals(is_animated, sticker.is_animated) && + Objects.equals(is_video, sticker.is_video) && Objects.equals(thumbnail, sticker.thumbnail) && + Objects.equals(emoji, sticker.emoji) && Objects.equals(setName, sticker.setName) && + Objects.equals(premium_animation, sticker.premium_animation) && + Objects.equals(mask_position, sticker.mask_position) && + Objects.equals(custom_emoji_id, sticker.custom_emoji_id) && + Objects.equals(needs_repainting, sticker.needs_repainting) && Objects.equals(file_size, sticker.file_size); + } + + @Override + public int hashCode() { + return Objects.hash(file_id, file_unique_id, type, width, height, is_animated, is_video, thumbnail, emoji, + setName, premium_animation, mask_position, custom_emoji_id, needs_repainting, file_size); + } } diff --git a/src/main/java/et/telebof/types/StickerSet.java b/src/main/java/et/telebof/types/StickerSet.java index ed77c81..59dd6b7 100644 --- a/src/main/java/et/telebof/types/StickerSet.java +++ b/src/main/java/et/telebof/types/StickerSet.java @@ -2,9 +2,23 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class StickerSet implements Serializable { public String name, title, sticker_type; public List stickers; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + StickerSet that = (StickerSet) object; + return Objects.equals(name, that.name) && Objects.equals(title, that.title) && + Objects.equals(sticker_type, that.sticker_type) && Objects.equals(stickers, that.stickers); + } + + @Override + public int hashCode() { + return Objects.hash(name, title, sticker_type, stickers); + } } diff --git a/src/main/java/et/telebof/types/Story.java b/src/main/java/et/telebof/types/Story.java index 5172ffa..cc024ca 100644 --- a/src/main/java/et/telebof/types/Story.java +++ b/src/main/java/et/telebof/types/Story.java @@ -1,8 +1,22 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class Story implements Serializable { public Chat chat; public Integer id; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Story story = (Story) object; + return Objects.equals(chat, story.chat) && Objects.equals(id, story.id); + } + + @Override + public int hashCode() { + return Objects.hash(chat, id); + } } diff --git a/src/main/java/et/telebof/types/SuccessfulPayment.java b/src/main/java/et/telebof/types/SuccessfulPayment.java index bc83e6e..73b8514 100644 --- a/src/main/java/et/telebof/types/SuccessfulPayment.java +++ b/src/main/java/et/telebof/types/SuccessfulPayment.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class SuccessfulPayment implements Serializable { public String currency; @@ -9,4 +10,21 @@ public class SuccessfulPayment implements Serializable { public OrderInfo order_info; public String telegram_payment_charge_id, provider_payment_charge_id; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + SuccessfulPayment that = (SuccessfulPayment) object; + return Objects.equals(currency, that.currency) && Objects.equals(total_amount, that.total_amount) && + Objects.equals(invoice_payload, that.invoice_payload) && + Objects.equals(shipping_option_id, that.shipping_option_id) && + Objects.equals(order_info, that.order_info) && + Objects.equals(telegram_payment_charge_id, that.telegram_payment_charge_id) && + Objects.equals(provider_payment_charge_id, that.provider_payment_charge_id); + } + + @Override + public int hashCode() { + return Objects.hash(currency, total_amount, invoice_payload, shipping_option_id, order_info, telegram_payment_charge_id, provider_payment_charge_id); + } } diff --git a/src/main/java/et/telebof/types/SwitchInlineQueryChosenChat.java b/src/main/java/et/telebof/types/SwitchInlineQueryChosenChat.java index 044f28b..ceb5b0a 100644 --- a/src/main/java/et/telebof/types/SwitchInlineQueryChosenChat.java +++ b/src/main/java/et/telebof/types/SwitchInlineQueryChosenChat.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class SwitchInlineQueryChosenChat implements Serializable { private String query; @@ -30,4 +31,20 @@ public SwitchInlineQueryChosenChat allowChannelChats(boolean allowChannelChats){ this.allow_channel_chats = allowChannelChats; return this; } + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + SwitchInlineQueryChosenChat that = (SwitchInlineQueryChosenChat) object; + return Objects.equals(query, that.query) && Objects.equals(allow_user_chats, that.allow_user_chats) && + Objects.equals(allow_bot_chats, that.allow_bot_chats) && + Objects.equals(allow_group_chats, that.allow_group_chats) && + Objects.equals(allow_channel_chats, that.allow_channel_chats); + } + + @Override + public int hashCode() { + return Objects.hash(query, allow_user_chats, allow_bot_chats, allow_group_chats, allow_channel_chats); + } } diff --git a/src/main/java/et/telebof/types/TextQuote.java b/src/main/java/et/telebof/types/TextQuote.java index 7d87c4b..eb5467a 100644 --- a/src/main/java/et/telebof/types/TextQuote.java +++ b/src/main/java/et/telebof/types/TextQuote.java @@ -2,10 +2,25 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class TextQuote implements Serializable { public String text; public List entities; public Integer position; public Boolean is_manual; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + TextQuote textQuote = (TextQuote) object; + return Objects.equals(text, textQuote.text) && Objects.equals(entities, textQuote.entities) && + Objects.equals(position, textQuote.position) && Objects.equals(is_manual, textQuote.is_manual); + } + + @Override + public int hashCode() { + return Objects.hash(text, entities, position, is_manual); + } } diff --git a/src/main/java/et/telebof/types/Update.java b/src/main/java/et/telebof/types/Update.java index 43f985f..efc4935 100644 --- a/src/main/java/et/telebof/types/Update.java +++ b/src/main/java/et/telebof/types/Update.java @@ -1,5 +1,6 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; /** This class represents an incoming updates. * At most one of the optional parameters can be present in any given update. @@ -8,7 +9,7 @@ * @author Natanim Negash */ -public class Update extends JsonSerializable implements Serializable { +public class Update implements Serializable { public int update_id; public Message message, edited_message, channel_post, edited_channel_post, business_message, edited_business_message; public CallbackQuery callback_query; @@ -27,5 +28,69 @@ public class Update extends JsonSerializable implements Serializable { public BusinessConnection business_connection; public BusinessMessagesDeleted deleted_business_messages; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Update update = (Update) object; + return update_id == update.update_id && Objects.equals(message, update.message) && + Objects.equals(edited_message, update.edited_message) && + Objects.equals(channel_post, update.channel_post) && + Objects.equals(edited_channel_post, update.edited_channel_post) && + Objects.equals(business_message, update.business_message) && + Objects.equals(edited_business_message, update.edited_business_message) && + Objects.equals(callback_query, update.callback_query) && + Objects.equals(inline_query, update.inline_query) && + Objects.equals(chosen_inline_result, update.chosen_inline_result) && + Objects.equals(poll, update.poll) && Objects.equals(poll_answer, update.poll_answer) && + Objects.equals(pre_checkout_query, update.pre_checkout_query) && + Objects.equals(shipping_query, update.shipping_query) && + Objects.equals(my_chat_member, update.my_chat_member) && + Objects.equals(chat_member, update.chat_member) && + Objects.equals(chat_join_request, update.chat_join_request) && + Objects.equals(message_reaction, update.message_reaction) && + Objects.equals(message_reaction_count, update.message_reaction_count) && + Objects.equals(chat_boost, update.chat_boost) && + Objects.equals(removed_chat_boost, update.removed_chat_boost) && + Objects.equals(business_connection, update.business_connection) && + Objects.equals(deleted_business_messages, update.deleted_business_messages); + } + @Override + public int hashCode() { + return Objects.hash(update_id, message, edited_message, channel_post, edited_channel_post, business_message, + edited_business_message, callback_query, inline_query, chosen_inline_result, poll, poll_answer, + pre_checkout_query, shipping_query, my_chat_member, chat_member, chat_join_request, message_reaction, + message_reaction_count, chat_boost, removed_chat_boost, business_connection, deleted_business_messages); + } + + + @Override + public String toString() { + return "Update{" + + "update_id=" + update_id + + ", message=" + message + + ", edited_message=" + edited_message + + ", channel_post=" + channel_post + + ", edited_channel_post=" + edited_channel_post + + ", business_message=" + business_message + + ", edited_business_message=" + edited_business_message + + ", callback_query=" + callback_query + + ", inline_query=" + inline_query + + ", chosen_inline_result=" + chosen_inline_result + + ", poll=" + poll + + ", poll_answer=" + poll_answer + + ", pre_checkout_query=" + pre_checkout_query + + ", shipping_query=" + shipping_query + + ", my_chat_member=" + my_chat_member + + ", chat_member=" + chat_member + + ", chat_join_request=" + chat_join_request + + ", message_reaction=" + message_reaction + + ", message_reaction_count=" + message_reaction_count + + ", chat_boost=" + chat_boost + + ", removed_chat_boost=" + removed_chat_boost + + ", business_connection=" + business_connection + + ", deleted_business_messages=" + deleted_business_messages + + '}'; + } } diff --git a/src/main/java/et/telebof/types/User.java b/src/main/java/et/telebof/types/User.java index ecad58e..18f3c41 100644 --- a/src/main/java/et/telebof/types/User.java +++ b/src/main/java/et/telebof/types/User.java @@ -1,9 +1,10 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class User extends JsonSerializable implements Serializable { - public Long id; +public class User implements Serializable { + public long id; public Boolean is_bot, is_premium, added_to_attachment_menu, can_join_groups, can_read_all_group_messages, supports_inline_queries, can_connect_to_business; public String first_name, last_name, language_code, username; @@ -14,6 +15,45 @@ public String mention(){ return String.format("%s", id, name); } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + User user = (User) object; + return id == user.id && Objects.equals(is_bot, user.is_bot) && Objects.equals(is_premium, user.is_premium) && + Objects.equals(added_to_attachment_menu, user.added_to_attachment_menu) && + Objects.equals(can_join_groups, user.can_join_groups) && + Objects.equals(can_read_all_group_messages, user.can_read_all_group_messages) && + Objects.equals(supports_inline_queries, user.supports_inline_queries) && + Objects.equals(can_connect_to_business, user.can_connect_to_business) && + Objects.equals(first_name, user.first_name) && Objects.equals(last_name, user.last_name) && + Objects.equals(language_code, user.language_code) && Objects.equals(username, user.username); + } + + @Override + public int hashCode() { + return Objects.hash(id, is_bot, is_premium, added_to_attachment_menu, can_join_groups, + can_read_all_group_messages, supports_inline_queries, can_connect_to_business, first_name, last_name, + language_code, username); + } + + @Override + public String toString() { + return "User{" + + "id=" + id + + ", is_bot=" + is_bot + + ", is_premium=" + is_premium + + ", added_to_attachment_menu=" + added_to_attachment_menu + + ", can_join_groups=" + can_join_groups + + ", can_read_all_group_messages=" + can_read_all_group_messages + + ", supports_inline_queries=" + supports_inline_queries + + ", can_connect_to_business=" + can_connect_to_business + + ", first_name='" + first_name + '\'' + + ", last_name='" + last_name + '\'' + + ", language_code='" + language_code + '\'' + + ", username='" + username + '\'' + + '}'; + } } diff --git a/src/main/java/et/telebof/types/UserChatBoosts.java b/src/main/java/et/telebof/types/UserChatBoosts.java index fbdd712..eb77257 100644 --- a/src/main/java/et/telebof/types/UserChatBoosts.java +++ b/src/main/java/et/telebof/types/UserChatBoosts.java @@ -2,7 +2,21 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class UserChatBoosts implements Serializable { public List boosts; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + UserChatBoosts that = (UserChatBoosts) object; + return Objects.equals(boosts, that.boosts); + } + + @Override + public int hashCode() { + return Objects.hash(boosts); + } } diff --git a/src/main/java/et/telebof/types/UserProfilePhotos.java b/src/main/java/et/telebof/types/UserProfilePhotos.java index 7ca3324..86a81e7 100644 --- a/src/main/java/et/telebof/types/UserProfilePhotos.java +++ b/src/main/java/et/telebof/types/UserProfilePhotos.java @@ -2,9 +2,22 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class UserProfilePhotos implements Serializable { public Integer total_count; public List photos; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + UserProfilePhotos that = (UserProfilePhotos) object; + return Objects.equals(total_count, that.total_count) && Objects.equals(photos, that.photos); + } + + @Override + public int hashCode() { + return Objects.hash(total_count, photos); + } } diff --git a/src/main/java/et/telebof/types/UsersShared.java b/src/main/java/et/telebof/types/UsersShared.java index 7540594..99e5a91 100644 --- a/src/main/java/et/telebof/types/UsersShared.java +++ b/src/main/java/et/telebof/types/UsersShared.java @@ -2,8 +2,22 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; public class UsersShared implements Serializable { public int request_id; public List users; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + UsersShared that = (UsersShared) object; + return request_id == that.request_id && Objects.equals(users, that.users); + } + + @Override + public int hashCode() { + return Objects.hash(request_id, users); + } } diff --git a/src/main/java/et/telebof/types/Venue.java b/src/main/java/et/telebof/types/Venue.java index 66b2d1f..fa4d2b4 100644 --- a/src/main/java/et/telebof/types/Venue.java +++ b/src/main/java/et/telebof/types/Venue.java @@ -1,9 +1,27 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class Venue implements Serializable { public String title, address, foursquare_id, foursquare_type, google_place_id, google_place_type; public Location location; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Venue venue = (Venue) object; + return Objects.equals(title, venue.title) && Objects.equals(address, venue.address) && + Objects.equals(foursquare_id, venue.foursquare_id) && + Objects.equals(foursquare_type, venue.foursquare_type) && + Objects.equals(google_place_id, venue.google_place_id) && + Objects.equals(google_place_type, venue.google_place_type) && + Objects.equals(location, venue.location); + } + + @Override + public int hashCode() { + return Objects.hash(title, address, foursquare_id, foursquare_type, google_place_id, google_place_type, location); + } } diff --git a/src/main/java/et/telebof/types/Video.java b/src/main/java/et/telebof/types/Video.java index a328fd9..3a59432 100644 --- a/src/main/java/et/telebof/types/Video.java +++ b/src/main/java/et/telebof/types/Video.java @@ -1,4 +1,27 @@ package et.telebof.types; -public class Video extends Animation { +import java.util.Objects; + +public class Video{ + public String file_id, file_unique_id, file_name, mime_type; + public Integer width, height, duration; + public Integer file_size; + public PhotoSize thumbnail; + + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Video video = (Video) object; + return Objects.equals(file_id, video.file_id) && Objects.equals(file_unique_id, video.file_unique_id) && + Objects.equals(file_name, video.file_name) && Objects.equals(mime_type, video.mime_type) && + Objects.equals(width, video.width) && Objects.equals(height, video.height) && + Objects.equals(duration, video.duration) && Objects.equals(file_size, video.file_size) && + Objects.equals(thumbnail, video.thumbnail); + } + + @Override + public int hashCode() { + return Objects.hash(file_id, file_unique_id, file_name, mime_type, width, height, duration, file_size, thumbnail); + } } diff --git a/src/main/java/et/telebof/types/VideoChatEnded.java b/src/main/java/et/telebof/types/VideoChatEnded.java index c3db3cb..cd997f4 100644 --- a/src/main/java/et/telebof/types/VideoChatEnded.java +++ b/src/main/java/et/telebof/types/VideoChatEnded.java @@ -1,8 +1,21 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class VideoChatEnded extends JsonSerializable implements Serializable { +public class VideoChatEnded implements Serializable { public Integer duration; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + VideoChatEnded that = (VideoChatEnded) object; + return Objects.equals(duration, that.duration); + } + + @Override + public int hashCode() { + return Objects.hash(duration); + } } diff --git a/src/main/java/et/telebof/types/VideoChatParticipantsInvited.java b/src/main/java/et/telebof/types/VideoChatParticipantsInvited.java index 4f1d36f..cdbac23 100644 --- a/src/main/java/et/telebof/types/VideoChatParticipantsInvited.java +++ b/src/main/java/et/telebof/types/VideoChatParticipantsInvited.java @@ -2,8 +2,21 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; -public class VideoChatParticipantsInvited extends JsonSerializable implements Serializable { +public class VideoChatParticipantsInvited implements Serializable { public List users; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + VideoChatParticipantsInvited that = (VideoChatParticipantsInvited) object; + return Objects.equals(users, that.users); + } + + @Override + public int hashCode() { + return Objects.hash(users); + } } diff --git a/src/main/java/et/telebof/types/VideoChatScheduled.java b/src/main/java/et/telebof/types/VideoChatScheduled.java index c35cad5..40295b4 100644 --- a/src/main/java/et/telebof/types/VideoChatScheduled.java +++ b/src/main/java/et/telebof/types/VideoChatScheduled.java @@ -1,8 +1,21 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class VideoChatScheduled extends JsonSerializable implements Serializable { +public class VideoChatScheduled implements Serializable { public Integer start_date; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + VideoChatScheduled that = (VideoChatScheduled) object; + return Objects.equals(start_date, that.start_date); + } + + @Override + public int hashCode() { + return Objects.hash(start_date); + } } diff --git a/src/main/java/et/telebof/types/VideoChatStarted.java b/src/main/java/et/telebof/types/VideoChatStarted.java index 23791b9..847a69f 100644 --- a/src/main/java/et/telebof/types/VideoChatStarted.java +++ b/src/main/java/et/telebof/types/VideoChatStarted.java @@ -3,6 +3,6 @@ import java.io.Serializable; -public class VideoChatStarted extends JsonSerializable implements Serializable { +public class VideoChatStarted implements Serializable { // not implemented } diff --git a/src/main/java/et/telebof/types/VideoNote.java b/src/main/java/et/telebof/types/VideoNote.java index b7d2646..45d93a1 100644 --- a/src/main/java/et/telebof/types/VideoNote.java +++ b/src/main/java/et/telebof/types/VideoNote.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class VideoNote implements Serializable { public String file_id, file_unique_id; @@ -8,4 +9,18 @@ public class VideoNote implements Serializable { public Integer file_size; public PhotoSize thumbnail; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + VideoNote videoNote = (VideoNote) object; + return Objects.equals(file_id, videoNote.file_id) && Objects.equals(file_unique_id, videoNote.file_unique_id) && + Objects.equals(length, videoNote.length) && Objects.equals(duration, videoNote.duration) && + Objects.equals(file_size, videoNote.file_size) && Objects.equals(thumbnail, videoNote.thumbnail); + } + + @Override + public int hashCode() { + return Objects.hash(file_id, file_unique_id, length, duration, file_size, thumbnail); + } } \ No newline at end of file diff --git a/src/main/java/et/telebof/types/Voice.java b/src/main/java/et/telebof/types/Voice.java index fb1f12b..4860b8d 100644 --- a/src/main/java/et/telebof/types/Voice.java +++ b/src/main/java/et/telebof/types/Voice.java @@ -1,10 +1,25 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class Voice extends JsonSerializable implements Serializable { +public class Voice implements Serializable { public String file_id, file_unique_id, mime_type; public Integer duration; public Integer file_size; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + Voice voice = (Voice) object; + return Objects.equals(file_id, voice.file_id) && Objects.equals(file_unique_id, voice.file_unique_id) && + Objects.equals(mime_type, voice.mime_type) && Objects.equals(duration, voice.duration) && + Objects.equals(file_size, voice.file_size); + } + + @Override + public int hashCode() { + return Objects.hash(file_id, file_unique_id, mime_type, duration, file_size); + } } diff --git a/src/main/java/et/telebof/types/WebAppData.java b/src/main/java/et/telebof/types/WebAppData.java index c58562f..962c61b 100644 --- a/src/main/java/et/telebof/types/WebAppData.java +++ b/src/main/java/et/telebof/types/WebAppData.java @@ -1,8 +1,29 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; -public class WebAppData extends JsonSerializable implements Serializable { +public class WebAppData implements Serializable { public String data, button_text; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + WebAppData that = (WebAppData) object; + return Objects.equals(data, that.data) && Objects.equals(button_text, that.button_text); + } + + @Override + public int hashCode() { + return Objects.hash(data, button_text); + } + + @Override + public String toString() { + return "WebAppData{" + + "data='" + data + '\'' + + ", button_text='" + button_text + '\'' + + '}'; + } } diff --git a/src/main/java/et/telebof/types/WebAppInfo.java b/src/main/java/et/telebof/types/WebAppInfo.java index 37b3d86..046e144 100644 --- a/src/main/java/et/telebof/types/WebAppInfo.java +++ b/src/main/java/et/telebof/types/WebAppInfo.java @@ -1,6 +1,7 @@ package et.telebof.types; import java.io.Serializable; +import java.util.Objects; public class WebAppInfo implements Serializable { @@ -10,4 +11,16 @@ public WebAppInfo(String url) { this.url = url; } + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + WebAppInfo that = (WebAppInfo) object; + return Objects.equals(url, that.url); + } + + @Override + public int hashCode() { + return Objects.hash(url); + } } diff --git a/src/main/java/et/telebof/types/WebhookInfo.java b/src/main/java/et/telebof/types/WebhookInfo.java index 7091bf1..33b95a0 100644 --- a/src/main/java/et/telebof/types/WebhookInfo.java +++ b/src/main/java/et/telebof/types/WebhookInfo.java @@ -3,12 +3,45 @@ import java.io.Serializable; import java.util.List; +import java.util.Objects; -public class WebhookInfo extends JsonSerializable implements Serializable { +public class WebhookInfo implements Serializable { public String url, ip_address, last_error_message; public Integer pending_update_count, last_synchronization_error_date, max_connections; public Boolean has_custom_certificate; public List allowed_updates; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + WebhookInfo that = (WebhookInfo) object; + return Objects.equals(url, that.url) && Objects.equals(ip_address, that.ip_address) && + Objects.equals(last_error_message, that.last_error_message) && + Objects.equals(pending_update_count, that.pending_update_count) && + Objects.equals(last_synchronization_error_date, that.last_synchronization_error_date) && + Objects.equals(max_connections, that.max_connections) && + Objects.equals(has_custom_certificate, that.has_custom_certificate) && + Objects.equals(allowed_updates, that.allowed_updates); + } + + @Override + public int hashCode() { + return Objects.hash(url, ip_address, last_error_message, pending_update_count, last_synchronization_error_date, max_connections, has_custom_certificate, allowed_updates); + } + + @Override + public String toString() { + return "WebhookInfo{" + + "url='" + url + '\'' + + ", ip_address='" + ip_address + '\'' + + ", last_error_message='" + last_error_message + '\'' + + ", pending_update_count=" + pending_update_count + + ", last_synchronization_error_date=" + last_synchronization_error_date + + ", max_connections=" + max_connections + + ", has_custom_certificate=" + has_custom_certificate + + ", allowed_updates=" + allowed_updates + + '}'; + } } diff --git a/src/main/java/et/telebof/types/WriteAccessAllowed.java b/src/main/java/et/telebof/types/WriteAccessAllowed.java index ba7a945..f65b6d1 100644 --- a/src/main/java/et/telebof/types/WriteAccessAllowed.java +++ b/src/main/java/et/telebof/types/WriteAccessAllowed.java @@ -2,9 +2,23 @@ import java.io.Serializable; +import java.util.Objects; -public class WriteAccessAllowed extends JsonSerializable implements Serializable { +public class WriteAccessAllowed implements Serializable { public String web_app_name; public Boolean from_request, from_attachment_menu; + @Override + public boolean equals(Object object) { + if (this == object) return true; + if (object == null || getClass() != object.getClass()) return false; + WriteAccessAllowed that = (WriteAccessAllowed) object; + return Objects.equals(web_app_name, that.web_app_name) && Objects.equals(from_request, that.from_request) && + Objects.equals(from_attachment_menu, that.from_attachment_menu); + } + + @Override + public int hashCode() { + return Objects.hash(web_app_name, from_request, from_attachment_menu); + } }