Class ComponentDeserializer
java.lang.Object
net.dv8tion.jda.api.components.utils.ComponentDeserializer
Utility class to deserialize components that were previously serialized by
ComponentSerializer.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionComponentDeserializer(Collection<? extends FileUpload> files) Create a new deserializer instance with the provided files. -
Method Summary
Modifier and TypeMethodDescriptiondeserializeAll(List<DataObject> components) Deserializes all the provided components.deserializeAs(Class<T> type, List<DataObject> components) Deserializes all the provided components to the provided component type.deserializeAs(Class<T> type, DataArray components) Deserializes all the provided components to the provided component type.<T extends Component>
TdeserializeAs(Class<T> type, DataObject component) Deserializes the provided components to the provided component type.<T extends ComponentTree<?>>
TdeserializeAsTree(Class<T> treeType, List<DataObject> components) Deserializes the provided components to the provided component type.<T extends ComponentTree<?>>
TdeserializeAsTree(Class<T> treeType, DataArray components) Deserializes the provided components to the provided component type.
-
Constructor Details
-
ComponentDeserializer
Create a new deserializer instance with the provided files.- Parameters:
files- The implicit file uploads used by the components (seeComponentSerializer.getFileUploads(Collection))
-
-
Method Details
-
deserializeAll
Deserializes all the provided components.- Parameters:
components- The list of components to deserialize- Returns:
- The deserialized components as
IComponentUnion - Throws:
ParsingException- If any of the components have an invalid formatIllegalArgumentException- Ifnullis provided- See Also:
-
deserializeAs
@Nonnull public <T extends Component> Stream<T> deserializeAs(@Nonnull Class<T> type, @Nonnull List<DataObject> components) Deserializes all the provided components to the provided component type.- Parameters:
type- The target component typecomponents- The list of components to deserialize- Returns:
- The deserialized components
- Throws:
ParsingException- If any of the components have an invalid formatIllegalArgumentException- Ifnullis provided or the resulting component cannot be cast to the target type- See Also:
-
deserializeAs
@Nonnull public <T extends Component> Stream<T> deserializeAs(@Nonnull Class<T> type, @Nonnull DataArray components) Deserializes all the provided components to the provided component type.- Parameters:
type- The target component typecomponents- The array of components to deserialize- Returns:
- The deserialized components
- Throws:
ParsingException- If any of the components have an invalid formatIllegalArgumentException- Ifnullis provided or the resulting component cannot be cast to the target type- See Also:
-
deserializeAs
@Nonnull public <T extends Component> T deserializeAs(@Nonnull Class<T> type, @Nonnull DataObject component) Deserializes the provided components to the provided component type.- Parameters:
type- The target component typecomponent- The component to deserialize- Returns:
- The deserialized components
- Throws:
ParsingException- If the component has an invalid formatIllegalArgumentException- Ifnullis provided or the resulting component cannot be cast to the target type- See Also:
-
deserializeAsTree
@Nonnull public <T extends ComponentTree<?>> T deserializeAsTree(@Nonnull Class<T> treeType, @Nonnull List<DataObject> components) Deserializes the provided components to the provided component type.- Parameters:
treeType- The target component tree type (for instanceMessageComponentTree)components- The list of components to deserialize- Returns:
- The deserialized components as a component tree
- Throws:
ParsingException- If any of the components has an invalid formatIllegalArgumentException- Ifnullis provided or the resulting component cannot be cast to the target type- See Also:
-
deserializeAsTree
@Nonnull public <T extends ComponentTree<?>> T deserializeAsTree(@Nonnull Class<T> treeType, @Nonnull DataArray components) Deserializes the provided components to the provided component type.- Parameters:
treeType- The target component tree type (for instanceMessageComponentTree)components- The list of components to deserialize- Returns:
- The deserialized components as a component tree
- Throws:
ParsingException- If any of the components has an invalid formatIllegalArgumentException- Ifnullis provided or the resulting component cannot be cast to the target type- See Also:
-