Class ActionRow
- java.lang.Object
-
- net.dv8tion.jda.api.interactions.components.ActionRow
-
- All Implemented Interfaces:
Iterable<ItemComponent>,Component,LayoutComponent,SerializableData
public class ActionRow extends Object implements LayoutComponent
One row of components.- See Also:
ItemComponent,LayoutComponent
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.interactions.components.Component
Component.Type
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ActionRowasDisabled()Returns a new instance of this LayoutComponent with all components set to disabled.ActionRowasEnabled()Returns a new instance of this LayoutComponent with all components set to enabled.booleanequals(Object obj)static ActionRowfromData(DataObject data)Load ActionRow from serialized representation.List<ItemComponent>getComponents()Mutable list of components in this ActionRow.Component.TypegetType()The type of component.inthashCode()Iterator<ItemComponent>iterator()static ActionRowof(Collection<? extends ItemComponent> components)Create one row ofcomponents.static ActionRowof(ItemComponent... components)Create one row ofcomponents.static List<ActionRow>partitionOf(Collection<? extends ItemComponent> components)Partitions the providedcomponentsinto a list of ActionRow instances.static List<ActionRow>partitionOf(ItemComponent... components)Partitions the providedcomponentsinto a list of ActionRow instances.DataObjecttoData()SerializedDataObjectfor this object.StringtoString()ActionRowwithDisabled(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, isValid, updateComponent, updateComponent
-
-
-
-
Method Detail
-
fromData
@Nonnull public static ActionRow fromData(@Nonnull DataObject data)
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
@Nonnull public static ActionRow of(@Nonnull Collection<? extends ItemComponent> components)
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
@Nonnull public static ActionRow of(@Nonnull ItemComponent... components)
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 providedcomponentsinto 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:
ListofActionRow- Throws:
IllegalArgumentException- If null is provided
-
partitionOf
@Nonnull public static List<ActionRow> partitionOf(@Nonnull ItemComponent... components)
Partitions the providedcomponentsinto 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:
ListofActionRow- Throws:
IllegalArgumentException- If null is provided
-
getComponents
@Nonnull public List<ItemComponent> getComponents()
Mutable list of components in this ActionRow.
ActionRows should not be empty and are limited to 5 buttons.- Specified by:
getComponentsin interfaceLayoutComponent- Returns:
- The list of components
-
withDisabled
@Nonnull @CheckReturnValue public ActionRow withDisabled(boolean disabled)
Description copied from interface:LayoutComponentReturns 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:
withDisabledin 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:
ActionComponent.withDisabled(boolean)
-
asDisabled
@Nonnull @CheckReturnValue public ActionRow asDisabled()
Description copied from interface:LayoutComponentReturns 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:
asDisabledin interfaceLayoutComponent- Returns:
- The new layout component with all components updated
- See Also:
ActionComponent.asDisabled()
-
asEnabled
@Nonnull @CheckReturnValue public ActionRow asEnabled()
Description copied from interface:LayoutComponentReturns 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:
asEnabledin interfaceLayoutComponent- Returns:
- The new layout component with all components updated
- See Also:
ActionComponent.asEnabled()
-
getType
@Nonnull public Component.Type getType()
Description copied from interface:ComponentThe type of component.- Specified by:
getTypein interfaceComponent- Returns:
Component.Type
-
toData
@Nonnull public DataObject toData()
Description copied from interface:SerializableDataSerializedDataObjectfor this object.- Specified by:
toDatain interfaceSerializableData- Returns:
DataObject
-
iterator
@Nonnull public Iterator<ItemComponent> iterator()
- Specified by:
iteratorin interfaceIterable<ItemComponent>
-
-