Class ComponentDeserializer

java.lang.Object
net.dv8tion.jda.api.components.utils.ComponentDeserializer

public class ComponentDeserializer extends Object
Utility class to deserialize components that were previously serialized by ComponentSerializer.
See Also:
  • Constructor Details

  • Method Details

    • deserializeAll

      @Nonnull public List<IComponentUnion> deserializeAll(@Nonnull List<DataObject> components)
      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 format
      IllegalArgumentException - If null is 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 type
      components - The list of components to deserialize
      Returns:
      The deserialized components
      Throws:
      ParsingException - If any of the components have an invalid format
      IllegalArgumentException - If null is 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 type
      components - The array of components to deserialize
      Returns:
      The deserialized components
      Throws:
      ParsingException - If any of the components have an invalid format
      IllegalArgumentException - If null is 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 type
      component - The component to deserialize
      Returns:
      The deserialized components
      Throws:
      ParsingException - If the component has an invalid format
      IllegalArgumentException - If null is 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 instance MessageComponentTree)
      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 format
      IllegalArgumentException - If null is 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 instance MessageComponentTree)
      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 format
      IllegalArgumentException - If null is provided or the resulting component cannot be cast to the target type
      See Also: