#2663 - No effective change - Tidy Query interface with default methods

This commit is contained in:
Rob Bygrave
2022-04-20 21:49:06 +12:00
parent 76b02ff56a
commit 4d21fbfcf8
3 changed files with 21 additions and 44 deletions
+21 -14
View File
@@ -2,6 +2,7 @@ package io.ebean;
import io.avaje.lang.NonNullApi;
import io.avaje.lang.Nullable;
import javax.persistence.NonUniqueResultException;
import java.sql.Connection;
import java.sql.Timestamp;
@@ -1372,18 +1373,9 @@ public interface Query<T> extends CancelableQuery {
* optional asc and desc keywords representing ascending and descending order
* respectively.
*/
Query<T> order(String orderByClause);
/**
* Return the OrderBy so that you can append an ascending or descending
* property to the order by clause.
* <p>
* This will never return a null. If no order by clause exists then an 'empty'
* OrderBy object is returned.
* <p>
* This is the same as <code>orderBy()</code>
*/
OrderBy<T> order();
default Query<T> order(String orderByClause) {
return orderBy(orderByClause);
}
/**
* Return the OrderBy so that you can append an ascending or descending
@@ -1397,15 +1389,30 @@ public interface Query<T> extends CancelableQuery {
OrderBy<T> orderBy();
/**
* Set an OrderBy object to replace any existing OrderBy clause.
* Return the OrderBy so that you can append an ascending or descending
* property to the order by clause.
* <p>
* This will never return a null. If no order by clause exists then an 'empty'
* OrderBy object is returned.
* <p>
* This is the same as <code>orderBy()</code>
*/
Query<T> setOrder(OrderBy<T> orderBy);
default OrderBy<T> order() {
return orderBy();
}
/**
* Set an OrderBy object to replace any existing OrderBy clause.
*/
Query<T> setOrderBy(OrderBy<T> orderBy);
/**
* Set an OrderBy object to replace any existing OrderBy clause.
*/
default Query<T> setOrder(OrderBy<T> orderBy) {
return setOrderBy(orderBy);
}
/**
* Set whether this query uses DISTINCT.
* <p>
@@ -432,26 +432,11 @@ final class DefaultFetchGroupQuery<T> implements SpiFetchGroupQuery<T>, SpiQuery
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
}
@Override
public Query<T> order(String orderByClause) {
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
}
@Override
public OrderBy<T> order() {
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
}
@Override
public OrderBy<T> orderBy() {
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
}
@Override
public Query<T> setOrder(OrderBy<T> orderBy) {
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
}
@Override
public Query<T> setOrderBy(OrderBy<T> orderBy) {
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
@@ -1614,11 +1614,6 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
@Override
public OrderBy<T> orderBy() {
return order();
}
@Override
public OrderBy<T> order() {
if (orderBy == null) {
orderBy = new OrderBy<>(this, null);
}
@@ -1627,11 +1622,6 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
@Override
public Query<T> orderBy(String orderByClause) {
return order(orderByClause);
}
@Override
public Query<T> order(String orderByClause) {
if (orderByClause == null || orderByClause.trim().isEmpty()) {
this.orderBy = null;
} else {
@@ -1642,11 +1632,6 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
@Override
public Query<T> setOrderBy(OrderBy<T> orderBy) {
return setOrder(orderBy);
}
@Override
public Query<T> setOrder(OrderBy<T> orderBy) {
this.orderBy = orderBy;
if (orderBy != null) {
orderBy.setQuery(this);