Skip to content

Commit 46fdd82

Browse files
committed
Added the fields set_name and mask_position to the Sticker object, plus two new objects, StickerSet, and MaskPosition
1 parent 360c5b5 commit 46fdd82

File tree

4 files changed

+166
-0
lines changed

4 files changed

+166
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package com.pengrad.telegrambot.model;
2+
3+
import com.google.gson.Gson;
4+
5+
import java.io.Serializable;
6+
7+
/**
8+
* Stas Parshin
9+
* 23 July 2017
10+
*/
11+
public class MaskPosition implements Serializable {
12+
private final static long serialVersionUID = 0L;
13+
private final static Gson gson = new Gson();
14+
15+
public enum Point {
16+
forehead, eyes, mouth, chin
17+
}
18+
19+
private String point;
20+
private Float x_shift, y_shift;
21+
private Float scale;
22+
23+
public MaskPosition() {
24+
}
25+
26+
public MaskPosition(Point point, Float x_shift, Float y_shift, Float scale) {
27+
this(point.name(), x_shift, y_shift, scale);
28+
}
29+
30+
public MaskPosition(String point, Float xShift, Float yShift, Float scale) {
31+
this.point = point;
32+
this.x_shift = xShift;
33+
this.y_shift = yShift;
34+
this.scale = scale;
35+
}
36+
37+
public String point() {
38+
return point;
39+
}
40+
41+
public Float xShift() {
42+
return x_shift;
43+
}
44+
45+
public Float yShift() {
46+
return y_shift;
47+
}
48+
49+
public Float scale() {
50+
return scale;
51+
}
52+
53+
@Override
54+
public boolean equals(Object o) {
55+
if (this == o) return true;
56+
if (o == null || getClass() != o.getClass()) return false;
57+
58+
MaskPosition that = (MaskPosition) o;
59+
60+
if (point != null ? !point.equals(that.point) : that.point != null) return false;
61+
if (x_shift != null ? !x_shift.equals(that.x_shift) : that.x_shift != null) return false;
62+
if (y_shift != null ? !y_shift.equals(that.y_shift) : that.y_shift != null) return false;
63+
return scale != null ? scale.equals(that.scale) : that.scale == null;
64+
}
65+
66+
@Override
67+
public int hashCode() {
68+
int result = point != null ? point.hashCode() : 0;
69+
result = 31 * result + (x_shift != null ? x_shift.hashCode() : 0);
70+
result = 31 * result + (y_shift != null ? y_shift.hashCode() : 0);
71+
result = 31 * result + (scale != null ? scale.hashCode() : 0);
72+
return result;
73+
}
74+
75+
@Override
76+
public String toString() {
77+
return "MaskPosition{" +
78+
"point='" + point + '\'' +
79+
", x_shift=" + x_shift +
80+
", y_shift=" + y_shift +
81+
", scale=" + scale +
82+
'}';
83+
}
84+
}

library/src/main/java/com/pengrad/telegrambot/model/Sticker.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class Sticker implements Serializable {
1414
private Integer height;
1515
private PhotoSize thumb;
1616
private String emoji;
17+
private String set_name;
18+
private MaskPosition mask_position;
1719
private Integer file_size;
1820

1921
public String fileId() {
@@ -36,6 +38,14 @@ public String emoji() {
3638
return emoji;
3739
}
3840

41+
public String setName() {
42+
return set_name;
43+
}
44+
45+
public MaskPosition maskPosition() {
46+
return mask_position;
47+
}
48+
3949
public Integer fileSize() {
4050
return file_size;
4151
}
@@ -52,6 +62,8 @@ public boolean equals(Object o) {
5262
if (height != null ? !height.equals(sticker.height) : sticker.height != null) return false;
5363
if (thumb != null ? !thumb.equals(sticker.thumb) : sticker.thumb != null) return false;
5464
if (emoji != null ? !emoji.equals(sticker.emoji) : sticker.emoji != null) return false;
65+
if (set_name != null ? !set_name.equals(sticker.set_name) : sticker.set_name != null) return false;
66+
if (mask_position != null ? !mask_position.equals(sticker.mask_position) : sticker.mask_position != null) return false;
5567
return file_size != null ? file_size.equals(sticker.file_size) : sticker.file_size == null;
5668
}
5769

@@ -68,6 +80,8 @@ public String toString() {
6880
", height=" + height +
6981
", thumb=" + thumb +
7082
", emoji='" + emoji + '\'' +
83+
", set_name='" + set_name + '\'' +
84+
", mask_position=" + mask_position +
7185
", file_size=" + file_size +
7286
'}';
7387
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.pengrad.telegrambot.model;
2+
3+
import java.io.Serializable;
4+
import java.util.Arrays;
5+
6+
/**
7+
* Stas Parshin
8+
* 23 July 2017
9+
*/
10+
public class StickerSet implements Serializable {
11+
private final static long serialVersionUID = 0L;
12+
13+
private String name;
14+
private String title;
15+
private Boolean contains_masks;
16+
private Sticker[] stickers;
17+
18+
public String name() {
19+
return name;
20+
}
21+
22+
public String title() {
23+
return title;
24+
}
25+
26+
public Boolean containsMasks() {
27+
return contains_masks;
28+
}
29+
30+
public Sticker[] stickers() {
31+
return stickers;
32+
}
33+
34+
@Override
35+
public boolean equals(Object o) {
36+
if (this == o) return true;
37+
if (o == null || getClass() != o.getClass()) return false;
38+
39+
StickerSet that = (StickerSet) o;
40+
41+
if (name != null ? !name.equals(that.name) : that.name != null) return false;
42+
if (title != null ? !title.equals(that.title) : that.title != null) return false;
43+
if (contains_masks != null ? !contains_masks.equals(that.contains_masks) : that.contains_masks != null) return false;
44+
// Probably incorrect - comparing Object[] arrays with Arrays.equals
45+
return Arrays.equals(stickers, that.stickers);
46+
}
47+
48+
@Override
49+
public int hashCode() {
50+
int result = name != null ? name.hashCode() : 0;
51+
result = 31 * result + (title != null ? title.hashCode() : 0);
52+
result = 31 * result + (contains_masks != null ? contains_masks.hashCode() : 0);
53+
result = 31 * result + Arrays.hashCode(stickers);
54+
return result;
55+
}
56+
57+
@Override
58+
public String toString() {
59+
return "StickerSet{" +
60+
"name='" + name + '\'' +
61+
", title='" + title + '\'' +
62+
", contains_masks=" + contains_masks +
63+
", stickers=" + Arrays.toString(stickers) +
64+
'}';
65+
}
66+
}

library/src/test/java/com/pengrad/telegrambot/ModelTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public void setClasses() {
3737
InlineQuery.class,
3838
Invoice.class,
3939
Location.class,
40+
MaskPosition.class,
4041
Message.class,
4142
MessageEntity.class,
4243
OrderInfo.class,
@@ -46,6 +47,7 @@ public void setClasses() {
4647
ShippingAddress.class,
4748
ShippingQuery.class,
4849
Sticker.class,
50+
StickerSet.class,
4951
SuccessfulPayment.class,
5052
Update.class,
5153
User.class,

0 commit comments

Comments
 (0)