Skip to content

Commit

Permalink
Update Stickers equals()
Browse files Browse the repository at this point in the history
  • Loading branch information
pengrad committed Feb 5, 2022
1 parent 1a7bc45 commit 4b80202
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
26 changes: 13 additions & 13 deletions library/src/main/java/com/pengrad/telegrambot/model/Sticker.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pengrad.telegrambot.model;

import java.io.Serializable;
import java.util.Objects;

/**
* stas
Expand Down Expand Up @@ -69,20 +70,18 @@ public Integer fileSize() {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Sticker sticker = (Sticker) o;

if (file_id != null ? !file_id.equals(sticker.file_id) : sticker.file_id != null) return false;
if (file_unique_id != null ? !file_unique_id.equals(sticker.file_unique_id) : sticker.file_unique_id != null)
return false;
if (width != null ? !width.equals(sticker.width) : sticker.width != null) return false;
if (height != null ? !height.equals(sticker.height) : sticker.height != null) return false;
if (is_animated != null ? !is_animated.equals(sticker.is_animated) : sticker.is_animated != null) return false;
if (thumb != null ? !thumb.equals(sticker.thumb) : sticker.thumb != null) return false;
if (emoji != null ? !emoji.equals(sticker.emoji) : sticker.emoji != null) return false;
if (set_name != null ? !set_name.equals(sticker.set_name) : sticker.set_name != null) return false;
if (mask_position != null ? !mask_position.equals(sticker.mask_position) : sticker.mask_position != null) return false;
return file_size != null ? file_size.equals(sticker.file_size) : sticker.file_size == null;
return Objects.equals(file_id, sticker.file_id) &&
Objects.equals(file_unique_id, sticker.file_unique_id) &&
Objects.equals(width, sticker.width) &&
Objects.equals(height, sticker.height) &&
Objects.equals(is_animated, sticker.is_animated) &&
Objects.equals(is_video, sticker.is_video) &&
Objects.equals(thumb, sticker.thumb) &&
Objects.equals(emoji, sticker.emoji) &&
Objects.equals(set_name, sticker.set_name) &&
Objects.equals(mask_position, sticker.mask_position) &&
Objects.equals(file_size, sticker.file_size);
}

@Override
Expand All @@ -98,6 +97,7 @@ public String toString() {
", width=" + width +
", height=" + height +
", is_animated=" + is_animated +
", is_video=" + is_video +
", thumb=" + thumb +
", emoji='" + emoji + '\'' +
", set_name='" + set_name + '\'' +
Expand Down
27 changes: 10 additions & 17 deletions library/src/main/java/com/pengrad/telegrambot/model/StickerSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

/**
* Stas Parshin
Expand Down Expand Up @@ -50,29 +51,20 @@ public Boolean isVideo() {
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 (is_animated != null ? !is_animated.equals(that.is_animated) : that.is_animated != 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
if (!Arrays.equals(stickers, that.stickers)) return false;
if (thumb != null ? !thumb.equals(that.thumb) : that.thumb != null) return false;

return true;
return Objects.equals(name, that.name) &&
Objects.equals(title, that.title) &&
Objects.equals(is_animated, that.is_animated) &&
Objects.equals(is_video, that.is_video) &&
Objects.equals(contains_masks, that.contains_masks) &&
Arrays.equals(stickers, that.stickers) &&
Objects.equals(thumb, that.thumb);
}

@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (title != null ? title.hashCode() : 0);
result = 31 * result + (is_animated != null ? is_animated.hashCode() : 0);
result = 31 * result + (contains_masks != null ? contains_masks.hashCode() : 0);
int result = Objects.hash(name, title, is_animated, is_video, contains_masks, thumb);
result = 31 * result + Arrays.hashCode(stickers);
result = 31 * result + (thumb != null ? thumb.hashCode() : 0);
return result;
}

Expand All @@ -82,6 +74,7 @@ public String toString() {
"name='" + name + '\'' +
", title='" + title + '\'' +
", is_animated=" + is_animated +
", is_video=" + is_video +
", contains_masks=" + contains_masks +
", stickers=" + Arrays.toString(stickers) +
", thumb=" + thumb +
Expand Down

0 comments on commit 4b80202

Please sign in to comment.