Class SortedColumnsAttribute

java.lang.Object
com.illumon.iris.db.v2.SortedColumnsAttribute

public class SortedColumnsAttribute
extends Object
Helper class for managing the sorted columns attribute.
  • Method Details

    • getOrderForColumn

      public static Optional<SortingOrder> getOrderForColumn​(String attribute, String columnName)
      Retrieve the sorting order for a column from an attribute.
      Parameters:
      attribute - the Table's value of Table.SORTED_COLUMNS_ATTRIBUTE.
      columnName - the name of the column
      Returns:
      an optional containing the SortingOrder of the column if defined, empty otherwise
    • getOrderForColumn

      public static Optional<SortingOrder> getOrderForColumn​(Table table, String columnName)
      Retrieve the sorting order for a column from a table.
      Parameters:
      table - the table to interrogate
      columnName - the name of the column
      Returns:
      an optional containing the SortingOrder of the column if defined, empty otherwise
    • isSortedBy

      public static boolean isSortedBy​(Table table, String columnName, SortingOrder order)
      Determine if a table is sorted by the given column and order.
      Parameters:
      table - the table to interrogate
      columnName - the name of the column
      order - the order to check for
      Returns:
      true if table is sorted by columnName in the specified order
    • setOrderForColumn

      public static String setOrderForColumn​(String attribute, String columnName, SortingOrder order)
      Pack the desired sorting order into a String attribute.
      Parameters:
      attribute - an attribute containing sorting order
      columnName - the column to update
      order - the order that the column is sorted in
      Returns:
      a String suitable for use as a Table.SORTED_COLUMNS_ATTRIBUTE value.
    • setOrderForColumn

      public static void setOrderForColumn​(Table table, String columnName, SortingOrder order)
      Mark the table as sorted by the given column.
      Parameters:
      table - the table to update
      columnName - the column to update
      order - the order that the column is sorted in