DATACMNS-867 - Removed handling of null Pageables.
Pageable now exposes a dedicated null-object representing the absence of pagination so that all places that previously handled null values can now rather be more relaxed and assume that a non-null value is given.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2013 the original author or authors.
|
||||
* Copyright 2008-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -120,4 +122,13 @@ public interface Pageable {
|
||||
* @return
|
||||
*/
|
||||
boolean hasPrevious();
|
||||
|
||||
/**
|
||||
* Returns an {@link Optional} so that it can easily be mapped on.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default Optional<Pageable> toOptional() {
|
||||
return isUnpaged() ? Optional.empty() : Optional.of(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user