Class ComponentsUtil
java.lang.Object
net.dv8tion.jda.internal.components.utils.ComponentsUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <R,
E extends Component>
RdoReplace
(Class<? extends Component> expectedChildrenType, Iterable<E> children, ComponentReplacer replacer, Function<List<E>, R> finisher) static long
getComponentTreeSize
(Collection<? extends Component> tree) static long
getComponentTreeTextContentLength
(Collection<? extends Component> components) static Stream
<FileUpload> getFilesFromMedia
(ResolvedMedia media) getIllegalV1Components
(Collection<? extends Component> components) static boolean
hasIllegalV1Components
(Collection<? extends Component> components) static <TUnion extends IComponentUnion>
List<TUnion> membersToUnion
(Collection<? extends Component> members, Class<TUnion> clazz) Checks all the components has the target union type, and isn't anUnknownComponent
, throwsIllegalArgumentException
otherwise.membersToUnionWithUnknownType
(Collection<? extends Component> members, Class<T> clazz) Retains all components extending the provided union type, keeps unknown components, throwsIllegalArgumentException
on invalid types.static <T extends IComponentUnion>
TsafeUnionCast
(String componentCategory, Component component, Class<T> toUnionClass) Checks the component has the target union type, and isn't anUnknownComponent
, throwsIllegalArgumentException
otherwise.static <T extends Component>
TsafeUnionCastWithUnknownType
(String componentCategory, Component component, Class<T> toUnionClass) Checks the component has the target union type, and allows unknown components, throwsIllegalArgumentException
otherwise.
-
Constructor Details
-
ComponentsUtil
public ComponentsUtil()
-
-
Method Details
-
safeUnionCast
public static <T extends IComponentUnion> T safeUnionCast(String componentCategory, Component component, Class<T> toUnionClass) Checks the component has the target union type, and isn't anUnknownComponent
, throwsIllegalArgumentException
otherwise. -
safeUnionCastWithUnknownType
public static <T extends Component> T safeUnionCastWithUnknownType(String componentCategory, Component component, Class<T> toUnionClass) Checks the component has the target union type, and allows unknown components, throwsIllegalArgumentException
otherwise.
This should only be used for reading purposes, usemembersToUnion(Collection, Class)
to verify components to be sent. -
membersToUnion
public static <TUnion extends IComponentUnion> List<TUnion> membersToUnion(Collection<? extends Component> members, Class<TUnion> clazz) Checks all the components has the target union type, and isn't anUnknownComponent
, throwsIllegalArgumentException
otherwise. -
membersToUnionWithUnknownType
public static <T extends Component> List<T> membersToUnionWithUnknownType(Collection<? extends Component> members, Class<T> clazz) Retains all components extending the provided union type, keeps unknown components, throwsIllegalArgumentException
on invalid types.
This should only be used for reading purposes, usemembersToUnion(Collection, Class)
to verify components to be sent. -
doReplace
-
getComponentTreeSize
-
getIllegalV1Components
-
hasIllegalV1Components
-
getComponentTreeTextContentLength
public static long getComponentTreeTextContentLength(@Nonnull Collection<? extends Component> components) -
getFilesFromMedia
-