From 4fd950d5932d75de1df0992a8cb5ca788df02f2e Mon Sep 17 00:00:00 2001 From: Natan Date: Thu, 30 Oct 2025 12:40:36 -0300 Subject: [PATCH 1/2] docs: comment --- .../devnatan/inventoryframework/component/PaginationImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inventory-framework-core/src/main/java/me/devnatan/inventoryframework/component/PaginationImpl.java b/inventory-framework-core/src/main/java/me/devnatan/inventoryframework/component/PaginationImpl.java index 382dc7538..3054ab3d3 100644 --- a/inventory-framework-core/src/main/java/me/devnatan/inventoryframework/component/PaginationImpl.java +++ b/inventory-framework-core/src/main/java/me/devnatan/inventoryframework/component/PaginationImpl.java @@ -120,7 +120,7 @@ private CompletableFuture> loadSourceForTheCurrentPage() { currentPageIndex(), reuseLazy, isStatic(), isComputed(), forceUpdated); if ((isStatic() || reuseLazy) && !isComputed() && !forceUpdated) { - // For unknown reasons already initialized but source is null, external modification? + // Already initialized but source is null?? External modification? if (initialized && currSource == null) throw new IllegalStateException("User provided pagination source cannot be null"); else { From 0a2f99d3eb0386c05ed8c2635cde4ad2e386226e Mon Sep 17 00:00:00 2001 From: Natan Date: Fri, 31 Oct 2025 12:50:32 -0300 Subject: [PATCH 2/2] feat: `computedPagination(Supplier)` signature --- .../inventoryframework/state/StateAccess.java | 23 +++++++++++++++++++ .../state/StateAccessImpl.java | 20 ++++++++++++++-- .../inventoryframework/PlatformView.java | 15 ++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/state/StateAccess.java b/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/state/StateAccess.java index a9eac47d4..80d7dac0c 100644 --- a/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/state/StateAccess.java +++ b/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/state/StateAccess.java @@ -199,6 +199,19 @@ State computedPaginationState( @NotNull Function> sourceProvider, @NotNull PaginationValueConsumer valueConsumer); + /** + * Creates a new unmodifiable computed pagination state. + * + * @param sourceProvider Data source for pagination. + * @param valueConsumer Function for creating pagination items, this function is called for + * each paged element (item) on a page. + * @param The pagination data type. + * @return A new unmodifiable pagination state. + */ + State computedPaginationState( + @NotNull Supplier> sourceProvider, + @NotNull PaginationValueConsumer valueConsumer); + /** * Creates a new unmodifiable computed pagination state with asynchronous data source. *

@@ -278,6 +291,16 @@ State lazyAsyncPaginationState( PaginationStateBuilder buildComputedPaginationState( @NotNull Function> sourceProvider); + /** + * Creates a new unmodifiable dynamic pagination state builder. + * + * @param sourceProvider The data source for pagination. + * @param The pagination data type. + * @return A new pagination state builder. + */ + PaginationStateBuilder buildComputedPaginationState( + @NotNull Supplier> sourceProvider); + /** * Creates a new unmodifiable computed pagination state builder with asynchronous data source. *

diff --git a/inventory-framework-core/src/main/java/me/devnatan/inventoryframework/state/StateAccessImpl.java b/inventory-framework-core/src/main/java/me/devnatan/inventoryframework/state/StateAccessImpl.java index 66d74f12f..48f676f1c 100644 --- a/inventory-framework-core/src/main/java/me/devnatan/inventoryframework/state/StateAccessImpl.java +++ b/inventory-framework-core/src/main/java/me/devnatan/inventoryframework/state/StateAccessImpl.java @@ -139,7 +139,7 @@ public final State paginationState( } @Override - public final State computedPaginationState( + public State computedPaginationState( @NotNull Function> sourceProvider, @NotNull PaginationValueConsumer valueConsumer) { return this.buildComputedPaginationState(sourceProvider) @@ -147,6 +147,15 @@ public final State computedPaginationState( .build(); } + @Override + public State computedPaginationState( + @NotNull Supplier> sourceProvider, + @NotNull PaginationValueConsumer valueConsumer) { + return this.buildComputedPaginationState(sourceProvider) + .elementFactory(valueConsumer) + .build(); + } + @Override public final State computedAsyncPaginationState( @NotNull Function>> sourceProvider, @@ -191,12 +200,19 @@ public final PaginationStateBuilder buildPagination } @Override - public final PaginationStateBuilder buildComputedPaginationState( + public PaginationStateBuilder buildComputedPaginationState( @NotNull Function> sourceProvider) { return new PaginationStateBuilder<>( elementFactoryProvider, sourceProvider, this::createPaginationState, false, true); } + @Override + public PaginationStateBuilder buildComputedPaginationState( + @NotNull Supplier> sourceProvider) { + return new PaginationStateBuilder<>( + elementFactoryProvider, sourceProvider, this::createPaginationState, false, true); + } + @Override public final PaginationStateBuilder buildComputedAsyncPaginationState( @NotNull Function>> sourceProvider) { 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 560687c0a..cad0a897f 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 @@ -692,6 +692,14 @@ public final State computedPaginationState( return stateAccess.computedPaginationState(sourceProvider, valueConsumer); } + @Override + public final State computedPaginationState( + @NotNull Supplier> sourceProvider, + @NotNull PaginationValueConsumer valueConsumer) { + requireNotInitialized(); + return stateAccess.computedPaginationState(sourceProvider, valueConsumer); + } + @Override public final State computedAsyncPaginationState( @NotNull Function>> sourceProvider, @@ -738,6 +746,13 @@ public final PaginationStateBuilder buildComputedPaginat return stateAccess.buildComputedPaginationState(sourceProvider); } + @Override + public final PaginationStateBuilder buildComputedPaginationState( + @NotNull Supplier> sourceProvider) { + requireNotInitialized(); + return stateAccess.buildComputedPaginationState(sourceProvider); + } + @Override public final PaginationStateBuilder buildComputedAsyncPaginationState( @NotNull Function>> sourceProvider) {