Package net.dv8tion.jda.api.components
Class Components
java.lang.Object
net.dv8tion.jda.api.components.Components
Utility class for components.
This utility builds on ComponentDeserializer
to deserialize components.
The implementation provided by ComponentDeserializer
allows to deserialize components with implicit FileUploads
like Thumbnail
.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Component>
TparseComponent
(Class<T> componentType, DataObject data) Converts the providedDataObject
into a component of typeComponents
.parseComponents
(Class<T> componentType, DataArray data) static <T extends ComponentTree<?>>
TConverts the providedDataArray
into aComponentTree
.
-
Constructor Details
-
Components
public Components()
-
-
Method Details
-
parseComponent
@Nonnull public static <T extends Component> T parseComponent(@Nonnull Class<T> componentType, @Nonnull DataObject data) Converts the providedDataObject
into a component of typeComponents
.
Note that any unsupported component will be represented as anUnknownComponent
.- Parameters:
data
- TheDataArray
to create the component tree from- Returns:
- A
ComponentTree
representing the provided data - Throws:
IllegalArgumentException
- If the provided data isnull
, or the component is not of typeComponents
- See Also:
-
parseComponents
@Nonnull public static <T extends Component> List<T> parseComponents(@Nonnull Class<T> componentType, @Nonnull DataArray data) Converts the providedDataArray
into aList
of components.
Note that any unsupported component will be represented as anUnknownComponent
.- Parameters:
data
- TheDataArray
to create the components from- Returns:
- A
List
ofComponents
representing the provided data - Throws:
IllegalArgumentException
- If the provided data isnull
, or one of the components is not of typeComponents
- See Also:
-
parseTree
@Nonnull public static <T extends ComponentTree<?>> T parseTree(@Nonnull Class<T> treeType, @Nonnull DataArray data) Converts the providedDataArray
into aComponentTree
.
Note that any unsupported component will be represented as anUnknownComponent
.- Parameters:
data
- TheDataArray
to create the component tree from- Returns:
- A
ComponentTree
representing the provided data - Throws:
IllegalArgumentException
- If the provided data isnull
, or one of the components is not compatible.UnsupportedOperationException
- If the provided tree type is not supported- See Also:
-