Package org.bremersee.comparator
Interface WellKnownTextParser
-
- All Known Implementing Classes:
WellKnownTextParser.Impl
@Valid 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classWellKnownTextParser.ImplAn implementation.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description @NotNull Comparatorapply(ComparatorField comparatorField)Creates the comparator for the given field.default @NotNull ComparatorFieldbuildComparatorField(String fieldDescription)Builds a comparator field from the string representation of a sort order (must be a single field, not a path).default @NotNull List<ComparatorField>buildComparatorFields(String wkt)Builds a list of comparator fields from the string representation of a sort order.default @NotNull WellKnownTextPropertiesgetProperties()Gets properties.static @NotNull WellKnownTextParsernewInstance(@NotNull Function<ComparatorField,Comparator> comparatorFunction)New instance well known text parser.static @NotNull WellKnownTextParsernewInstance(@NotNull Function<ComparatorField,Comparator> comparatorFunction, WellKnownTextProperties properties)New instance well known text parser.default @NotNull Comparator<Object>parse(String wkt)Parses the string representation of a sort order and creates a comparator.
-
-
-
Method Detail
-
getProperties
@NotNull default @NotNull WellKnownTextProperties getProperties()
Gets properties.- Returns:
- the properties
-
parse
@NotNull default @NotNull 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
@NotNull default @NotNull 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
@NotNull default @NotNull 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
@NotNull @NotNull Comparator apply(ComparatorField comparatorField)
Creates the comparator for the given field.- Parameters:
comparatorField- the comparator field- Returns:
- the comparator
-
newInstance
@NotNull static @NotNull WellKnownTextParser newInstance(@NotNull @NotNull Function<ComparatorField,Comparator> comparatorFunction)
New instance well known text parser.- Parameters:
comparatorFunction- the comparator function- Returns:
- the well known text parser
-
newInstance
@NotNull static @NotNull WellKnownTextParser newInstance(@NotNull @NotNull Function<ComparatorField,Comparator> comparatorFunction, WellKnownTextProperties properties)
New instance well known text parser.- Parameters:
comparatorFunction- the comparator functionproperties- the properties- Returns:
- the well known text parser
-
-