DATACMNS-658 - Add IgnoreCase ordering option to SortHandlerMethodArgumentResolver.

We now pick up case-insensitive sorting flags by parsing it up from a sort query string argument.

To enable ignore case for one or more properties, we expect "ignorecase" as last element in a sort spec. Sort order and case-sensitivity options are parsed case-insensitive for a greater flexibility:

http://localhost/?sort=firstname,IgnoreCase or http://localhost/?sort=firstname,ASC,ignorecase

Original pull request: #172.
This commit is contained in:
Dan Nawrocki
2020-03-02 11:59:37 +01:00
committed by Mark Paluch
parent f2a6391273
commit 9ef3099711
2 changed files with 27 additions and 2 deletions

View File

@@ -187,8 +187,10 @@ public abstract class SortHandlerMethodArgumentResolverSupport {
/**
* Parses the given sort expressions into a {@link Sort} instance. The implementation expects the sources to be a
* concatenation of Strings using the given delimiter. If the last element can be parsed into a {@link Direction} it's
* considered a {@link Direction} and a simple property otherwise.
* concatenation of Strings using the given delimiter. If the last element is equal to "ignorecase" (when using a
* case-insensitive comparison), the sort order will be performed without respect to case. If the last element (or the
* penultimate element if the last is "ignorecase") can be parsed into a {@link Direction} it's considered a
* {@link Direction} and a simple property otherwise.
*
* @param source will never be {@literal null}.
* @param delimiter the delimiter to be used to split up the source elements, will never be {@literal null}.