Interface WellKnownTextParser


  • 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

      • 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 description
        delimiter - the delimiter
        index - 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 description
        delimiter - the delimiter
        index - the index
        defaultValue - the default value
        expectedValues - the expected values
        Returns:
        the boolean