DATACMNS-1021 - Add Order.asc(…) and Order.desc(…) factory methods.

We now support Order creation with Order.asc(String) and Order.desc(String) factory methods as shortcut to constructor creation via new Order(Direction, String).

Sort.by(Order.asc("age"), Order.desc("name"));

Deprecated Order(String) constructor in favor of the Order.by(String) factory method. Replace references to new Order(String) with Order.by(String).

Original pull request: #211.
This commit is contained in:
Mark Paluch
2017-04-25 11:17:54 +02:00
committed by Oliver Gierke
parent 78374f3cb7
commit 14647f9192
5 changed files with 54 additions and 9 deletions

View File

@@ -33,6 +33,7 @@ import com.querydsl.core.types.Path;
*
* @author Thomas Darimont
* @author Christoph Strobl
* @author Mark Paluch
*/
public class QSort extends Sort implements Serializable {
@@ -99,7 +100,7 @@ public class QSort extends Sort implements Serializable {
Assert.notNull(targetElement, "Target element must not be null!");
return new Order(targetElement.toString()).with(orderSpecifier.isAscending() ? Direction.ASC : Direction.DESC);
return Order.by(targetElement.toString()).with(orderSpecifier.isAscending() ? Direction.ASC : Direction.DESC);
}
/**