Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,19 @@ <T> State<Pagination> computedPaginationState(
@NotNull Function<Context, List<? super T>> sourceProvider,
@NotNull PaginationValueConsumer<Context, ItemBuilder, T> 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 <T> The pagination data type.
* @return A new unmodifiable pagination state.
*/
<T> State<Pagination> computedPaginationState(
@NotNull Supplier<List<? super T>> sourceProvider,
@NotNull PaginationValueConsumer<Context, ItemBuilder, T> valueConsumer);

/**
* Creates a new unmodifiable computed pagination state with asynchronous data source.
* <p>
Expand Down Expand Up @@ -278,6 +291,16 @@ <T> State<Pagination> lazyAsyncPaginationState(
<T> PaginationStateBuilder<Context, ItemBuilder, T> buildComputedPaginationState(
@NotNull Function<Context, List<? super T>> sourceProvider);

/**
* Creates a new unmodifiable dynamic pagination state builder.
*
* @param sourceProvider The data source for pagination.
* @param <T> The pagination data type.
* @return A new pagination state builder.
*/
<T> PaginationStateBuilder<Context, ItemBuilder, T> buildComputedPaginationState(
@NotNull Supplier<List<? super T>> sourceProvider);

/**
* Creates a new unmodifiable computed pagination state builder with asynchronous data source.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private CompletableFuture<List<?>> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,23 @@ public final <T> State<Pagination> paginationState(
}

@Override
public final <T> State<Pagination> computedPaginationState(
public <T> State<Pagination> computedPaginationState(
@NotNull Function<Context, List<? super T>> sourceProvider,
@NotNull PaginationValueConsumer<Context, ItemBuilder, T> valueConsumer) {
return this.buildComputedPaginationState(sourceProvider)
.elementFactory(valueConsumer)
.build();
}

@Override
public <T> State<Pagination> computedPaginationState(
@NotNull Supplier<List<? super T>> sourceProvider,
@NotNull PaginationValueConsumer<Context, ItemBuilder, T> valueConsumer) {
return this.buildComputedPaginationState(sourceProvider)
.elementFactory(valueConsumer)
.build();
}

@Override
public final <T> State<Pagination> computedAsyncPaginationState(
@NotNull Function<Context, CompletableFuture<List<T>>> sourceProvider,
Expand Down Expand Up @@ -191,12 +200,19 @@ public final <T> PaginationStateBuilder<Context, ItemBuilder, T> buildPagination
}

@Override
public final <T> PaginationStateBuilder<Context, ItemBuilder, T> buildComputedPaginationState(
public <T> PaginationStateBuilder<Context, ItemBuilder, T> buildComputedPaginationState(
@NotNull Function<Context, List<? super T>> sourceProvider) {
return new PaginationStateBuilder<>(
elementFactoryProvider, sourceProvider, this::createPaginationState, false, true);
}

@Override
public <T> PaginationStateBuilder<Context, ItemBuilder, T> buildComputedPaginationState(
@NotNull Supplier<List<? super T>> sourceProvider) {
return new PaginationStateBuilder<>(
elementFactoryProvider, sourceProvider, this::createPaginationState, false, true);
}

@Override
public final <T> PaginationStateBuilder<Context, ItemBuilder, T> buildComputedAsyncPaginationState(
@NotNull Function<Context, CompletableFuture<List<T>>> sourceProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,14 @@ public final <T> State<Pagination> computedPaginationState(
return stateAccess.computedPaginationState(sourceProvider, valueConsumer);
}

@Override
public final <T> State<Pagination> computedPaginationState(
@NotNull Supplier<List<? super T>> sourceProvider,
@NotNull PaginationValueConsumer<TContext, TItem, T> valueConsumer) {
requireNotInitialized();
return stateAccess.computedPaginationState(sourceProvider, valueConsumer);
}

@Override
public final <T> State<Pagination> computedAsyncPaginationState(
@NotNull Function<TContext, CompletableFuture<List<T>>> sourceProvider,
Expand Down Expand Up @@ -738,6 +746,13 @@ public final <T> PaginationStateBuilder<TContext, TItem, T> buildComputedPaginat
return stateAccess.buildComputedPaginationState(sourceProvider);
}

@Override
public final <T> PaginationStateBuilder<TContext, TItem, T> buildComputedPaginationState(
@NotNull Supplier<List<? super T>> sourceProvider) {
requireNotInitialized();
return stateAccess.buildComputedPaginationState(sourceProvider);
}

@Override
public final <T> PaginationStateBuilder<TContext, TItem, T> buildComputedAsyncPaginationState(
@NotNull Function<TContext, CompletableFuture<List<T>>> sourceProvider) {
Expand Down
Loading