-
-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing methods to get the actual component in HighLevelComponent…
… and LowLevelComponent
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
14 changes: 13 additions & 1 deletion
14
javacord-api/src/main/java/org/javacord/api/entity/message/component/HighLevelComponent.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 |
---|---|---|
@@ -1,4 +1,16 @@ | ||
package org.javacord.api.entity.message.component; | ||
|
||
public interface HighLevelComponent extends Component { | ||
import org.javacord.api.util.Specializable; | ||
import java.util.Optional; | ||
|
||
public interface HighLevelComponent extends Component, Specializable<HighLevelComponent> { | ||
|
||
default boolean isActionRow() { | ||
return getType() == ComponentType.ACTION_ROW; | ||
} | ||
|
||
default Optional<ActionRow> asActionRow() { | ||
return isActionRow() ? Optional.of((ActionRow) this) : Optional.empty(); | ||
} | ||
|
||
} |
22 changes: 21 additions & 1 deletion
22
javacord-api/src/main/java/org/javacord/api/entity/message/component/LowLevelComponent.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 |
---|---|---|
@@ -1,4 +1,24 @@ | ||
package org.javacord.api.entity.message.component; | ||
|
||
public interface LowLevelComponent extends Component { | ||
import org.javacord.api.util.Specializable; | ||
import java.util.Optional; | ||
|
||
public interface LowLevelComponent extends Component, Specializable<LowLevelComponent> { | ||
|
||
default boolean isButton() { | ||
return getType() == ComponentType.BUTTON; | ||
} | ||
|
||
default Optional<Button> asButton() { | ||
return isButton() ? Optional.of((Button) this) : Optional.empty(); | ||
} | ||
|
||
default boolean isSelectMenu() { | ||
return getType() == ComponentType.SELECT_MENU; | ||
} | ||
|
||
default Optional<SelectMenu> asSelectMenu() { | ||
return isSelectMenu() ? Optional.of((SelectMenu) this) : Optional.empty(); | ||
} | ||
|
||
} |