From 4fb51ec99c592facd0a72adfee8ad3885133d2ae Mon Sep 17 00:00:00 2001 From: rubenlagus Date: Sat, 31 Oct 2020 13:41:05 +0000 Subject: [PATCH] Added lombok --- pom.xml | 7 ++ telegrambots-meta/pom.xml | 5 ++ .../meta/api/methods/BotApiMethod.java | 2 + .../meta/api/objects/commands/BotCommand.java | 48 +++-------- .../meta/api/objects/games/Animation.java | 59 +------------ .../meta/api/objects/games/CallbackGame.java | 25 ++---- .../meta/api/objects/games/Game.java | 48 ++--------- .../meta/api/objects/games/GameHighScore.java | 29 ++----- .../inlinequery/ChosenInlineQuery.java | 44 ++-------- .../api/objects/inlinequery/InlineQuery.java | 52 ++--------- .../InputContactMessageContent.java | 64 +++----------- .../InputLocationMessageContent.java | 66 +++----------- .../InputTextMessageContent.java | 80 +++-------------- .../InputVenueMessageContent.java | 86 +++---------------- 14 files changed, 107 insertions(+), 508 deletions(-) diff --git a/pom.xml b/pom.xml index 4704c1e6..68db8f58 100644 --- a/pom.xml +++ b/pom.xml @@ -74,10 +74,17 @@ 2.10.1 1.7.29 1.3.5 + 1.18.16 + + org.projectlombok + lombok + ${lombok.version} + provided + org.junit.jupiter junit-jupiter-api diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml index 46ed343d..24c60519 100644 --- a/telegrambots-meta/pom.xml +++ b/telegrambots-meta/pom.xml @@ -114,6 +114,11 @@ json ${json.version} + + org.projectlombok + lombok + provided + diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/BotApiMethod.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/BotApiMethod.java index 620f7bf2..6d4cc32f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/BotApiMethod.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/BotApiMethod.java @@ -3,6 +3,7 @@ package org.telegram.telegrambots.meta.api.methods; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; import java.io.Serializable; @@ -14,6 +15,7 @@ import java.io.Serializable; */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) +@Data public abstract class BotApiMethod extends PartialBotApiMethod { protected static final String METHOD_FIELD = "method"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java index 63fb2419..e3b4dfbb 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java @@ -1,17 +1,24 @@ package org.telegram.telegrambots.meta.api.objects.commands; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.interfaces.Validable; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; -import static com.google.common.base.Preconditions.checkNotNull; - /** * @author Ruben Bermudez * @version 4.7 * This object represents a bot command. */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class BotCommand implements BotApiObject, Validable { private static final String COMMAND_FIELD = "command"; private static final String DESCRIPTION_FIELD = "description"; @@ -20,37 +27,12 @@ public class BotCommand implements BotApiObject, Validable { * Text of the command. Can contain only lowercase English letters, digits and underscores. 1-32 characters. */ @JsonProperty(COMMAND_FIELD) + @NonNull private String command; ///< Value of the dice, 1-6 @JsonProperty(DESCRIPTION_FIELD) + @NonNull private String description; ///< Description of the command, 3-256 characters. - public BotCommand() { - super(); - } - - public BotCommand(String command, String description) { - this.command = checkNotNull(command); - this.description = checkNotNull(description); - } - - public String getCommand() { - return command; - } - - public BotCommand setCommand(String command) { - this.command = command; - return this; - } - - public String getDescription() { - return description; - } - - public BotCommand setDescription(String description) { - this.description = description; - return this; - } - @Override public void validate() throws TelegramApiValidationException { if (command == null || command.isEmpty()) { @@ -60,12 +42,4 @@ public class BotCommand implements BotApiObject, Validable { throw new TelegramApiValidationException("Description parameter can't be empty", this); } } - - @Override - public String toString() { - return "BotCommand{" + - "command='" + command + '\'' + - ", description='" + description + '\'' + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java index 75d2d76e..d1279e21 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java @@ -17,6 +17,8 @@ package org.telegram.telegrambots.meta.api.objects.games; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.PhotoSize; @@ -25,6 +27,8 @@ import org.telegram.telegrambots.meta.api.objects.PhotoSize; * @version 2.4 * This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). */ +@Data +@NoArgsConstructor public class Animation implements BotApiObject { private static final String FILEID_FIELD = "file_id"; private static final String FILEUNIQUEID_FIELD = "file_unique_id"; @@ -58,59 +62,4 @@ public class Animation implements BotApiObject { private String mimetype; ///< Optional. MIME type of the file as defined by sender @JsonProperty(FILESIZE_FIELD) private Integer fileSize; ///< Optional. File size - - public Animation() { - super(); - } - - public String getFileId() { - return fileId; - } - - public PhotoSize getThumb() { - return thumb; - } - - public String getFileName() { - return fileName; - } - - public String getMimetype() { - return mimetype; - } - - public Integer getFileSize() { - return fileSize; - } - - public Integer getWidth() { - return width; - } - - public Integer getHeight() { - return height; - } - - public Integer getDuration() { - return duration; - } - - public String getFileUniqueId() { - return fileUniqueId; - } - - @Override - public String toString() { - return "Animation{" + - "fileId='" + fileId + '\'' + - ", width=" + width + - ", height=" + height + - ", duration=" + duration + - ", thumb=" + thumb + - ", fileName='" + fileName + '\'' + - ", mimetype='" + mimetype + '\'' + - ", fileSize=" + fileSize + - ", fileUniqueId=" + fileUniqueId + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/CallbackGame.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/CallbackGame.java index 6528163b..0aec927c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/CallbackGame.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/CallbackGame.java @@ -17,31 +17,16 @@ package org.telegram.telegrambots.meta.api.objects.games; +import lombok.Data; +import lombok.NoArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; /** * @author Ruben Bermudez * @version 2.4 - * @brief A placeholder, currently holds no information. Use BotFather to set up your game. - * @date 16 of September of 2016 + * A placeholder, currently holds no information. Use BotFather to set up your game. */ +@Data +@NoArgsConstructor public class CallbackGame implements BotApiObject { - public CallbackGame() { - super(); - } - - @Override - public String toString() { - return "CallbackGame{}"; - } - - @Override - public boolean equals(Object o) { - return o == this || o instanceof CallbackGame; - } - - @Override - public int hashCode() { - return getClass().hashCode(); - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java index 7e84b3ef..2be56adb 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java @@ -17,7 +17,8 @@ package org.telegram.telegrambots.meta.api.objects.games; import com.fasterxml.jackson.annotation.JsonProperty; - +import lombok.Data; +import lombok.NoArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.MessageEntity; import org.telegram.telegrambots.meta.api.objects.PhotoSize; @@ -27,10 +28,11 @@ import java.util.List; /** * @author Ruben Bermudez * @version 2.4 - * @brief This object represents a game. - * Use BotFather to create and edit games, their short names will act as unique identifiers. - * @date 27 of September of 2016 + * This object represents a game. + * @apiNote Use BotFather to create and edit games, their short names will act as unique identifiers. */ +@Data +@NoArgsConstructor public class Game implements BotApiObject { private static final String TITLE_FIELD = "title"; @@ -63,45 +65,7 @@ public class Game implements BotApiObject { @JsonProperty(ANIMATION_FIELD) private Animation animation; ///< Optional. Animation - public Game() { - super(); - } - - public String getTitle() { - return title; - } - - public String getDescription() { - return description; - } - - public List getPhoto() { - return photo; - } - - public Animation getAnimation() { - return animation; - } - - public String getText() { - return text; - } - public boolean hasEntities() { return entities != null && !entities.isEmpty(); } - - public List getEntities() { - return entities; - } - - @Override - public String toString() { - return "Game{" + - "title='" + title + '\'' + - ", description='" + description + '\'' + - ", photo=" + photo + - ", animation=" + animation + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java index c9a7f43a..379fd281 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java @@ -18,16 +18,18 @@ package org.telegram.telegrambots.meta.api.objects.games; import com.fasterxml.jackson.annotation.JsonProperty; - +import lombok.Data; +import lombok.NoArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.User; /** * @author Ruben Bermudez * @version 1.0 - * @brief This object represents one row of a game high scores table - * @date 25 of September of 2016 + * This object represents one row of a game high scores table */ +@Data +@NoArgsConstructor public class GameHighScore implements BotApiObject { private static final String POSITION_FIELD = "position"; private static final String USER_FIELD = "user"; @@ -39,25 +41,4 @@ public class GameHighScore implements BotApiObject { private User user; ///< User @JsonProperty(SCORE_FIELD) private Integer score; ///< Score - - public Integer getPosition() { - return position; - } - - public User getUser() { - return user; - } - - public Integer getScore() { - return score; - } - - @Override - public String toString() { - return "GameHighScore{" + - "position=" + position + - ", user=" + user + - ", score=" + score + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java index f0e4de82..bd1114eb 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java @@ -2,6 +2,9 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.Location; import org.telegram.telegrambots.meta.api.objects.User; @@ -9,10 +12,12 @@ import org.telegram.telegrambots.meta.api.objects.User; /** * @author Ruben Bermudez * @version 1.0 - * @brief Represents a result of an inline query that was chosen by the user and sent to their chat + * Represents a result of an inline query that was chosen by the user and sent to their chat * partner. - * @date 01 of January of 2016 */ +@Data +@NoArgsConstructor +@Builder public class ChosenInlineQuery implements BotApiObject { private static final String RESULTID_FIELD = "result_id"; private static final String FROM_FIELD = "from"; @@ -36,39 +41,4 @@ public class ChosenInlineQuery implements BotApiObject { private String inlineMessageId; @JsonProperty(QUERY_FIELD) private String query; ///< The query that was used to obtain the result. - - public ChosenInlineQuery() { - super(); - } - - public String getResultId() { - return resultId; - } - - public User getFrom() { - return from; - } - - public Location getLocation() { - return location; - } - - public String getInlineMessageId() { - return inlineMessageId; - } - - public String getQuery() { - return query; - } - - @Override - public String toString() { - return "ChosenInlineQuery{" + - "resultId='" + resultId + '\'' + - ", from=" + from + - ", location=" + location + - ", inlineMessageId=" + inlineMessageId + - ", query='" + query + '\'' + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java index 99d31257..b41039a4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java @@ -2,6 +2,9 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.Location; import org.telegram.telegrambots.meta.api.objects.User; @@ -9,10 +12,12 @@ import org.telegram.telegrambots.meta.api.objects.User; /** * @author Ruben Bermudez * @version 1.0 - * @brief This object represents an incoming inline query. When the user sends an empty query, your + * This object represents an incoming inline query. When the user sends an empty query, your * bot could return some default or trending results. - * @date 01 of January of 2016 */ +@Data +@NoArgsConstructor +@Builder public class InlineQuery implements BotApiObject { private static final String ID_FIELD = "id"; private static final String FROM_FIELD = "from"; @@ -30,48 +35,5 @@ public class InlineQuery implements BotApiObject { private String query; ///< Text of the query @JsonProperty(OFFSET_FIELD) private String offset; ///< Offset of the results to be returned, can be controlled by the bot - - public InlineQuery() { - super(); - } - - public String getId() { - return id; - } - - public User getFrom() { - return from; - } - - public Location getLocation() { - return location; - } - - public String getQuery() { - return query; - } - - public String getOffset() { - return offset; - } - - public boolean hasQuery() { - return query != null && !query.isEmpty(); - } - - public boolean hasLocation() { - return location != null; - } - - @Override - public String toString() { - return "InlineQuery{" + - "id='" + id + '\'' + - ", from=" + from + - ", location=" + location + - ", query='" + query + '\'' + - ", offset='" + offset + '\'' + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java index e40965f9..28309713 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java @@ -1,18 +1,26 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent; import com.fasterxml.jackson.annotation.JsonProperty; - import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; /** * @author Ruben Bermudez * @version 1.0 * Represents the content of a contact message to be sent as the result of an inline query - * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will + * @apiNote This will only work in Telegram versions released after 9 April, 2016. Older clients will * ignore them. */ @JsonDeserialize +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class InputContactMessageContent implements InputMessageContent { private static final String PHONE_NUMBER_FIELD = "phone_number"; @@ -21,54 +29,16 @@ public class InputContactMessageContent implements InputMessageContent { private static final String VCARD_FIELD = "vcard"; @JsonProperty(PHONE_NUMBER_FIELD) + @NonNull private String phoneNumber; ///< Contact's phone number @JsonProperty(FIRST_NAME_FIELD) + @NonNull private String firstName; ///< Contact's first name @JsonProperty(LAST_NAME_FIELD) private String lastName; ///< Optional. Contact's last name @JsonProperty(VCARD_FIELD) private String vCard; ///< Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes - public InputContactMessageContent() { - super(); - } - - public String getPhoneNumber() { - return phoneNumber; - } - - public InputContactMessageContent setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - return this; - } - - public String getFirstName() { - return firstName; - } - - public InputContactMessageContent setFirstName(String firstName) { - this.firstName = firstName; - return this; - } - - public String getLastName() { - return lastName; - } - - public InputContactMessageContent setLastName(String lastName) { - this.lastName = lastName; - return this; - } - - public String getVCard() { - return vCard; - } - - public InputContactMessageContent setVCard(String vCard) { - this.vCard = vCard; - return this; - } - @Override public void validate() throws TelegramApiValidationException { if (phoneNumber == null || phoneNumber.isEmpty()) { @@ -78,14 +48,4 @@ public class InputContactMessageContent implements InputMessageContent { throw new TelegramApiValidationException("FirstName parameter can't be empty", this); } } - - @Override - public String toString() { - return "InputContactMessageContent{" + - "phoneNumber='" + phoneNumber + '\'' + - ", firstName='" + firstName + '\'' + - ", lastName='" + lastName + '\'' + - ", vCard='" + vCard + '\'' + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java index 55b59866..a60d3949 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java @@ -1,22 +1,26 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent; import com.fasterxml.jackson.annotation.JsonProperty; - import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; -import java.util.Objects; - -import static com.google.common.base.Preconditions.checkNotNull; - /** * @author Ruben Bermudez * @version 1.0 * Represents the content of a location message to be sent as the result of an inline query. - * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will + * @apiNote This will only work in Telegram versions released after 9 April, 2016. Older clients will * ignore them. */ @JsonDeserialize +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class InputLocationMessageContent implements InputMessageContent { private static final String LATITUDE_FIELD = "latitude"; @@ -24,51 +28,14 @@ public class InputLocationMessageContent implements InputMessageContent { private static final String LIVEPERIOD_FIELD = "live_period"; @JsonProperty(LATITUDE_FIELD) + @NonNull private Float latitude; ///< Latitude of the location in degrees @JsonProperty(LONGITUDE_FIELD) + @NonNull private Float longitude; ///< Longitude of the location in degrees @JsonProperty(LIVEPERIOD_FIELD) private Integer livePeriod; ///< Optional. Period in seconds for which the location can be updated, should be between 60 and 86400. - public InputLocationMessageContent() { - super(); - } - - public InputLocationMessageContent(Float latitude, Float longitude) { - super(); - this.latitude = checkNotNull(latitude); - this.longitude = checkNotNull(longitude); - } - - public Float getLongitude() { - return longitude; - } - - public InputLocationMessageContent setLongitude(Float longitude) { - Objects.requireNonNull(longitude); - this.longitude = longitude; - return this; - } - - public Float getLatitude() { - return latitude; - } - - public InputLocationMessageContent setLatitude(Float latitude) { - Objects.requireNonNull(latitude); - this.latitude = latitude; - return this; - } - - public Integer getLivePeriod() { - return livePeriod; - } - - public InputLocationMessageContent setLivePeriod(Integer livePeriod) { - this.livePeriod = livePeriod; - return this; - } - @Override public void validate() throws TelegramApiValidationException { if (latitude == null) { @@ -81,13 +48,4 @@ public class InputLocationMessageContent implements InputMessageContent { throw new TelegramApiValidationException("Live period parameter must be between 60 and 86400", this); } } - - @Override - public String toString() { - return "InputLocationMessageContent{" + - "latitude=" + latitude + - ", longitude=" + longitude + - ", livePeriod=" + livePeriod + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java index 70268150..0f529854 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java @@ -1,9 +1,12 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent; import com.fasterxml.jackson.annotation.JsonProperty; - import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.telegram.telegrambots.meta.api.methods.ParseMode; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; /** @@ -12,6 +15,10 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; * Represents the content of a text message to be sent as the result of an inline query. */ @JsonDeserialize +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class InputTextMessageContent implements InputMessageContent { private static final String MESSAGETEXT_FIELD = "message_text"; @@ -19,84 +26,17 @@ public class InputTextMessageContent implements InputMessageContent { private static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview"; @JsonProperty(MESSAGETEXT_FIELD) + @NonNull private String messageText; ///< Text of a message to be sent, 1-4096 characters @JsonProperty(PARSEMODE_FIELD) private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. @JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD) private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message - public InputTextMessageContent() { - super(); - } - - public String getMessageText() { - return messageText; - } - - public InputTextMessageContent setMessageText(String messageText) { - this.messageText = messageText; - return this; - } - - public String getParseMode() { - return parseMode; - } - - public InputTextMessageContent setParseMode(String parseMode) { - this.parseMode = parseMode; - return this; - } - - public Boolean getDisableWebPagePreview() { - return disableWebPagePreview; - } - - public InputTextMessageContent setDisableWebPagePreview(Boolean disableWebPagePreview) { - this.disableWebPagePreview = disableWebPagePreview; - return this; - } - - public InputTextMessageContent enableMarkdown(boolean enable) { - if (enable) { - this.parseMode = ParseMode.MARKDOWN; - } else { - this.parseMode = null; - } - return this; - } - - public InputTextMessageContent enableHtml(boolean enable) { - if (enable) { - this.parseMode = ParseMode.HTML; - } else { - this.parseMode = null; - } - return this; - } - - public InputTextMessageContent disableWebPagePreview() { - disableWebPagePreview = true; - return this; - } - - public InputTextMessageContent enableWebPagePreview() { - disableWebPagePreview = null; - return this; - } - @Override public void validate() throws TelegramApiValidationException { if (messageText == null || messageText.isEmpty()) { throw new TelegramApiValidationException("MessageText parameter can't be empty", this); } } - - @Override - public String toString() { - return "InputTextMessageContent{" + - ", messageText='" + messageText + '\'' + - ", parseMode='" + parseMode + '\'' + - ", disableWebPagePreview=" + disableWebPagePreview + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java index fe8ef9e0..68b0f945 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java @@ -3,16 +3,25 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessageconte import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; /** * @author Ruben Bermudez * @version 1.0 * Represents the content of a venue message to be sent as the result of an inline query. - * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will + * @apiNote This will only work in Telegram versions released after 9 April, 2016. Older clients will * ignore them. */ @JsonDeserialize +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class InputVenueMessageContent implements InputMessageContent { private static final String LATITUDE_FIELD = "latitude"; @@ -23,77 +32,22 @@ public class InputVenueMessageContent implements InputMessageContent { private static final String FOURSQUARETYPE_FIELD = "foursquare_type"; @JsonProperty(LATITUDE_FIELD) + @NonNull private Float latitude; ///< Latitude of the venue in degrees @JsonProperty(LONGITUDE_FIELD) + @NonNull private Float longitude; ///< Longitude of the venue in degrees @JsonProperty(TITLE_FIELD) + @NonNull private String title; ///< Name of the venue @JsonProperty(ADDRESS_FIELD) + @NonNull private String address; ///< Address of the venue @JsonProperty(FOURSQUAREID_FIELD) private String foursquareId; ///< Optional. Foursquare identifier of the venue, if known @JsonProperty(FOURSQUARETYPE_FIELD) private String foursquareType; ///< Optional. Foursquare type of the venue, if known. - - public InputVenueMessageContent() { - super(); - } - - public Float getLatitude() { - return latitude; - } - - public InputVenueMessageContent setLatitude(Float latitude) { - this.latitude = latitude; - return this; - } - - public Float getLongitude() { - return longitude; - } - - public InputVenueMessageContent setLongitude(Float longitude) { - this.longitude = longitude; - return this; - } - - public String getTitle() { - return title; - } - - public InputVenueMessageContent setTitle(String title) { - this.title = title; - return this; - } - - public String getAddress() { - return address; - } - - public InputVenueMessageContent setAddress(String address) { - this.address = address; - return this; - } - - public String getFoursquareId() { - return foursquareId; - } - - public InputVenueMessageContent setFoursquareId(String foursquareId) { - this.foursquareId = foursquareId; - return this; - } - - public String getFoursquareType() { - return foursquareType; - } - - public InputVenueMessageContent setFoursquareType(String foursquareType) { - this.foursquareType = foursquareType; - return this; - } - @Override public void validate() throws TelegramApiValidationException { if (latitude == null) { @@ -109,16 +63,4 @@ public class InputVenueMessageContent implements InputMessageContent { throw new TelegramApiValidationException("Address parameter can't be empty", this); } } - - @Override - public String toString() { - return "InputVenueMessageContent{" + - "latitude=" + latitude + - ", longitude=" + longitude + - ", title='" + title + '\'' + - ", address='" + address + '\'' + - ", foursquareId='" + foursquareId + '\'' + - ", foursquareType='" + foursquareType + '\'' + - '}'; - } }