Class SequencedContainer<E extends ContainerChildComponent>
- Type Parameters:
E- the component type this container supports.
- All Implemented Interfaces:
LocalizedComponent, SequencedComponent<E>, IDisableable, Component, Container, IComponentUnion, MessageTopLevelComponent, MessageTopLevelComponentUnion, IReplaceable, SerializableData
A Container implementation that allows adding ContainerChildComponents sequentially.
This class is fully compatible with JDA and implements both Container and MessageTopLevelComponentUnion. Use
of(ContainerChildComponent) to create a new SequencedContainer. Compared to JDA's Container, the component
list of this container isn't immutable and can be extended.
SequencedContainer<ContainerChildComponent> container = SequencedContainer.of(TextDisplay.of("Hello World!"));
container.add(Separator.createDivider(Spacing.SMALL));
container.add(TextDisplay.of("Goodbye World"));
Localization
This Container implementation also supports localization. When AbstractSequencedContainer.getComponents() or AbstractSequencedContainer.toData() is called, the
component list of this container is localized via ComponentResolver. Use AbstractSequencedContainer.entries(Entry...) to provide
additional Entries outside the SequencedComponent.add(Component, Entry...) methods.
Usage outside JDA-Commands
Container.of(Collection) uses the JDACIntrospection API to access a Resolver and the user locale. This means, the
static of factory method is only usable in JDACScope.PREPARATION. If you want to use this class outside JDA-Commands
call the constructor and pass the Resolver as well as the Locale manually.
SequencedContainer<ContainerChildComponent> container = new SequencedContainer(resolver, locale, TextDisplay.of("Hello World!"));
-
Nested Class Summary
Nested classes/interfaces inherited from interface Component
Component.Type -
Field Summary
Fields inherited from class AbstractSequencedContainer
container, entries -
Constructor Summary
ConstructorsConstructorDescriptionSequencedContainer(Resolver<String> resolver, Locale locale, E header) Constructs a newSequencedContainer.SequencedContainer(Resolver<String> resolver, DiscordLocale locale, E header) Constructs a newSequencedContainer. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends ContainerChildComponent>
SequencedContainer<T> of(T header) Constructs a newSequencedContainerfrom the given componentT.protected SequencedContainer<E> self()Methods inherited from class AbstractSequencedContainer
add, addAll, addFirst, addLast, asActionRow, asContainer, asDisabled, asEnabled, asFileDisplay, asMediaGallery, asSection, asSeparator, asTextDisplay, checkAccess, entries, entries, getAccentColorRaw, getComponents, getType, getUniqueId, isSpoiler, locale, locale, locale, replace, toData, withAccentColor, withAccentColor, withComponents, withComponents, withDisabled, withSpoiler, withUniqueIdMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Container
getAccentColor, isDisabled, isEnabled, isMessageCompatible, isModalCompatibleMethods inherited from interface IComponentUnion
isUnknownComponent
-
Constructor Details
-
SequencedContainer
Constructs a newSequencedContainer.- Parameters:
resolver- theResolverto use for localizationlocale- the locale this container will be localized toheader- the first component of this container
-
SequencedContainer
-
-
Method Details
-
of
Constructs a new
SequencedContainerfrom the given componentT.This method can only be used inside events or in methods annotated with
IntrospectionAccess.- Type Parameters:
T- the component type this container supports.- Throws:
ReplyException- if theJDACScope.PREPARATIONisn't accessible.
-
self
- Specified by:
selfin classAbstractSequencedContainer<E extends ContainerChildComponent, SequencedContainer<E extends ContainerChildComponent>>
-