-
-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the fields set_name and mask_position to the Sticker object, pl…
…us two new objects, StickerSet, and MaskPosition
- Loading branch information
Showing
4 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
library/src/main/java/com/pengrad/telegrambot/model/MaskPosition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.pengrad.telegrambot.model; | ||
|
||
import com.google.gson.Gson; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* Stas Parshin | ||
* 23 July 2017 | ||
*/ | ||
public class MaskPosition implements Serializable { | ||
private final static long serialVersionUID = 0L; | ||
private final static Gson gson = new Gson(); | ||
|
||
public enum Point { | ||
forehead, eyes, mouth, chin | ||
} | ||
|
||
private String point; | ||
private Float x_shift, y_shift; | ||
private Float scale; | ||
|
||
public MaskPosition() { | ||
} | ||
|
||
public MaskPosition(Point point, Float x_shift, Float y_shift, Float scale) { | ||
this(point.name(), x_shift, y_shift, scale); | ||
} | ||
|
||
public MaskPosition(String point, Float xShift, Float yShift, Float scale) { | ||
this.point = point; | ||
this.x_shift = xShift; | ||
this.y_shift = yShift; | ||
this.scale = scale; | ||
} | ||
|
||
public String point() { | ||
return point; | ||
} | ||
|
||
public Float xShift() { | ||
return x_shift; | ||
} | ||
|
||
public Float yShift() { | ||
return y_shift; | ||
} | ||
|
||
public Float scale() { | ||
return scale; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
MaskPosition that = (MaskPosition) o; | ||
|
||
if (point != null ? !point.equals(that.point) : that.point != null) return false; | ||
if (x_shift != null ? !x_shift.equals(that.x_shift) : that.x_shift != null) return false; | ||
if (y_shift != null ? !y_shift.equals(that.y_shift) : that.y_shift != null) return false; | ||
return scale != null ? scale.equals(that.scale) : that.scale == null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = point != null ? point.hashCode() : 0; | ||
result = 31 * result + (x_shift != null ? x_shift.hashCode() : 0); | ||
result = 31 * result + (y_shift != null ? y_shift.hashCode() : 0); | ||
result = 31 * result + (scale != null ? scale.hashCode() : 0); | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MaskPosition{" + | ||
"point='" + point + '\'' + | ||
", x_shift=" + x_shift + | ||
", y_shift=" + y_shift + | ||
", scale=" + scale + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
library/src/main/java/com/pengrad/telegrambot/model/StickerSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.pengrad.telegrambot.model; | ||
|
||
import java.io.Serializable; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* Stas Parshin | ||
* 23 July 2017 | ||
*/ | ||
public class StickerSet implements Serializable { | ||
private final static long serialVersionUID = 0L; | ||
|
||
private String name; | ||
private String title; | ||
private Boolean contains_masks; | ||
private Sticker[] stickers; | ||
|
||
public String name() { | ||
return name; | ||
} | ||
|
||
public String title() { | ||
return title; | ||
} | ||
|
||
public Boolean containsMasks() { | ||
return contains_masks; | ||
} | ||
|
||
public Sticker[] stickers() { | ||
return stickers; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
StickerSet that = (StickerSet) o; | ||
|
||
if (name != null ? !name.equals(that.name) : that.name != null) return false; | ||
if (title != null ? !title.equals(that.title) : that.title != null) return false; | ||
if (contains_masks != null ? !contains_masks.equals(that.contains_masks) : that.contains_masks != null) return false; | ||
// Probably incorrect - comparing Object[] arrays with Arrays.equals | ||
return Arrays.equals(stickers, that.stickers); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = name != null ? name.hashCode() : 0; | ||
result = 31 * result + (title != null ? title.hashCode() : 0); | ||
result = 31 * result + (contains_masks != null ? contains_masks.hashCode() : 0); | ||
result = 31 * result + Arrays.hashCode(stickers); | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "StickerSet{" + | ||
"name='" + name + '\'' + | ||
", title='" + title + '\'' + | ||
", contains_masks=" + contains_masks + | ||
", stickers=" + Arrays.toString(stickers) + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters