Class SequencedContainer<E extends ContainerChildComponent>

java.lang.Object
io.github.kaktushose.jdac.components.internal.AbstractSequencedContainer<E, SequencedContainer<E>>
io.github.kaktushose.jdac.components.container.SequencedContainer<E>
Type Parameters:
E - the component type this container supports.
All Implemented Interfaces:
LocalizedComponent, SequencedComponent<E>, IDisableable, Component, Container, IComponentUnion, MessageTopLevelComponent, MessageTopLevelComponentUnion, IReplaceable, SerializableData

public final class SequencedContainer<E extends ContainerChildComponent> extends AbstractSequencedContainer<E, SequencedContainer<E>>

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!"));