@@ -234,13 +234,16 @@ public static Direction fromStringOrNull(String value) {
234
234
* {@link Sort}
235
235
*
236
236
* @author Oliver Gierke
237
+ * @author Kevin Raymond
237
238
*/
238
239
public static class Order implements Serializable {
239
240
240
241
private static final long serialVersionUID = 1522511010900108987L ;
242
+ private static final boolean DEFAULT_IGNORE_CASE = false ;
241
243
242
244
private final Direction direction ;
243
245
private final String property ;
246
+ private final boolean ignoreCase ;
244
247
245
248
/**
246
249
* Creates a new {@link Order} instance. if order is {@literal null} then order defaults to
@@ -251,12 +254,7 @@ public static class Order implements Serializable {
251
254
*/
252
255
public Order (Direction direction , String property ) {
253
256
254
- if (!StringUtils .hasText (property )) {
255
- throw new IllegalArgumentException ("Property must not null or empty!" );
256
- }
257
-
258
- this .direction = direction == null ? DEFAULT_DIRECTION : direction ;
259
- this .property = property ;
257
+ this (direction , property , DEFAULT_IGNORE_CASE );
260
258
}
261
259
262
260
/**
@@ -269,6 +267,25 @@ public Order(String property) {
269
267
this (DEFAULT_DIRECTION , property );
270
268
}
271
269
270
+ /**
271
+ * Creates a new {@link Order} instance. if order is {@literal null} then order defaults to
272
+ * {@link Sort#DEFAULT_DIRECTION}
273
+ *
274
+ * @param direction can be {@literal null}, will default to {@link Sort#DEFAULT_DIRECTION}
275
+ * @param property must not be {@literal null} or empty.
276
+ * @param ignoreCase true if sorting should be case insensitive. false if sorting should be case sensitive.
277
+ */
278
+ private Order (Direction direction , String property , boolean ignoreCase ) {
279
+
280
+ if (!StringUtils .hasText (property )) {
281
+ throw new IllegalArgumentException ("Property must not null or empty!" );
282
+ }
283
+
284
+ this .direction = direction == null ? DEFAULT_DIRECTION : direction ;
285
+ this .property = property ;
286
+ this .ignoreCase = ignoreCase ;
287
+ }
288
+
272
289
/**
273
290
* @deprecated use {@link Sort#Sort(Direction, List)} instead.
274
291
*/
@@ -309,6 +326,15 @@ public boolean isAscending() {
309
326
return this .direction .equals (Direction .ASC );
310
327
}
311
328
329
+ /**
330
+ * Returns whether or not the sort will be case sensitive.
331
+ *
332
+ * @return
333
+ */
334
+ public boolean isIgnoreCase () {
335
+ return ignoreCase ;
336
+ }
337
+
312
338
/**
313
339
* Returns a new {@link Order} with the given {@link Order}.
314
340
*
@@ -329,6 +355,15 @@ public Sort withProperties(String... properties) {
329
355
return new Sort (this .direction , properties );
330
356
}
331
357
358
+ /**
359
+ * Returns a new {@link Order} with case insensitive sorting enabled.
360
+ *
361
+ * @return
362
+ */
363
+ public Order ignoreCase () {
364
+ return new Order (direction , property , true );
365
+ }
366
+
332
367
/*
333
368
* (non-Javadoc)
334
369
* @see java.lang.Object#hashCode()
0 commit comments