Browse Source

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.
pull/194/merge
Oliver Gierke 9 years ago
parent
commit
4918eca7cf
  1. 4
      src/main/java/org/springframework/data/domain/Chunk.java
  2. 10
      src/main/java/org/springframework/data/domain/Slice.java

4
src/main/java/org/springframework/data/domain/Chunk.java

@ -15,6 +15,8 @@ @@ -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 { @@ -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}.

10
src/main/java/org/springframework/data/domain/Slice.java

@ -100,6 +100,16 @@ public interface Slice<T> extends Streamable<T> { @@ -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

Loading…
Cancel
Save