Added lombok

This commit is contained in:
rubenlagus 2020-10-31 13:41:05 +00:00 committed by Ruben Bermudez
parent 0a58ef7120
commit 4fb51ec99c
14 changed files with 107 additions and 508 deletions

View File

@ -74,10 +74,17 @@
<jackson.version>2.10.1</jackson.version> <jackson.version>2.10.1</jackson.version>
<slf4j.version>1.7.29</slf4j.version> <slf4j.version>1.7.29</slf4j.version>
<jakarta.annotation.version>1.3.5</jakarta.annotation.version> <jakarta.annotation.version>1.3.5</jakarta.annotation.version>
<lombok.version>1.18.16</lombok.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId> <artifactId>junit-jupiter-api</artifactId>

View File

@ -114,6 +114,11 @@
<artifactId>json</artifactId> <artifactId>json</artifactId>
<version>${json.version}</version> <version>${json.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -3,6 +3,7 @@ package org.telegram.telegrambots.meta.api.methods;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -14,6 +15,7 @@ import java.io.Serializable;
*/ */
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@Data
public abstract class BotApiMethod<T extends Serializable> extends PartialBotApiMethod<T> { public abstract class BotApiMethod<T extends Serializable> extends PartialBotApiMethod<T> {
protected static final String METHOD_FIELD = "method"; protected static final String METHOD_FIELD = "method";

View File

@ -1,17 +1,24 @@
package org.telegram.telegrambots.meta.api.objects.commands; package org.telegram.telegrambots.meta.api.objects.commands;
import com.fasterxml.jackson.annotation.JsonProperty; 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.BotApiObject;
import org.telegram.telegrambots.meta.api.interfaces.Validable; import org.telegram.telegrambots.meta.api.interfaces.Validable;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 4.7 * @version 4.7
* This object represents a bot command. * This object represents a bot command.
*/ */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class BotCommand implements BotApiObject, Validable { public class BotCommand implements BotApiObject, Validable {
private static final String COMMAND_FIELD = "command"; private static final String COMMAND_FIELD = "command";
private static final String DESCRIPTION_FIELD = "description"; 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. * Text of the command. Can contain only lowercase English letters, digits and underscores. 1-32 characters.
*/ */
@JsonProperty(COMMAND_FIELD) @JsonProperty(COMMAND_FIELD)
@NonNull
private String command; ///< Value of the dice, 1-6 private String command; ///< Value of the dice, 1-6
@JsonProperty(DESCRIPTION_FIELD) @JsonProperty(DESCRIPTION_FIELD)
@NonNull
private String description; ///< Description of the command, 3-256 characters. 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 @Override
public void validate() throws TelegramApiValidationException { public void validate() throws TelegramApiValidationException {
if (command == null || command.isEmpty()) { 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); throw new TelegramApiValidationException("Description parameter can't be empty", this);
} }
} }
@Override
public String toString() {
return "BotCommand{" +
"command='" + command + '\'' +
", description='" + description + '\'' +
'}';
}
} }

View File

@ -17,6 +17,8 @@
package org.telegram.telegrambots.meta.api.objects.games; package org.telegram.telegrambots.meta.api.objects.games;
import com.fasterxml.jackson.annotation.JsonProperty; 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.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.objects.PhotoSize; import org.telegram.telegrambots.meta.api.objects.PhotoSize;
@ -25,6 +27,8 @@ import org.telegram.telegrambots.meta.api.objects.PhotoSize;
* @version 2.4 * @version 2.4
* This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). * This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
*/ */
@Data
@NoArgsConstructor
public class Animation implements BotApiObject { public class Animation implements BotApiObject {
private static final String FILEID_FIELD = "file_id"; private static final String FILEID_FIELD = "file_id";
private static final String FILEUNIQUEID_FIELD = "file_unique_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 private String mimetype; ///< Optional. MIME type of the file as defined by sender
@JsonProperty(FILESIZE_FIELD) @JsonProperty(FILESIZE_FIELD)
private Integer fileSize; ///< Optional. File size 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 +
'}';
}
} }

View File

