2626 *
2727 * @author Mark Paluch
2828 * @author Milan Milanov
29+ * @author Mikhail Polivakha
2930 * @since 1.1
3031 */
3132public class OrderByField extends AbstractSegment {
3233
3334 private final Expression expression ;
3435 private final @ Nullable Sort .Direction direction ;
3536 private final Sort .NullHandling nullHandling ;
37+ private final boolean caseInsensitive ;
3638
37- private OrderByField (Expression expression , @ Nullable Direction direction , NullHandling nullHandling ) {
39+ private OrderByField (Expression expression , @ Nullable Direction direction , NullHandling nullHandling , boolean caseInsensitive ) {
3840
3941 super (expression );
4042 Assert .notNull (expression , "Order by expression must not be null" );
4143 Assert .notNull (nullHandling , "NullHandling by expression must not be null" );
4244
4345 this .expression = expression ;
4446 this .direction = direction ;
47+ this .caseInsensitive = caseInsensitive ;
4548 this .nullHandling = nullHandling ;
4649 }
4750
@@ -52,38 +55,51 @@ private OrderByField(Expression expression, @Nullable Direction direction, NullH
5255 * @return the {@link OrderByField}.
5356 */
5457 public static OrderByField from (Expression expression ) {
55- return new OrderByField (expression , null , NullHandling .NATIVE );
58+ return new OrderByField (expression , null , NullHandling .NATIVE , false );
5659 }
5760
5861 /**
5962 * Creates a new {@link OrderByField} from an {@link Expression} applying a given ordering.
6063 *
6164 * @param expression must not be {@literal null}.
62- * @param direction order direction
65+ * @param direction order direction.
6366 * @return the {@link OrderByField}.
6467 */
6568 public static OrderByField from (Expression expression , Direction direction ) {
66- return new OrderByField (expression , direction , NullHandling .NATIVE );
69+ return new OrderByField (expression , direction , NullHandling .NATIVE , false );
6770 }
6871
6972 /**
70- * Creates a new {@link OrderByField} from a the current one using ascending sorting.
73+ * Creates a new {@link OrderByField} from an {@link Expression} applying a given ordering and {@link NullHandling}.
74+ *
75+ * @param expression must not be {@literal null}.
76+ * @param direction order direction.
77+ * @param nullHandling the null handling strategy.
78+ * @param caseInsensitive whether the ordering is case-insensitive.
79+ * @return the {@link OrderByField}.
80+ */
81+ public static OrderByField from (Expression expression , Direction direction , NullHandling nullHandling , boolean caseInsensitive ) {
82+ return new OrderByField (expression , direction , nullHandling , caseInsensitive );
83+ }
84+
85+ /**
86+ * Creates a new {@link OrderByField} from a current one using ascending sorting.
7187 *
7288 * @return the new {@link OrderByField} with ascending sorting.
7389 * @see #desc()
7490 */
7591 public OrderByField asc () {
76- return new OrderByField (expression , Direction .ASC , nullHandling );
92+ return new OrderByField (expression , Direction .ASC , nullHandling , caseInsensitive );
7793 }
7894
7995 /**
80- * Creates a new {@link OrderByField} from a the current one using descending sorting.
96+ * Creates a new {@link OrderByField} from a current one using descending sorting.
8197 *
8298 * @return the new {@link OrderByField} with descending sorting.
8399 * @see #asc()
84100 */
85101 public OrderByField desc () {
86- return new OrderByField (expression , Direction .DESC , nullHandling );
102+ return new OrderByField (expression , Direction .DESC , nullHandling , caseInsensitive );
87103 }
88104
89105 /**
@@ -93,7 +109,7 @@ public OrderByField desc() {
93109 * @return the new {@link OrderByField} with {@link NullHandling} applied.
94110 */
95111 public OrderByField withNullHandling (NullHandling nullHandling ) {
96- return new OrderByField (expression , direction , nullHandling );
112+ return new OrderByField (expression , direction , nullHandling , caseInsensitive );
97113 }
98114
99115 public Expression getExpression () {
0 commit comments