Package org.bremersee.comparator
Interface WellKnownTextParser
-
public interface WellKnownTextParserParses the string representation of a sort order and creates a comparator.The default implementation supports the following syntax:
fieldNameOrPath0,asc,ignoreCase,nullIsFirst|fieldNameOrPath1,asc,ignoreCase,nullIsFirst
For example
person.lastName,asc,true,false|person.firstName,asc,true,false
- Author:
- Christian Bremer
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Comparatorapply(ComparatorField comparatorField)Creates the comparator for the given field.default ComparatorFieldbuildComparatorField(String fieldDescription)Builds a comparator field from the string representation of a sort order (must be a single field, not a path).default List<ComparatorField>buildComparatorFields(String wkt)Builds a list of comparator fields from the string representation of a sort order.static booleanfindBooleanPart(String fieldDescription, String delimiter, int index, boolean defaultValue, String... expectedValues)Finds a boolean part of the field description.static StringfindStringPart(String fieldDescription, String delimiter, int index)Finds a string part of the field description.default Comparator<Object>parse(String wkt)Parses the string representation of a sort order and creates a comparator.
-
-
-
Method Detail
-
parse
default Comparator<Object> parse(String wkt)
Parses the string representation of a sort order and creates a comparator.The default implementation supports the following syntax:
fieldNameOrPath0,asc,ignoreCase,nullIsFirst|fieldNameOrPath1,asc,ignoreCase,nullIsFirst
For example
person.lastName,asc,true,false|person.firstName,asc,true,false
- Parameters:
wkt- the string representation of a sort order (as well known text)- Returns:
- the created comparator
-
buildComparatorFields
default List<ComparatorField> buildComparatorFields(String wkt)
Builds a list of comparator fields from the string representation of a sort order.The default implementation supports the following syntax:
fieldNameOrPath0,asc,ignoreCase,nullIsFirst|fieldNameOrPath1,asc,ignoreCase,nullIsFirst
For example
person.lastName,asc,true,false|person.firstName,asc,true,false
- Parameters:
wkt- the string representation of a sort order (as well known text)- Returns:
- the list of comparator fields
-
buildComparatorField
default ComparatorField buildComparatorField(String fieldDescription)
Builds a comparator field from the string representation of a sort order (must be a single field, not a path).The default implementation supports the following syntax:
fieldNameOrPath,asc,ignoreCase,nullIsFirst
For example
person.lastName,asc,true,false
- Parameters:
fieldDescription- the field description- Returns:
- the comparator field
-
apply
Comparator apply(ComparatorField comparatorField)
Creates the comparator for the given field.- Parameters:
comparatorField- the comparator field- Returns:
- the comparator
-
findStringPart
static String findStringPart(String fieldDescription, String delimiter, int index)
Finds a string part of the field description.- Parameters:
fieldDescription- the field descriptiondelimiter- the delimiterindex- the index- Returns:
- the string
-
findBooleanPart
static boolean findBooleanPart(String fieldDescription, String delimiter, int index, boolean defaultValue, String... expectedValues)
Finds a boolean part of the field description.- Parameters:
fieldDescription- the field descriptiondelimiter- the delimiterindex- the indexdefaultValue- the default valueexpectedValues- the expected values- Returns:
- the boolean
-
-