Package dev.sympho.bot_utils
Class PaginationManager
java.lang.Object
dev.sympho.bot_utils.PaginationManager
Manager for displaying paginated data.
Note that, in order for an instance of this class to begin operating, it must be registered
with a ButtonManager using the handler given by pageUpdateHandler().
- Since:
- 1.0
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe data of a page to be displayed.static interfaceA function that generates the contents of a page.final classEntity responsible for generating content pages of a certain type. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConfigures the handler for page update buttons.register(String id, @Nullable Group requiredGroup, PaginationManager.PageGenerator generator) Registers a paginator.register(String id, PaginationManager.PageGenerator generator) Registers a paginator with no access restrictions.
-
Field Details
-
BUTTON_ID_UPDATE
The base ID for an update button.- See Also:
-
BUTTON_ID_DISPLAY
The ID for the counter display button.- See Also:
-
-
Constructor Details
-
PaginationManager
public PaginationManager()Creates a new instance.
-
-
Method Details
-
register
public PaginationManager.Paginator register(String id, @Nullable Group requiredGroup, PaginationManager.PageGenerator generator) throws IllegalArgumentException Registers a paginator.- Parameters:
id- The page type ID.requiredGroup- The group that a user must belong to to interact with the page controls. Ifnull, defaults to everyone.generator- The generator function for page data.- Returns:
- The paginator.
- Throws:
IllegalArgumentException- if there is already a registered paginator for the given type ID.
-
register
Registers a paginator with no access restrictions.Equivalent to
register(id, null, generator).- Parameters:
id- The page type ID.generator- The generator function for page data.- Returns:
- The paginator.
- Throws:
IllegalArgumentException- if there is already a registered paginator for the given type ID.
-
pageUpdateHandler
Configures the handler for page update buttons. Must be registered with a button manager for this pagination manager to work.- Returns:
- The handler.
-