Class SortOrder

java.lang.Object
org.bremersee.comparator.model.SortOrder
All Implemented Interfaces:
Serializable

public class SortOrder extends Object implements Serializable
The sort order is a list of sort order items.
Author:
Christian Bremer
See Also:
  • Field Details

  • Constructor Details

    • SortOrder

      protected SortOrder()
      Instantiates an empty sort order.
    • SortOrder

      public SortOrder(Collection<? extends SortOrderItem> sortOrderItems)
      Instantiates a new unmodifiable sort order.
      Parameters:
      sortOrderItems - the sort order items
  • Method Details

    • getItems

      public List<SortOrderItem> getItems()
      Gets the unmodifiable list of sort order items.
      Returns:
      the list of sort order items
    • isEmpty

      public boolean isEmpty()
      Checks whether the list of items is empty or not.
      Returns:
      true if the list of items is empty, otherwise false
    • isSorted

      public boolean isSorted()
      Checks whether this sort order contains any entries. If there are entries, this is sorted, otherwise it is unsorted.
      Returns:
      true if the list of sort orders is not empty (aka sorted), otherwise false
    • isUnsorted

      public boolean isUnsorted()
      Checks whether this sort order contains any entries. If there are no entries, this is unsorted, otherwise it is sorted.
      Returns:
      true if the list of sort orders is empty (aka unsorted), otherwise false
    • getSortOrderText

      public String getSortOrderText()
      Creates the sort order text of this ordering descriptions.

      The syntax of the ordering description is

       fieldNameOrPath0,direction,case-handling,null-handling;fieldNameOrPath1,direction,case-handling,null-handling
       

      For example

       created,desc;person.lastName,asc;person.firstName,asc
       
      Returns:
      the sort order text
    • getSortOrderText

      public String getSortOrderText(SortOrderTextSeparators separators)
      Creates the sort order text of this ordering descriptions.

      The syntax of the ordering description is

       fieldNameOrPath0,direction,case-handling,null-handling;fieldNameOrPath1,direction,case-handling,null-handling
       

      For example

       created,desc;person.lastName,asc;person.firstName,asc
       
      Parameters:
      separators - the separators
      Returns:
      the sort order text
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromSortOrderText

      public static SortOrder fromSortOrderText(String source)
      From sort order text.
      Parameters:
      source - the sort order text
      Returns:
      the sort order
    • fromSortOrderText

      public static SortOrder fromSortOrderText(String source, SortOrderTextSeparators separators)
      From sort order text.
      Parameters:
      source - the sort order text
      separators - the separators
      Returns:
      the sort order
    • by

      public static SortOrder by(SortOrderItem... sortOrderItems)
      Creates new sort order with the given items.
      Parameters:
      sortOrderItems - the sort orders
      Returns:
      the sort order
    • unsorted

      public static SortOrder unsorted()