Skip to content

Commit

Permalink
Added missing javadocs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ygimenez committed Oct 2, 2024
1 parent da2cd2a commit 3b4eef3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
</dependency>
</dependencies>

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/github/ygimenez/model/ButtonId.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
package com.github.ygimenez.model;

import com.github.ygimenez.type.Emote;
import net.dv8tion.jda.api.entities.emoji.Emoji;

/**
* Internal interface for allowing both {@link String} and {@link Emoji} buttons to coexist.
* @param <T> Type of this ID
*/
public interface ButtonId<T> {
/**
* Retrieves the value used to instantiate this object.
* @return The original object, either a {@link String} for {@link TextId} or an {@link Emoji} for {@link EmojiId}
*/
T getId();

/**
* Converts the value into a {@link String} representation for usage in pagination handlers.
* @return The original object, converted into its {@link String} representation
*/
default String extractId() {
if (this instanceof TextId) return ((TextId) this).getId();

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/github/ygimenez/model/EmojiId.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@

import java.util.Objects;

/**
* Subclass of {@link ButtonId} to represent {@link Emoji}-only buttons.
*/
public class EmojiId implements ButtonId<Emoji> {
private final Emoji id;

/**
* Creates a new instance.
* @param id The {@link Emoji} to be used
*/
public EmojiId(Emoji id) {
this.id = id;
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/github/ygimenez/model/TextId.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

import java.util.Objects;

/**
* Subclass of {@link ButtonId} to represent text-only buttons.
*/
public class TextId implements ButtonId<String> {
private final String id;

/**
* Creates a new instance.
* @param id The {@link String} to be used
*/
public TextId(String id) {
this.id = id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ButtonizeHelper(Map<ButtonId<?>, ThrowingConsumer<ButtonWrapper>> buttons
* @param action The action to be performed on click.
* @return The {@link ButtonizeHelper} instance for chaining convenience.
*/
public <T> ButtonizeHelper addAction(Emoji emoji, ThrowingConsumer<ButtonWrapper> action) {
public ButtonizeHelper addAction(Emoji emoji, ThrowingConsumer<ButtonWrapper> action) {
getContent().put(new EmojiId(emoji), action);
return this;
}
Expand All @@ -62,7 +62,7 @@ public <T> ButtonizeHelper addAction(Emoji emoji, ThrowingConsumer<ButtonWrapper
* @param action The action to be performed on click.
* @return The {@link ButtonizeHelper} instance for chaining convenience.
*/
public <T> ButtonizeHelper addAction(String label, ThrowingConsumer<ButtonWrapper> action) {
public ButtonizeHelper addAction(String label, ThrowingConsumer<ButtonWrapper> action) {
getContent().put(new TextId(label), action);
return this;
}
Expand Down

0 comments on commit 3b4eef3

Please sign in to comment.