@ -17,31 +17,16 @@
package org.telegram.telegrambots.meta.api.objects.games; package org.telegram.telegrambots.meta.api.objects.games;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 2.4 * @version 2.4
* @brief A placeholder, currently holds no information. Use BotFather to set up your game. * A placeholder, currently holds no information. Use BotFather to set up your game.
* @date 16 of September of 2016
*/ */
@Data
@NoArgsConstructor
public class CallbackGame implements BotApiObject { 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();
}
} }

View File

@ -17,7 +17,8 @@
package org.telegram.telegrambots.meta.api.objects.games; package org.telegram.telegrambots.meta.api.objects.games;
import com.fasterxml.jackson.annotation.JsonProperty; 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.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.objects.MessageEntity; import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.PhotoSize; import org.telegram.telegrambots.meta.api.objects.PhotoSize;
@ -27,10 +28,11 @@ import java.util.List;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 2.4 * @version 2.4
* @brief This object represents a game. * This object represents a game.
* Use BotFather to create and edit games, their short names will act as unique identifiers. * @apiNote Use BotFather to create and edit games, their short names will act as unique identifiers.
* @date 27 of September of 2016
*/ */
@Data
@NoArgsConstructor
public class Game implements BotApiObject { public class Game implements BotApiObject {
private static final String TITLE_FIELD = "title"; private static final String TITLE_FIELD = "title";
@ -63,45 +65,7 @@ public class Game implements BotApiObject {
@JsonProperty(ANIMATION_FIELD) @JsonProperty(ANIMATION_FIELD)
private Animation animation; ///< Optional. Animation private Animation animation; ///< Optional. Animation
public Game() {
super();
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public List<PhotoSize> getPhoto() {
return photo;
}
public Animation getAnimation() {
return animation;
}
public String getText() {
return text;
}
public boolean hasEntities() { public boolean hasEntities() {
return entities != null && !entities.isEmpty(); return entities != null && !entities.isEmpty();
} }
public List<MessageEntity> getEntities() {
return entities;
}
@Override
public String toString() {
return "Game{" +
"title='" + title + '\'' +
", description='" + description + '\'' +
", photo=" + photo +
", animation=" + animation +
'}';
}
} }

View File

@ -18,16 +18,18 @@
package org.telegram.telegrambots.meta.api.objects.games; package org.telegram.telegrambots.meta.api.objects.games;
import com.fasterxml.jackson.annotation.JsonProperty; 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.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.objects.User; import org.telegram.telegrambots.meta.api.objects.User;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief This object represents one row of a game high scores table * This object represents one row of a game high scores table
* @date 25 of September of 2016
*/ */
@Data
@NoArgsConstructor
public class GameHighScore implements BotApiObject { public class GameHighScore implements BotApiObject {
private static final String POSITION_FIELD = "position"; private static final String POSITION_FIELD = "position";
private static final String USER_FIELD = "user"; private static final String USER_FIELD = "user";
@ -39,25 +41,4 @@ public class GameHighScore implements BotApiObject {
private User user; ///< User private User user; ///< User
@JsonProperty(SCORE_FIELD) @JsonProperty(SCORE_FIELD)
private Integer score; ///< Score 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 +
'}';
}
} }

View File

@ -2,6 +2,9 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery;
import com.fasterxml.jackson.annotation.JsonProperty; 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.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.objects.Location; import org.telegram.telegrambots.meta.api.objects.Location;
import org.telegram.telegrambots.meta.api.objects.User; import org.telegram.telegrambots.meta.api.objects.User;
@ -9,10 +12,12 @@ import org.telegram.telegrambots.meta.api.objects.User;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @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. * partner.
* @date 01 of January of 2016
*/ */
@Data
@NoArgsConstructor
@Builder
public class ChosenInlineQuery implements BotApiObject { public class ChosenInlineQuery implements BotApiObject {
private static final String RESULTID_FIELD = "result_id"; private static final String RESULTID_FIELD = "result_id";
private static final String FROM_FIELD = "from"; private static final String FROM_FIELD = "from";
@ -36,39 +41,4 @@ public class ChosenInlineQuery implements BotApiObject {
private String inlineMessageId; private String inlineMessageId;
@JsonProperty(QUERY_FIELD) @JsonProperty(QUERY_FIELD)
private String query; ///< The query that was used to obtain the result. 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 + '\'' +
'}';
}
} }

View File

@ -2,6 +2,9 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery;
import com.fasterxml.jackson.annotation.JsonProperty; 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.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.objects.Location; import org.telegram.telegrambots.meta.api.objects.Location;
import org.telegram.telegrambots.meta.api.objects.User; import org.telegram.telegrambots.meta.api.objects.User;
@ -9,10 +12,12 @@ import org.telegram.telegrambots.meta.api.objects.User;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @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. * bot could return some default or trending results.
* @date 01 of January of 2016
*/ */
@Data
@NoArgsConstructor
@Builder
public class InlineQuery implements BotApiObject { public class InlineQuery implements BotApiObject {
private static final String ID_FIELD = "id"; private static final String ID_FIELD = "id";
private static final String FROM_FIELD = "from"; private static final String FROM_FIELD = "from";
@ -30,48 +35,5 @@ public class InlineQuery implements BotApiObject {
private String query; ///< Text of the query private String query; ///< Text of the query
@JsonProperty(OFFSET_FIELD) @JsonProperty(OFFSET_FIELD)
private String offset; ///< Offset of the results to be returned, can be controlled by the bot 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 + '\'' +
'}';
}
} }

View File

@ -1,18 +1,26 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent; package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 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 org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* Represents the content of a contact message to be sent as the result of an inline query * 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. * ignore them.
*/ */
@JsonDeserialize @JsonDeserialize
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class InputContactMessageContent implements InputMessageContent { public class InputContactMessageContent implements InputMessageContent {
private static final String PHONE_NUMBER_FIELD = "phone_number"; 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"; private static final String VCARD_FIELD = "vcard";
@JsonProperty(PHONE_NUMBER_FIELD) @JsonProperty(PHONE_NUMBER_FIELD)
@NonNull
private String phoneNumber; ///< Contact's phone number private String phoneNumber; ///< Contact's phone number
@JsonProperty(FIRST_NAME_FIELD) @JsonProperty(FIRST_NAME_FIELD)
@NonNull
private String firstName; ///< Contact's first name private String firstName; ///< Contact's first name
@JsonProperty(LAST_NAME_FIELD) @JsonProperty(LAST_NAME_FIELD)
private String lastName; ///< Optional. Contact's last name private String lastName; ///< Optional. Contact's last name
@JsonProperty(VCARD_FIELD) @JsonProperty(VCARD_FIELD)
private String vCard; ///< Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes 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 @Override
public void validate() throws TelegramApiValidationException { public void validate() throws TelegramApiValidationException {
if (phoneNumber == null || phoneNumber.isEmpty()) { if (phoneNumber == null || phoneNumber.isEmpty()) {
@ -78,14 +48,4 @@ public class InputContactMessageContent implements InputMessageContent {
throw new TelegramApiValidationException("FirstName parameter can't be empty", this); throw new TelegramApiValidationException("FirstName parameter can't be empty", this);
} }
} }
@Override
public String toString() {
return "InputContactMessageContent{" +
"phoneNumber='" + phoneNumber + '\'' +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", vCard='" + vCard + '\'' +
'}';
}
} }

View File

@ -1,22 +1,26 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent; package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 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 org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* Represents the content of a location message to be sent as the result of an inline query. * 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. * ignore them.
*/ */
@JsonDeserialize @JsonDeserialize
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class InputLocationMessageContent implements InputMessageContent { public class InputLocationMessageContent implements InputMessageContent {
private static final String LATITUDE_FIELD = "latitude"; private static final String LATITUDE_FIELD = "latitude";
@ -24,51 +28,14 @@ public class InputLocationMessageContent implements InputMessageContent {
private static final String LIVEPERIOD_FIELD = "live_period"; private static final String LIVEPERIOD_FIELD = "live_period";
@JsonProperty(LATITUDE_FIELD) @JsonProperty(LATITUDE_FIELD)
@NonNull
private Float latitude; ///< Latitude of the location in degrees private Float latitude; ///< Latitude of the location in degrees
@JsonProperty(LONGITUDE_FIELD) @JsonProperty(LONGITUDE_FIELD)
@NonNull
private Float longitude; ///< Longitude of the location in degrees private Float longitude; ///< Longitude of the location in degrees
@JsonProperty(LIVEPERIOD_FIELD) @JsonProperty(LIVEPERIOD_FIELD)
private Integer livePeriod; ///< Optional. Period in seconds for which the location can be updated, should be between 60 and 86400. 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 @Override
public void validate() throws TelegramApiValidationException { public void validate() throws TelegramApiValidationException {
if (latitude == null) { 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); 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 +
'}';
}
} }

View File

@ -1,9 +1,12 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent; package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 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; 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. * Represents the content of a text message to be sent as the result of an inline query.
*/ */
@JsonDeserialize @JsonDeserialize
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class InputTextMessageContent implements InputMessageContent { public class InputTextMessageContent implements InputMessageContent {
private static final String MESSAGETEXT_FIELD = "message_text"; 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"; private static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
@JsonProperty(MESSAGETEXT_FIELD) @JsonProperty(MESSAGETEXT_FIELD)
@NonNull
private String messageText; ///< Text of a message to be sent, 1-4096 characters private String messageText; ///< Text of a message to be sent, 1-4096 characters
@JsonProperty(PARSEMODE_FIELD) @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. 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) @JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message 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 @Override
public void validate() throws TelegramApiValidationException { public void validate() throws TelegramApiValidationException {
if (messageText == null || messageText.isEmpty()) { if (messageText == null || messageText.isEmpty()) {
throw new TelegramApiValidationException("MessageText parameter can't be empty", this); throw new TelegramApiValidationException("MessageText parameter can't be empty", this);
} }
} }
@Override
public String toString() {
return "InputTextMessageContent{" +
", messageText='" + messageText + '\'' +
", parseMode='" + parseMode + '\'' +
", disableWebPagePreview=" + disableWebPagePreview +
'}';
}
} }

View File

@ -3,16 +3,25 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessageconte
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 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 org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* Represents the content of a venue message to be sent as the result of an inline query. * 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. * ignore them.
*/ */
@JsonDeserialize @JsonDeserialize
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class InputVenueMessageContent implements InputMessageContent { public class InputVenueMessageContent implements InputMessageContent {
private static final String LATITUDE_FIELD = "latitude"; private static final String LATITUDE_FIELD = "latitude";
@ -23,77 +32,22 @@ public class InputVenueMessageContent implements InputMessageContent {
private static final String FOURSQUARETYPE_FIELD = "foursquare_type"; private static final String FOURSQUARETYPE_FIELD = "foursquare_type";
@JsonProperty(LATITUDE_FIELD) @JsonProperty(LATITUDE_FIELD)
@NonNull
private Float latitude; ///< Latitude of the venue in degrees private Float latitude; ///< Latitude of the venue in degrees
@JsonProperty(LONGITUDE_FIELD) @JsonProperty(LONGITUDE_FIELD)
@NonNull
private Float longitude; ///< Longitude of the venue in degrees private Float longitude; ///< Longitude of the venue in degrees
@JsonProperty(TITLE_FIELD) @JsonProperty(TITLE_FIELD)
@NonNull
private String title; ///< Name of the venue private String title; ///< Name of the venue
@JsonProperty(ADDRESS_FIELD) @JsonProperty(ADDRESS_FIELD)
@NonNull
private String address; ///< Address of the venue private String address; ///< Address of the venue
@JsonProperty(FOURSQUAREID_FIELD) @JsonProperty(FOURSQUAREID_FIELD)
private String foursquareId; ///< Optional. Foursquare identifier of the venue, if known private String foursquareId; ///< Optional. Foursquare identifier of the venue, if known
@JsonProperty(FOURSQUARETYPE_FIELD) @JsonProperty(FOURSQUARETYPE_FIELD)
private String foursquareType; ///< Optional. Foursquare type of the venue, if known. 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 @Override
public void validate() throws TelegramApiValidationException { public void validate() throws TelegramApiValidationException {
if (latitude == null) { if (latitude == null) {
@ -109,16 +63,4 @@ public class InputVenueMessageContent implements InputMessageContent {
throw new TelegramApiValidationException("Address parameter can't be empty", this); 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 + '\'' +
'}';
}
} }