DATACMNS-402 - Slight refinements in QSort implementation.
Re-enable concatenation with plain Sort via ….and(…) method. Some general polishing and JavaDoc cleanups. Original pull request: #59.
This commit is contained in:
@@ -21,6 +21,7 @@ import java.io.Serializable;
|
||||
* Abstract Java Bean implementation of {@code Pageable}.
|
||||
*
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public abstract class AbstractPageRequest implements Pageable, Serializable {
|
||||
|
||||
@@ -33,8 +34,8 @@ public abstract class AbstractPageRequest implements Pageable, Serializable {
|
||||
* Creates a new {@link AbstractPageRequest}. Pages are zero indexed, thus providing 0 for {@code page} will return
|
||||
* the first page.
|
||||
*
|
||||
* @param page
|
||||
* @param size
|
||||
* @param page must not be less than zero.
|
||||
* @param size must not be less than one.
|
||||
*/
|
||||
public AbstractPageRequest(int page, int size) {
|
||||
|
||||
@@ -82,6 +83,14 @@ public abstract class AbstractPageRequest implements Pageable, Serializable {
|
||||
return page > 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.domain.Pageable#previousOrFirst()
|
||||
*/
|
||||
public Pageable previousOrFirst() {
|
||||
return hasPrevious() ? previous() : first();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.domain.Pageable#next()
|
||||
@@ -101,24 +110,19 @@ public abstract class AbstractPageRequest implements Pageable, Serializable {
|
||||
*/
|
||||
public abstract Pageable first();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.domain.Pageable#previousOrFirst()
|
||||
*/
|
||||
public Pageable previousOrFirst() {
|
||||
return hasPrevious() ? previous() : first();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
|
||||
result = prime * result + page;
|
||||
result = prime * result + size;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -128,17 +132,16 @@ public abstract class AbstractPageRequest implements Pageable, Serializable {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AbstractPageRequest other = (AbstractPageRequest) obj;
|
||||
if (page != other.page)
|
||||
return false;
|
||||
if (size != other.size)
|
||||
return false;
|
||||
return true;
|
||||
return this.page == other.page && this.size == other.size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class QSort extends Sort implements Serializable {
|
||||
Assert.notNull(orderSpecifier, "Order specifier must not be null!");
|
||||
|
||||
Expression<?> target = orderSpecifier.getTarget();
|
||||
Object targetElement = ((com.mysema.query.types.Path) target).getMetadata().getElement();
|
||||
Object targetElement = ((com.mysema.query.types.Path<?>) target).getMetadata().getElement();
|
||||
|
||||
Assert.notNull(targetElement, "Target element must not be null!");
|
||||
|
||||
@@ -100,15 +100,6 @@ public class QSort extends Sort implements Serializable {
|
||||
return orderSpecifiers;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.domain.Sort#and(org.springframework.data.domain.Sort)
|
||||
*/
|
||||
@Override
|
||||
public Sort and(Sort sort) {
|
||||
throw new UnsupportedOperationException("You cannot combine a querydsl based QSort with an arbitrary Sort!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link QSort} consisting of the {@link OrderSpecifier}s of the current {@code QSort} combined with
|
||||
* the ones from the given {@code QSort}.
|
||||
@@ -147,7 +138,6 @@ public class QSort extends Sort implements Serializable {
|
||||
public QSort and(OrderSpecifier<?>... orderSpecifiers) {
|
||||
|
||||
Assert.notEmpty(orderSpecifiers, "OrderSpecifiers must not be null or empty!");
|
||||
|
||||
return and(Arrays.asList(orderSpecifiers));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user