Class ActionRow
java.lang.Object
net.dv8tion.jda.api.interactions.components.ActionRow
- All Implemented Interfaces:
Iterable<ItemComponent>
,Component
,LayoutComponent
,SerializableData
One row of components.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.interactions.components.Component
Component.Type
-
Method Summary
Modifier and TypeMethodDescriptionReturns a new instance of this LayoutComponent with all components set to disabled.Returns a new instance of this LayoutComponent with all components set to enabled.Creates a copy of thisLayoutComponent
.boolean
static ActionRow
fromData
(DataObject data) Load ActionRow from serialized representation.Mutable list of components in this ActionRow.getType()
The type of component.int
hashCode()
iterator()
static ActionRow
of
(Collection<? extends ItemComponent> components) Create one row ofcomponents
.static ActionRow
of
(ItemComponent... components) Create one row ofcomponents
.partitionOf
(Collection<? extends ItemComponent> components) Partitions the providedcomponents
into a list of ActionRow instances.partitionOf
(ItemComponent... components) Partitions the providedcomponents
into a list of ActionRow instances.toData()
SerializedDataObject
for this object.toString()
withDisabled
(boolean disabled) Returns a new instance of this LayoutComponent with all components set to disabled/enabled.Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface net.dv8tion.jda.api.interactions.components.LayoutComponent
getActionComponents, getButtons, isDisabled, isEmpty, isEnabled, isMessageCompatible, isModalCompatible, isValid, updateComponent, updateComponent
-
Method Details
-
fromData
Load ActionRow from serialized representation.
Inverse oftoData()
.- Parameters:
data
- Serialized version of an action row- Returns:
- ActionRow instance
- Throws:
ParsingException
- If the provided data is not a valid action rowIllegalArgumentException
- If the data is null or the type is not 1
-
of
Create one row ofcomponents
.
You cannot currently mix different types of components and each type has its own maximum defined byComponent.Type.getMaxPerRow()
.- Parameters:
components
- The components for this action row- Returns:
- The action row
- Throws:
IllegalArgumentException
- If anything is null, empty, or an invalid number of components are provided
-
of
Create one row ofcomponents
.
You cannot currently mix different types of components and each type has its own maximum defined byComponent.Type.getMaxPerRow()
.- Parameters:
components
- The components for this action row- Returns:
- The action row
- Throws:
IllegalArgumentException
- If anything is null, empty, or an invalid number of components are provided
-
partitionOf
@Nonnull public static List<ActionRow> partitionOf(@Nonnull Collection<? extends ItemComponent> components) Partitions the providedcomponents
into a list of ActionRow instances.
This will split the provided components byComponent.Type.getMaxPerRow()
and create homogeneously typed rows, meaning they will not have mixed component types.Example
List<ItemComponent> components = Arrays.asList( Button.primary("id1", "Hello"), Button.secondary("id2", "World"), SelectMenu.create("menu:id").build() ); List<ActionRow> partitioned = ActionRow.partition(components); // partitioned[0] = ActionRow(button, button) // partitioned[1] = ActionRow(selectMenu)
- Parameters:
components
- The components to partition- Returns:
List
ofActionRow
- Throws:
IllegalArgumentException
- If null is provided
-
partitionOf
Partitions the providedcomponents
into a list of ActionRow instances.
This will split the provided components byComponent.Type.getMaxPerRow()
and create homogeneously typed rows, meaning they will not have mixed component types.Example
List<ItemComponent> components = Arrays.asList( Button.primary("id1", "Hello"), Button.secondary("id2", "World"), SelectMenu.create("menu:id").build() ); List<ActionRow> partitioned = ActionRow.partition(components); // partitioned[0] = ActionRow(button, button) // partitioned[1] = ActionRow(selectMenu)
- Parameters:
components
- The components to partition- Returns:
List
ofActionRow
- Throws:
IllegalArgumentException
- If null is provided
-
getComponents
Mutable list of components in this ActionRow.
ActionRows should not be empty and are limited to 5 buttons.- Specified by:
getComponents
in interfaceLayoutComponent
- Returns:
- The list of components
-
withDisabled
Description copied from interface:LayoutComponent
Returns a new instance of this LayoutComponent with all components set to disabled/enabled.
This does not modify the layout this was called on. To do this in-place, you can useLayoutComponent.getComponents()
.- Specified by:
withDisabled
in interfaceLayoutComponent
- Parameters:
disabled
- True if the components should be set to disabled, false if they should be enabled- Returns:
- The new layout component with all components updated
- See Also:
-
asDisabled
Description copied from interface:LayoutComponent
Returns a new instance of this LayoutComponent with all components set to disabled.
This does not modify the layout this was called on. To do this in-place, you can useLayoutComponent.getComponents()
.- Specified by:
asDisabled
in interfaceLayoutComponent
- Returns:
- The new layout component with all components updated
- See Also:
-
asEnabled
Description copied from interface:LayoutComponent
Returns a new instance of this LayoutComponent with all components set to enabled.
This does not modify the layout this was called on. To do this in-place, you can useLayoutComponent.getComponents()
.- Specified by:
asEnabled
in interfaceLayoutComponent
- Returns:
- The new layout component with all components updated
- See Also:
-
createCopy
Description copied from interface:LayoutComponent
Creates a copy of thisLayoutComponent
.
This does not create copies of the contained components.- Specified by:
createCopy
in interfaceLayoutComponent
- Returns:
- A copy of this
LayoutComponent
-
getType
Description copied from interface:Component
The type of component.- Specified by:
getType
in interfaceComponent
- Returns:
Component.Type
-
toData
Description copied from interface:SerializableData
SerializedDataObject
for this object.- Specified by:
toData
in interfaceSerializableData
- Returns:
DataObject
-
iterator
- Specified by:
iterator
in interfaceIterable<ItemComponent>
-
toString
-
hashCode
public int hashCode() -
equals
-