Class PaginationBinding
- All Implemented Interfaces:
PaginationHost
PaginationHost seam the
relocated engine paints and settles through.
The binding deliberately does not reference PaginationImpl โ the dependency
points the other way (the token resolves its binding from the session's state store);
the binding works on the immutable PaginationSpec and its token id alone. The
spec's T and the paginator's T originate from the same paginate*
declaration, so the binding pairs them internally on Object through a documented
unchecked cast. Renderer, fallback, loading and lazy-source functions are evaluated
against one PlainViewContextImpl the binding creates at initialize time.
Renderer, fallback and loading failures are swallowed and logged at most once per minute per binding (ยง9 error table); the affected slot keeps its previous content, or shows the fallback item (or clears) when it never held content.
-
Constructor Summary
ConstructorsConstructorDescriptionPaginationBinding(@NotNull PaginationSpec<?> spec, int tokenId, @NotNull ViewSession session, @NotNull ViewEngine engine) Creates the binding for one pagination token of one session. -
Method Summary
Modifier and TypeMethodDescription@Nullable ComponentInstancecomponentAt(int slot) Returns the page-element component currently occupying a slot.@NotNull List<ComponentInstance>elementWatchersOf(@NotNull Set<Integer> dirtyTokenIds) Returns the current page-element components watching any of the given token ids.voidfillPage(@NotNull List<RenderedItem> items, @NotNull Layout layout) Applies one engine frame: itemiis mapped ontolayout.slots().get(i).@org.jetbrains.annotations.NotNull int[]Returns the empty-state and loading frame slots this binding paints into, de-duplicated.booleanReturns whether a pre-init navigation was recorded.voidinitialize(@NotNull ResolvedLayout viewLayout, @NotNull ViewConfig effectiveConfig) Builds the per-context runtime: resolves and validates the fill target, creates the per-context page source and the geometry engine, replays any pending navigation on the still-unbound paginator (the preserved 2.x record-only branch) and binds the engine to this host โ which dispatches the initial page load.booleanisActive()Returns whether the bound session is currently paintable.booleanReturns whetherinitialize(tech.guilhermekaua.spigotboot.inventoryapi.internal.layout.ResolvedLayout, tech.guilhermekaua.spigotboot.inventoryapi.config.ViewConfig)completed and the geometry engine is bound.@Nullable Paginator<?>Returns the bound geometry engine.intReturns the page navigation will land on once the binding initializes.@NotNull org.bukkit.entity.Playerplayer()Returns the live viewer the settle dispatcher uses to route the settle to the correct region thread.@Nullable UUIDplayerId()Returns the player pages are being loaded for; populates the slimPageRequest.@NotNull org.bukkit.plugin.Pluginplugin()Returns the plugin that owns the view; asynchronously completed settles are scheduled through it.voidrecordSwitchTo(int target) Records a pre-init navigation target; consumed once byinitialize(tech.guilhermekaua.spigotboot.inventoryapi.internal.layout.ResolvedLayout, tech.guilhermekaua.spigotboot.inventoryapi.config.ViewConfig).voidrefreshLazy(@NotNull ViewContext context) Re-invokes a lazy eager source's function against the given context, replaces the paginator's source with a fresh eager source over the result and re-requests the current page (forced).voidrepaint()Repaints the whole pagination area from the engine's current frame.voidRequests a reactive settle pass for the owning token: the engine repaints the token's pagination area and every component watching the token.@org.jetbrains.annotations.NotNull int[]Returns the slots this binding paints into: the fill layout's slots for normal and scroll geometry, the union of all pattern slots for pattern geometry.inttokenId()Returns the id of the pagination token this binding belongs to.
-
Constructor Details
-
PaginationBinding
public PaginationBinding(@NotNull @NotNull PaginationSpec<?> spec, int tokenId, @NotNull @NotNull ViewSession session, @NotNull @NotNull ViewEngine engine) Creates the binding for one pagination token of one session.- Parameters:
spec- the immutable pagination declaration of the tokentokenId- the token id assigned by the owning view's token tablesession- the session this binding belongs toengine- the engine providing the painter, the settle entry point and the plugin
-
-
Method Details
-
pendingTarget
public int pendingTarget()Returns the page navigation will land on once the binding initializes.- Returns:
- the pending 1-indexed target page;
1until a navigation was recorded
-
recordSwitchTo
public void recordSwitchTo(int target) Records a pre-init navigation target; consumed once byinitialize(tech.guilhermekaua.spigotboot.inventoryapi.internal.layout.ResolvedLayout, tech.guilhermekaua.spigotboot.inventoryapi.config.ViewConfig).- Parameters:
target- the requested 1-indexed page; clamped to at least1
-
initialize
public void initialize(@NotNull @NotNull ResolvedLayout viewLayout, @NotNull @NotNull ViewConfig effectiveConfig) Builds the per-context runtime: resolves and validates the fill target, creates the per-context page source and the geometry engine, replays any pending navigation on the still-unbound paginator (the preserved 2.x record-only branch) and binds the engine to this host โ which dispatches the initial page load. Eager sources settle inline here so their items are ready before the open's first paint; async sources stay loading so the first paint shows the loading frame.- Parameters:
viewLayout- the session's resolved config layouteffectiveConfig- the session's effective config- Throws:
ViewConfigurationException- when the layout char resolves to no slots, the explicit layout is empty, or an explicit layout or pattern slot lies outside the container
-
isInitialized
public boolean isInitialized()Returns whetherinitialize(tech.guilhermekaua.spigotboot.inventoryapi.internal.layout.ResolvedLayout, tech.guilhermekaua.spigotboot.inventoryapi.config.ViewConfig)completed and the geometry engine is bound.- Returns:
trueonce the paginator exists
-
paginator
Returns the bound geometry engine.- Returns:
- the paginator, or
nullbeforeinitialize(tech.guilhermekaua.spigotboot.inventoryapi.internal.layout.ResolvedLayout, tech.guilhermekaua.spigotboot.inventoryapi.config.ViewConfig)completed
-
targetSlots
@NotNull public @org.jetbrains.annotations.NotNull int[] targetSlots()Returns the slots this binding paints into: the fill layout's slots for normal and scroll geometry, the union of all pattern slots for pattern geometry.- Returns:
- a defensive copy of the resolved fill slots; empty before
initialize(tech.guilhermekaua.spigotboot.inventoryapi.internal.layout.ResolvedLayout, tech.guilhermekaua.spigotboot.inventoryapi.config.ViewConfig)
-
frameSlots
@NotNull public @org.jetbrains.annotations.NotNull int[] frameSlots()Returns the empty-state and loading frame slots this binding paints into, de-duplicated.- Returns:
- a defensive copy of the frame slots; empty before
initialize(tech.guilhermekaua.spigotboot.inventoryapi.internal.layout.ResolvedLayout, tech.guilhermekaua.spigotboot.inventoryapi.config.ViewConfig)or when no frame slots are declared
-
componentAt
Returns the page-element component currently occupying a slot.- Parameters:
slot- the raw container slot- Returns:
- the element component, or
nullwhen the slot holds none
-
repaint
public void repaint()Repaints the whole pagination area from the engine's current frame. -
elementWatchersOf
@NotNull public @NotNull List<ComponentInstance> elementWatchersOf(@NotNull @NotNull Set<Integer> dirtyTokenIds) Returns the current page-element components watching any of the given token ids.- Parameters:
dirtyTokenIds- the dirty token ids of a state flush- Returns:
- the matching element components, each at most once, in fill order
-
tokenId
public int tokenId()Returns the id of the pagination token this binding belongs to.- Returns:
- the token id
-
refreshLazy
Re-invokes a lazy eager source's function against the given context, replaces the paginator's source with a fresh eager source over the result and re-requests the current page (forced).- Parameters:
context- the context the lazy source function is evaluated against- Throws:
IllegalStateException- when the binding's source is not a lazy eager source
-
isActive
public boolean isActive()Description copied from interface:PaginationHostReturns whether the bound session is currently paintable.- Specified by:
isActivein interfacePaginationHost- Returns:
truewhile the session status is ACTIVE or TRANSITIONING
-
fillPage
Description copied from interface:PaginationHostApplies one engine frame: itemiis mapped ontolayout.slots().get(i).- Specified by:
fillPagein interfacePaginationHost- Parameters:
items- the rendered slot contents, one per layout slotlayout- the fill order the items map onto
-
requestRender
public void requestRender()Description copied from interface:PaginationHostRequests a reactive settle pass for the owning token: the engine repaints the token's pagination area and every component watching the token.- Specified by:
requestRenderin interfacePaginationHost
-
playerId
Description copied from interface:PaginationHostReturns the player pages are being loaded for; populates the slimPageRequest.- Specified by:
playerIdin interfacePaginationHost- Returns:
- the viewing player's id; production hosts never return null (test fixtures may)
-
player
@NotNull public @NotNull org.bukkit.entity.Player player()Description copied from interface:PaginationHostReturns the live viewer the settle dispatcher uses to route the settle to the correct region thread. Production hosts always return the session's player; test fixtures may returnnullto trigger the inline-settle path.- Specified by:
playerin interfacePaginationHost- Returns:
- the viewing player, or
nullfor test fixtures
-
plugin
@NotNull public @NotNull org.bukkit.plugin.Plugin plugin()Description copied from interface:PaginationHostReturns the plugin that owns the view; asynchronously completed settles are scheduled through it.- Specified by:
pluginin interfacePaginationHost- Returns:
- the owning plugin
-