diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundTypeUnknown.java b/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundTypeUnknown.java new file mode 100644 index 00000000..b5fb6c73 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundTypeUnknown.java @@ -0,0 +1,25 @@ +package com.pengrad.telegrambot.model.chatbackground; + +import java.util.Objects; + +public class BackgroundTypeUnknown extends BackgroundType { + + public static final String TYPE = "unknown"; + + public BackgroundTypeUnknown() { + super(TYPE); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + return true; + } + + @Override + public String toString() { + return "BackgroundTypeUnknown{" + + '}'; + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/BackgroundTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/BackgroundTypeAdapter.java index cf0100ab..c5302df9 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/BackgroundTypeAdapter.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/BackgroundTypeAdapter.java @@ -1,11 +1,7 @@ package com.pengrad.telegrambot.utility.gson; import com.google.gson.*; -import com.pengrad.telegrambot.model.chatbackground.BackgroundType; -import com.pengrad.telegrambot.model.chatbackground.BackgroundTypeChatTheme; -import com.pengrad.telegrambot.model.chatbackground.BackgroundTypeFill; -import com.pengrad.telegrambot.model.chatbackground.BackgroundTypePattern; -import com.pengrad.telegrambot.model.chatbackground.BackgroundTypeWallpaper; +import com.pengrad.telegrambot.model.chatbackground.*; import java.lang.reflect.Type; @@ -26,6 +22,6 @@ public BackgroundType deserialize(JsonElement element, Type type, JsonDeserializ return context.deserialize(object, BackgroundTypeChatTheme.class); } - return context.deserialize(object, BackgroundType.class); + return new BackgroundTypeUnknown(); } }