Class ComparatorField


  • public class ComparatorField
    extends Object
    This class defines the sort order of a field.
      ---------------------------------------------------------------------------------------------
     | Attribute    | Description                                                       | Default  |
     |--------------|-------------------------------------------------------------------|----------|
     | add          | The add name (or method name) of the object. It can be a path.    | null     |
     |              | The segments are separated by a dot (.): field0.field1.field2     |          |
     |--------------|-------------------------------------------------------------------|----------|
     | asc or desc  | Defines ascending or descending ordering.                         | asc      |
     |--------------|-------------------------------------------------------------------|----------|
     | ignoreCase   | Makes a case ignoring comparison (only for strings).              | true     |
     |--------------|-------------------------------------------------------------------|----------|
     | nullIsFirst  | Defines the ordering if one of the values is null.                | false    |
      ---------------------------------------------------------------------------------------------
     

    These values have a 'well known text' representation. The values are concatenated with comma (,):

     fieldNameOrPath,asc,ignoreCase,nullIsFirst
     

    For example:

     properties.customSettings.priority,asc,true,false
     

    Defaults can be omitted. This is the same:

     properties.customSettings.priority
     

    The building of a chain is done by concatenate the fields with a pipe (|):

     field0,asc,ignoreCase,nullIsFirst|field1,asc,ignoreCase,nullIsFirst
     
    Author:
    Christian Bremer
    • Constructor Detail

      • ComparatorField

        public ComparatorField()
        Instantiates a new comparator field.
      • ComparatorField

        public ComparatorField​(String field,
                               boolean asc,
                               boolean ignoreCase,
                               boolean nullIsFirst)
        Instantiates a new comparator field.
        Parameters:
        field - the field name or path (can be null)
        asc - true for an ascending order, false for a descending order
        ignoreCase - true for a case insensitive order, false for a case sensitive order
        nullIsFirst - specifies the order of null values
    • Method Detail

      • getField

        public String getField()
        Gets field name or path.
        Returns:
        the field name or path
      • isAsc

        public boolean isAsc()
        Is ascending or descending order.
        Returns:
        true if ascending order, false if descending order
      • isIgnoreCase

        public boolean isIgnoreCase()
        Is case insensitive or sensitive order.
        Returns:
        true if case insensitive order, false if case sensitive order
      • isNullIsFirst

        public boolean isNullIsFirst()
        Is null is first.
        Returns:
        true if null is first, otherwise false
      • toWkt

        public String toWkt()
        Creates the well known text of this field ordering description.

        The syntax of the field ordering description is

         fieldNameOrPath,asc,ignoreCase,nullIsFirst
         

        For example

         person.lastName,asc,true,false
         
        Returns:
        the well known text
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object