DATACMNS-1043 - Slice now exposes Pageable.
We now expose the Pageable that was used to create a Slice via its API. Slice itself constructs a default PageRequest so that current implementations of it still work as before.
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -38,7 +40,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable {
|
||||
private static final long serialVersionUID = 867755909294344406L;
|
||||
|
||||
private final List<T> content = new ArrayList<>();
|
||||
private final Pageable pageable;
|
||||
private final @Getter Pageable pageable;
|
||||
|
||||
/**
|
||||
* Creates a new {@link Chunk} with the given content and the given governing {@link Pageable}.
|
||||
|
||||
@@ -100,6 +100,16 @@ public interface Slice<T> extends Streamable<T> {
|
||||
*/
|
||||
boolean hasPrevious();
|
||||
|
||||
/**
|
||||
* Returns the {@link Pageable} that's been used to request the current {@link Slice}.
|
||||
*
|
||||
* @return
|
||||
* @since 2.0
|
||||
*/
|
||||
default Pageable getPageable() {
|
||||
return PageRequest.of(getNumber(), getSize(), getSort());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Pageable} to request the next {@link Slice}. Can be {@literal null} in case the current
|
||||
* {@link Slice} is already the last one. Clients should check {@link #hasNext()} before calling this method to make
|
||||
|
||||
Reference in New Issue
Block a user