Merge pull request #538 from aNNiMON/stickerpositioninset-fix

Fix setStickerPositionInSet
This commit is contained in:
Ruben Bermudez 2018-12-11 00:49:30 +00:00 committed by GitHub
commit d420625e7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,14 +17,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success.
*/
public class SetStickerPositionInSet extends BotApiMethod<Boolean> {
private static final String PATH = "getStickerSet";
private static final String PATH = "setStickerPositionInSet";
private static final String STICKER_FIELD = "sticker";
private static final String POSITION_FIELD = "position";
@JsonProperty(STICKER_FIELD)
private String sticker; ///< File identifier of the sticker
@JsonProperty(STICKER_FIELD)
@JsonProperty(POSITION_FIELD)
private Integer position; ///< New sticker position in the set, zero-based
public SetStickerPositionInSet(String sticker, Integer position) {
@ -61,7 +61,7 @@ public class SetStickerPositionInSet extends BotApiMethod<Boolean> {
if (sticker == null || sticker.isEmpty()) {
throw new TelegramApiValidationException("sticker can't be null", this);
}
if (position == null || position > 0) {
if (position == null || position < 0) {
throw new TelegramApiValidationException("position can't be null", this);
}
}
@ -71,7 +71,7 @@ public class SetStickerPositionInSet extends BotApiMethod<Boolean> {
}
public SetStickerPositionInSet setSticker(String sticker) {
this.sticker = sticker;
this.sticker = checkNotNull(sticker);
return this;
}
@ -80,7 +80,7 @@ public class SetStickerPositionInSet extends BotApiMethod<Boolean> {
}
public SetStickerPositionInSet setPosition(Integer position) {
this.position = position;
this.position = checkNotNull(position);
return this;
}