|
15 | 15 | */
|
16 | 16 | package org.springframework.data.repository.query;
|
17 | 17 |
|
18 |
| -import org.springframework.data.domain.Window; |
19 | 18 | import reactor.core.publisher.Flux;
|
20 | 19 | import reactor.core.publisher.Mono;
|
21 | 20 |
|
22 | 21 | import java.util.Arrays;
|
23 | 22 | import java.util.Collection;
|
24 | 23 | import java.util.List;
|
25 | 24 | import java.util.Optional;
|
| 25 | +import java.util.function.Function; |
26 | 26 | import java.util.stream.Stream;
|
27 | 27 |
|
28 | 28 | import org.springframework.data.domain.Page;
|
29 | 29 | import org.springframework.data.domain.Pageable;
|
30 | 30 | import org.springframework.data.domain.ScrollPosition;
|
| 31 | +import org.springframework.data.domain.Slice; |
31 | 32 | import org.springframework.data.domain.Sort;
|
| 33 | +import org.springframework.data.domain.Window; |
32 | 34 | import org.springframework.lang.Nullable;
|
33 | 35 |
|
34 | 36 | /**
|
|
41 | 43 | public interface FluentQuery<T> {
|
42 | 44 |
|
43 | 45 | /**
|
44 |
| - * Define the sort order. |
| 46 | + * Define the sort order. Multiple calls will add {@link Sort#and(Sort) Sort} specifications. |
45 | 47 | *
|
46 | 48 | * @param sort the {@link Sort} specification to sort the results by, may be {@link Sort#unsorted()}, must not be
|
47 | 49 | * {@literal null}.
|
@@ -189,6 +191,19 @@ default Window<T> scroll(ScrollPosition scrollPosition) {
|
189 | 191 | */
|
190 | 192 | Page<T> page(Pageable pageable);
|
191 | 193 |
|
| 194 | + /** |
| 195 | + * Get a slice of matching elements for {@link Pageable}. |
| 196 | + * |
| 197 | + * @param pageable the pageable to request a sliced result, can be {@link Pageable#unpaged()}, must not be |
| 198 | + * {@literal null}. The given {@link Pageable} will override any previously specified {@link Sort sort}. |
| 199 | + * Any potentially specified {@link #limit(int)} will be overridden by {@link Pageable#getPageSize()}. |
| 200 | + * @return |
| 201 | + * @since 3.5 |
| 202 | + */ |
| 203 | + default Slice<T> slice(Pageable pageable) { |
| 204 | + return page(pageable); |
| 205 | + } |
| 206 | + |
192 | 207 | /**
|
193 | 208 | * Stream all matching elements.
|
194 | 209 | *
|
@@ -285,6 +300,19 @@ default Mono<Window<T>> scroll(ScrollPosition scrollPosition) {
|
285 | 300 | */
|
286 | 301 | Mono<Page<T>> page(Pageable pageable);
|
287 | 302 |
|
| 303 | + /** |
| 304 | + * Get a slice of matching elements for {@link Pageable}. |
| 305 | + * |
| 306 | + * @param pageable the pageable to request a sliced result, can be {@link Pageable#unpaged()}, must not be |
| 307 | + * {@literal null}. The given {@link Pageable} will override any previously specified {@link Sort sort}. |
| 308 | + * Any potentially specified {@link #limit(int)} will be overridden by {@link Pageable#getPageSize()}. |
| 309 | + * @return |
| 310 | + * @since 3.5 |
| 311 | + */ |
| 312 | + default Mono<Slice<T>> slice(Pageable pageable) { |
| 313 | + return page(pageable).map(Function.identity()); |
| 314 | + } |
| 315 | + |
288 | 316 | /**
|
289 | 317 | * Get the number of matching elements.
|
290 | 318 | *
|
|
0 commit comments