Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add common method getType to ReactionType interface #1382

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

aNNiMON
Copy link
Contributor

@aNNiMON aNNiMON commented Jun 16, 2024

No description provided.

@Chase22
Copy link
Collaborator

Chase22 commented Jun 28, 2024

Not a big fan of making a generated override for an interface method. The getter is generated in the subtypes using Lombok. I'd argue for explicitly implementing the getter in this case to make the inheritance clearer @rubenlagus your opinion?

@aNNiMON
Copy link
Contributor Author

aNNiMON commented Jun 28, 2024

@Chase22, this change helps to quickly check a type of reaction by using a getter instead of ugly instanceof.
property = "type" => getType()

property = "type"
)
@JsonSubTypes({
@JsonSubTypes.Type(value = ReactionTypeEmoji.class, name = ReactionType.EMOJI_TYPE),
@JsonSubTypes.Type(value = ReactionTypeCustomEmoji.class, name = ReactionType.CUSTOM_EMOJI_TYPE)
})
public interface ReactionType extends Validable, BotApiObject {
String EMOJI_TYPE = "emoji";
String CUSTOM_EMOJI_TYPE = "custom_emoji";

Literally the same was done here: property = "status" => getStatus()

property = "status")
@JsonSubTypes({
@JsonSubTypes.Type(value = ChatMemberAdministrator.class, name = "administrator"),
@JsonSubTypes.Type(value = ChatMemberBanned.class, name = "kicked"),
@JsonSubTypes.Type(value = ChatMemberLeft.class, name = "left"),
@JsonSubTypes.Type(value = ChatMemberMember.class, name = "member"),
@JsonSubTypes.Type(value = ChatMemberOwner.class, name = "creator"),
@JsonSubTypes.Type(value = ChatMemberRestricted.class, name = "restricted"),
})
public interface ChatMember extends BotApiObject {
String getStatus();

And here:

property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = MenuButtonDefault.class, name = "default"),
@JsonSubTypes.Type(value = MenuButtonWebApp.class, name = "web_app"),
@JsonSubTypes.Type(value = MenuButtonCommands.class, name = "commands")
})
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@SuperBuilder
public abstract class MenuButton implements BotApiObject, Validable {
public static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
public abstract String getType();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants