Interface WellKnownTextParser

  • All Known Implementing Classes:
    WellKnownTextParser.Impl

    @Valid
    public interface WellKnownTextParser
    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
     
    Author:
    Christian Bremer
    • 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