From 757e5cc5ded9cc660eec9bd0bcc8bf3c567a4b4f Mon Sep 17 00:00:00 2001 From: Natan Vieira Date: Sat, 9 Dec 2023 15:05:15 -0300 Subject: [PATCH] Component state registry and access implementation (#587) --- .../component/Component.java | 1 - .../context/IFSlotClickContext.java | 1 - .../component/BukkitComponentBuilder.java | 2 +- .../component/BukkitComponentImpl.java | 4 +- .../component/BukkitItemComponentImpl.java | 11 +- .../context/CloseContext.java | 1 - .../context/RenderContext.java | 1 - .../inventoryframework/PlatformView.java | 2 +- .../component/AbstractComponentHandle.java | 96 ++++++------ .../component/PaginationBuilder.java | 9 +- .../component/PlatformComponent.java | 144 +----------------- .../context/PlatformRenderContext.java | 24 --- .../state/StateAccessImpl.java | 22 +-- 13 files changed, 70 insertions(+), 248 deletions(-) diff --git a/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/component/Component.java b/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/component/Component.java index fefaa493c..82b6a6a92 100644 --- a/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/component/Component.java +++ b/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/component/Component.java @@ -89,7 +89,6 @@ public interface Component extends VirtualView, Pipelined { @ApiStatus.Internal boolean isManagedExternally(); - // TODO Needs documentation boolean shouldRender(IFContext context); /** diff --git a/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/context/IFSlotClickContext.java b/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/context/IFSlotClickContext.java index 10a7844a2..52aeab452 100644 --- a/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/context/IFSlotClickContext.java +++ b/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/context/IFSlotClickContext.java @@ -13,7 +13,6 @@ */ public interface IFSlotClickContext extends IFSlotContext, IFConfinedContext { - // TODO needs documentation @NotNull ViewContainer getClickedContainer(); diff --git a/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitComponentBuilder.java b/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitComponentBuilder.java index d805527df..4835d9511 100644 --- a/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitComponentBuilder.java +++ b/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitComponentBuilder.java @@ -45,7 +45,7 @@ public final SELF onClick(@Nullable Consumer clickHand /** {@inheritDoc} */ @Override public Component buildComponent(VirtualView root) { - return new BukkitComponentImpl<>( + return new BukkitComponentImpl( getKey(), root, getReference(), diff --git a/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitComponentImpl.java b/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitComponentImpl.java index 3877beb07..5af7ac832 100644 --- a/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitComponentImpl.java +++ b/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitComponentImpl.java @@ -5,7 +5,6 @@ import java.util.function.Predicate; import me.devnatan.inventoryframework.Ref; import me.devnatan.inventoryframework.VirtualView; -import me.devnatan.inventoryframework.context.Context; import me.devnatan.inventoryframework.context.IFComponentRenderContext; import me.devnatan.inventoryframework.context.IFComponentUpdateContext; import me.devnatan.inventoryframework.context.IFContext; @@ -13,8 +12,7 @@ import me.devnatan.inventoryframework.state.State; import org.jetbrains.annotations.NotNull; -public final class BukkitComponentImpl> - extends PlatformComponent { +public final class BukkitComponentImpl extends PlatformComponent { BukkitComponentImpl( String key, diff --git a/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitItemComponentImpl.java b/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitItemComponentImpl.java index 850a49f7d..f3d5f49a2 100644 --- a/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitItemComponentImpl.java +++ b/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/component/BukkitItemComponentImpl.java @@ -8,7 +8,6 @@ import me.devnatan.inventoryframework.Ref; import me.devnatan.inventoryframework.VirtualView; import me.devnatan.inventoryframework.context.ComponentRenderContext; -import me.devnatan.inventoryframework.context.Context; import me.devnatan.inventoryframework.context.IFComponentContext; import me.devnatan.inventoryframework.context.IFComponentRenderContext; import me.devnatan.inventoryframework.context.IFComponentUpdateContext; @@ -22,7 +21,7 @@ /** * {@link ItemComponent} implementation for Bukkit platform. */ -public final class BukkitItemComponentImpl extends PlatformComponent implements ItemComponent { +public final class BukkitItemComponentImpl extends PlatformComponent implements ItemComponent { private int position; private final ItemStack stack; @@ -55,7 +54,7 @@ public final class BukkitItemComponentImpl extends PlatformComponent> { - private BukkitItemComponentImpl component; - - Handle(BukkitItemComponentImpl component) { - this.component = component; - } - @Override public void rendered(@NotNull ComponentRenderContext context) { final BukkitItemComponentImpl component = (BukkitItemComponentImpl) context.getComponent(); diff --git a/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/context/CloseContext.java b/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/context/CloseContext.java index 82abcb5f2..1dad49430 100644 --- a/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/context/CloseContext.java +++ b/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/context/CloseContext.java @@ -31,7 +31,6 @@ public CloseContext(@NotNull Viewer subject, @NotNull IFRenderContext parent) { this.parent = parent; } - // TODO Needs documentation public final @NotNull Player getPlayer() { return player; } diff --git a/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/context/RenderContext.java b/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/context/RenderContext.java index 0523ea5ad..e2611d70a 100644 --- a/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/context/RenderContext.java +++ b/inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/context/RenderContext.java @@ -48,7 +48,6 @@ public RenderContext( return (View) root; } - // TODO documentation public @NotNull Player getPlayer() { tryThrowDoNotWorkWithSharedContext("getAllPlayers"); return player; diff --git a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/PlatformView.java b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/PlatformView.java index 41bdad9a8..2f5d6d66d 100644 --- a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/PlatformView.java +++ b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/PlatformView.java @@ -63,7 +63,7 @@ public abstract class PlatformView< private FRAMEWORK framework; private boolean initialized; private final StateAccess stateAccess = - new StateAccessImpl<>(this, getElementFactory(), getStateRegistry()); + new StateAccessImpl<>(this, getStateRegistry()); // region Open & Close /** diff --git a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/AbstractComponentHandle.java b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/AbstractComponentHandle.java index e45635021..d271f8643 100644 --- a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/AbstractComponentHandle.java +++ b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/AbstractComponentHandle.java @@ -4,139 +4,149 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Function; import java.util.function.Supplier; +import me.devnatan.inventoryframework.VirtualView; import me.devnatan.inventoryframework.state.MutableIntState; import me.devnatan.inventoryframework.state.MutableState; import me.devnatan.inventoryframework.state.State; import me.devnatan.inventoryframework.state.StateAccess; +import me.devnatan.inventoryframework.state.StateAccessImpl; +import me.devnatan.inventoryframework.state.StateRegistry; import org.jetbrains.annotations.NotNull; public abstract class AbstractComponentHandle extends ComponentHandle - implements StateAccess { + implements StateAccess, VirtualView { + + private final StateRegistry stateRegistry = new StateRegistry(); + private final StateAccess stateAccess = new StateAccessImpl<>(this, stateRegistry); protected AbstractComponentHandle() {} public abstract COMPONENT_BUILDER builder(); @Override - public State state(T initialValue) { - return null; + public final State state(T initialValue) { + return stateAccess.state(initialValue); } @Override - public MutableState mutableState(T initialValue) { - return null; + public final MutableState mutableState(T initialValue) { + return stateAccess.mutableState(initialValue); } @Override - public MutableIntState mutableState(int initialValue) { - return null; + public final MutableIntState mutableState(int initialValue) { + return stateAccess.mutableState(initialValue); } @Override - public State computedState(@NotNull Function computation) { - return null; + public final State computedState(@NotNull Function computation) { + return stateAccess.computedState(computation); } @Override - public State computedState(@NotNull Supplier computation) { - return null; + public final State computedState(@NotNull Supplier computation) { + return stateAccess.computedState(computation); } @Override - public State lazyState(@NotNull Function computation) { - return null; + public final State lazyState(@NotNull Function computation) { + return stateAccess.lazyState(computation); } @Override - public State lazyState(@NotNull Supplier computation) { - return null; + public final State lazyState(@NotNull Supplier computation) { + return stateAccess.lazyState(computation); } @Override - public MutableState initialState() { - return null; + public final MutableState initialState() { + return stateAccess.initialState(); } @Override - public MutableState initialState(@NotNull String key) { - return null; + public final MutableState initialState(@NotNull String key) { + return stateAccess.initialState(key); } @Override - public State paginationState( + public final State paginationState( @NotNull List sourceProvider, @NotNull PaginationValueConsumer elementConsumer) { - return null; + return stateAccess.paginationState(sourceProvider, elementConsumer); } @Override - public State computedPaginationState( + public final State computedPaginationState( @NotNull Function> sourceProvider, @NotNull PaginationValueConsumer valueConsumer) { - return null; + + return stateAccess.computedPaginationState(sourceProvider, valueConsumer); } @Override - public State computedAsyncPaginationState( + public final State computedAsyncPaginationState( @NotNull Function>> sourceProvider, @NotNull PaginationValueConsumer valueConsumer) { - return null; + return stateAccess.computedAsyncPaginationState(sourceProvider, valueConsumer); } @Override - public State lazyPaginationState( + public final State lazyPaginationState( @NotNull Function> sourceProvider, @NotNull PaginationValueConsumer valueConsumer) { - return null; + + return stateAccess.lazyPaginationState(sourceProvider, valueConsumer); } @Override - public State lazyPaginationState( + public final State lazyPaginationState( @NotNull Supplier> sourceProvider, @NotNull PaginationValueConsumer valueConsumer) { - return null; + return stateAccess.lazyPaginationState(sourceProvider, valueConsumer); } @Override - public State lazyAsyncPaginationState( + public final State lazyAsyncPaginationState( @NotNull Function>> sourceProvider, @NotNull PaginationValueConsumer valueConsumer) { - return null; + + return stateAccess.lazyAsyncPaginationState(sourceProvider, valueConsumer); } @Override - public PaginationBuilder buildPaginationState( + public final PaginationBuilder buildPaginationState( @NotNull List sourceProvider) { - return null; + return stateAccess.buildPaginationState(sourceProvider); } @Override - public PaginationBuilder buildComputedPaginationState( + public final PaginationBuilder buildComputedPaginationState( @NotNull Function> sourceProvider) { - return null; + return stateAccess.buildComputedPaginationState(sourceProvider); } @Override - public PaginationBuilder buildComputedAsyncPaginationState( + public final PaginationBuilder buildComputedAsyncPaginationState( @NotNull Function>> sourceProvider) { - return null; + return stateAccess.buildComputedAsyncPaginationState(sourceProvider); } @Override - public PaginationBuilder buildLazyPaginationState( + public final PaginationBuilder buildLazyPaginationState( @NotNull Supplier> sourceProvider) { - return null; + return stateAccess.buildLazyPaginationState(sourceProvider); } @Override - public PaginationBuilder buildLazyPaginationState( + public final PaginationBuilder buildLazyPaginationState( @NotNull Function> sourceProvider) { - return null; + return stateAccess.buildLazyPaginationState(sourceProvider); } @Override - public PaginationBuilder buildLazyAsyncPaginationState( + public final PaginationBuilder buildLazyAsyncPaginationState( @NotNull Function>> sourceProvider) { - return null; + return stateAccess.buildLazyAsyncPaginationState(sourceProvider); } + // endregion } diff --git a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/PaginationBuilder.java b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/PaginationBuilder.java index 1cff413d8..655a86591 100644 --- a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/PaginationBuilder.java +++ b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/PaginationBuilder.java @@ -2,8 +2,8 @@ import java.util.function.BiConsumer; import me.devnatan.inventoryframework.VirtualView; -import me.devnatan.inventoryframework.internal.ElementFactory; import me.devnatan.inventoryframework.internal.LayoutSlot; +import me.devnatan.inventoryframework.internal.PlatformUtils; import me.devnatan.inventoryframework.state.State; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,6 @@ public final class PaginationBuilder extends PlatformComponentBuilder, CONTEXT> { - private final ElementFactory internalElementFactory; private final Object sourceProvider; private char layoutTarget = LayoutSlot.DEFAULT_SLOT_FILL_CHAR; private PaginationElementFactory paginationElementFactory; @@ -23,9 +22,7 @@ public final class PaginationBuilder * this library. No compatibility guarantees are provided. */ @ApiStatus.Internal - public PaginationBuilder( - ElementFactory internalElementFactory, Object sourceProvider, boolean async, boolean computed) { - this.internalElementFactory = internalElementFactory; + public PaginationBuilder(Object sourceProvider, boolean async, boolean computed) { this.sourceProvider = sourceProvider; this.async = async; this.computed = computed; @@ -64,7 +61,7 @@ public PaginationBuilder elementFactory( @NotNull PaginationValueConsumer elementConsumer) { this.paginationElementFactory = (pagination, index, slot, value) -> { CONTEXT context = (CONTEXT) pagination.getRoot(); - BUILDER builder = (BUILDER) internalElementFactory.createComponentBuilder(pagination); + BUILDER builder = (BUILDER) PlatformUtils.getFactory().createComponentBuilder(pagination); if (builder instanceof ItemComponentBuilder) ((ItemComponentBuilder) builder).setPosition(slot); elementConsumer.accept(context, builder, index, value); diff --git a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/PlatformComponent.java b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/PlatformComponent.java index 8b457a2d6..f189af39d 100644 --- a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/PlatformComponent.java +++ b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/component/PlatformComponent.java @@ -1,32 +1,18 @@ package me.devnatan.inventoryframework.component; -import java.util.List; import java.util.Set; -import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; -import java.util.function.Function; import java.util.function.Predicate; -import java.util.function.Supplier; -import me.devnatan.inventoryframework.PlatformView; import me.devnatan.inventoryframework.Ref; -import me.devnatan.inventoryframework.RootView; import me.devnatan.inventoryframework.VirtualView; import me.devnatan.inventoryframework.context.IFComponentRenderContext; import me.devnatan.inventoryframework.context.IFComponentUpdateContext; import me.devnatan.inventoryframework.context.IFContext; import me.devnatan.inventoryframework.context.IFSlotClickContext; -import me.devnatan.inventoryframework.state.MutableIntState; -import me.devnatan.inventoryframework.state.MutableState; import me.devnatan.inventoryframework.state.State; -import me.devnatan.inventoryframework.state.StateAccess; -import me.devnatan.inventoryframework.state.StateAccessImpl; -import org.jetbrains.annotations.NotNull; -@SuppressWarnings({"rawtypes", "unchecked"}) -public abstract class PlatformComponent extends AbstractComponent - implements Component, StateAccess { +public abstract class PlatformComponent extends AbstractComponent implements Component { - private final StateAccessImpl stateAccess; private final boolean cancelOnClick; private final boolean closeOnClick; private final boolean updateOnClick; @@ -34,11 +20,6 @@ public abstract class PlatformComponent extends Abst private final Consumer updateHandler; private final Consumer clickHandler; - { - final RootView root = (RootView) getRootAsContext().getRoot(); - stateAccess = new StateAccessImpl(this, root.getElementFactory(), ((PlatformView) root).getStateRegistry()); - } - protected PlatformComponent( String key, VirtualView root, @@ -87,127 +68,4 @@ public final Consumer getClickHandler() { return clickHandler; } // endregion - - @Override - public final State state(T initialValue) { - return stateAccess.state(initialValue); - } - - @Override - public final MutableState mutableState(T initialValue) { - return stateAccess.mutableState(initialValue); - } - - @Override - public final MutableIntState mutableState(int initialValue) { - return stateAccess.mutableState(initialValue); - } - - @Override - public final State computedState(@NotNull Function computation) { - return stateAccess.computedState(computation); - } - - @Override - public final State computedState(@NotNull Supplier computation) { - return stateAccess.computedState(computation); - } - - @Override - public final State lazyState(@NotNull Function computation) { - return stateAccess.lazyState(computation); - } - - @Override - public final State lazyState(@NotNull Supplier computation) { - return stateAccess.lazyState(computation); - } - - @Override - public final MutableState initialState() { - return stateAccess.initialState(); - } - - @Override - public final MutableState initialState(@NotNull String key) { - return stateAccess.initialState(key); - } - - @Override - public final State paginationState( - @NotNull List sourceProvider, - @NotNull PaginationValueConsumer elementConsumer) { - return stateAccess.paginationState(sourceProvider, elementConsumer); - } - - @Override - public final State computedPaginationState( - @NotNull Function> sourceProvider, - @NotNull PaginationValueConsumer valueConsumer) { - return stateAccess.computedPaginationState(sourceProvider, valueConsumer); - } - - @Override - public final State computedAsyncPaginationState( - @NotNull Function>> sourceProvider, - @NotNull PaginationValueConsumer valueConsumer) { - return stateAccess.computedAsyncPaginationState(sourceProvider, valueConsumer); - } - - @Override - public final State lazyPaginationState( - @NotNull Function> sourceProvider, - @NotNull PaginationValueConsumer valueConsumer) { - return stateAccess.lazyPaginationState(sourceProvider, valueConsumer); - } - - @Override - public final State lazyPaginationState( - @NotNull Supplier> sourceProvider, - @NotNull PaginationValueConsumer valueConsumer) { - return stateAccess.lazyPaginationState(sourceProvider, valueConsumer); - } - - @Override - public final State lazyAsyncPaginationState( - @NotNull Function>> sourceProvider, - @NotNull PaginationValueConsumer valueConsumer) { - return stateAccess.lazyAsyncPaginationState(sourceProvider, valueConsumer); - } - - @Override - public final PaginationBuilder buildPaginationState( - @NotNull List sourceProvider) { - return stateAccess.buildPaginationState(sourceProvider); - } - - @Override - public final PaginationBuilder buildComputedPaginationState( - @NotNull Function> sourceProvider) { - return stateAccess.buildComputedPaginationState(sourceProvider); - } - - @Override - public final PaginationBuilder buildComputedAsyncPaginationState( - @NotNull Function>> sourceProvider) { - return stateAccess.buildComputedAsyncPaginationState(sourceProvider); - } - - @Override - public final PaginationBuilder buildLazyPaginationState( - @NotNull Supplier> sourceProvider) { - return stateAccess.buildLazyPaginationState(sourceProvider); - } - - @Override - public final PaginationBuilder buildLazyPaginationState( - @NotNull Function> sourceProvider) { - return stateAccess.buildLazyPaginationState(sourceProvider); - } - - @Override - public final PaginationBuilder buildLazyAsyncPaginationState( - @NotNull Function>> sourceProvider) { - return stateAccess.buildLazyAsyncPaginationState(sourceProvider); - } } diff --git a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/context/PlatformRenderContext.java b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/context/PlatformRenderContext.java index 270a3f49f..1520cb0a8 100644 --- a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/context/PlatformRenderContext.java +++ b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/context/PlatformRenderContext.java @@ -23,7 +23,6 @@ import me.devnatan.inventoryframework.component.ComponentBuilder; import me.devnatan.inventoryframework.component.ComponentFactory; import me.devnatan.inventoryframework.component.ItemComponentBuilder; -import me.devnatan.inventoryframework.component.PlatformComponent; import me.devnatan.inventoryframework.component.PlatformComponentBuilder; import me.devnatan.inventoryframework.internal.LayoutSlot; import org.jetbrains.annotations.ApiStatus; @@ -224,29 +223,6 @@ public final void layoutSlot(char character, @NotNull BiConsumer> - BUILDER layoutComponent(char character, COMPONENT component) { - - // TODO More detailed exception message - final LayoutSlot layoutSlot = getLayoutSlots().stream() - .filter(value -> value.getCharacter() == character) - .findFirst() - .orElseThrow(() -> new InventoryFrameworkException("Missing layout character: " + character)); - - // FIXME Missing implementation - final BUILDER builder = null; - // final BUILDER builder = component.createBuilder(); - - getLayoutSlots().add(layoutSlot.withFactory($ -> (ComponentFactory) builder)); - return builder; - } - /** *

This API is experimental and is not subject to the general compatibility guarantees * such API may be changed or may be removed completely in any further release. diff --git a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/state/StateAccessImpl.java b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/state/StateAccessImpl.java index c1b2b9647..5f347de09 100644 --- a/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/state/StateAccessImpl.java +++ b/inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/state/StateAccessImpl.java @@ -5,13 +5,10 @@ import java.util.function.Function; import java.util.function.Supplier; import me.devnatan.inventoryframework.VirtualView; -import me.devnatan.inventoryframework.component.ItemComponentBuilder; import me.devnatan.inventoryframework.component.Pagination; import me.devnatan.inventoryframework.component.PaginationBuilder; import me.devnatan.inventoryframework.component.PaginationImpl; import me.devnatan.inventoryframework.component.PaginationValueConsumer; -import me.devnatan.inventoryframework.context.IFContext; -import me.devnatan.inventoryframework.internal.ElementFactory; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -20,16 +17,13 @@ * this library. No compatibility guarantees are provided. */ @ApiStatus.Internal -public final class StateAccessImpl - implements StateAccess { +public final class StateAccessImpl implements StateAccess { private final VirtualView caller; - private final ElementFactory elementFactory; private final StateRegistry stateRegistry; - public StateAccessImpl(VirtualView caller, ElementFactory elementFactory, StateRegistry stateRegistry) { + public StateAccessImpl(VirtualView caller, StateRegistry stateRegistry) { this.caller = caller; - this.elementFactory = elementFactory; this.stateRegistry = stateRegistry; } @@ -172,37 +166,37 @@ public State lazyAsyncPaginationState( @Override public PaginationBuilder buildPaginationState( @NotNull List sourceProvider) { - return new PaginationBuilder<>(this.elementFactory, sourceProvider, false, false); + return new PaginationBuilder<>(sourceProvider, false, false); } @Override public PaginationBuilder buildComputedPaginationState( @NotNull Function> sourceProvider) { - return new PaginationBuilder<>(this.elementFactory, sourceProvider, false, true); + return new PaginationBuilder<>(sourceProvider, false, true); } @Override public PaginationBuilder buildComputedAsyncPaginationState( @NotNull Function>> sourceProvider) { - return new PaginationBuilder<>(this.elementFactory, sourceProvider, true, true); + return new PaginationBuilder<>(sourceProvider, true, true); } @Override public PaginationBuilder buildLazyPaginationState( @NotNull Supplier> sourceProvider) { - return new PaginationBuilder<>(this.elementFactory, sourceProvider, false, false); + return new PaginationBuilder<>(sourceProvider, false, false); } @Override public PaginationBuilder buildLazyPaginationState( @NotNull Function> sourceProvider) { - return new PaginationBuilder<>(this.elementFactory, sourceProvider, false, false); + return new PaginationBuilder<>(sourceProvider, false, false); } @Override public PaginationBuilder buildLazyAsyncPaginationState( @NotNull Function>> sourceProvider) { - return new PaginationBuilder<>(this.elementFactory, sourceProvider, true, false); + return new PaginationBuilder<>(sourceProvider, true, false); } State createPaginationState(@NotNull PaginationBuilder builder) {