Class SortKey

java.lang.Object
org.forgerock.json.resource.SortKey

public final class SortKey extends Object
A sort key which can be used to specify the order in which JSON resources should be included in the results of a query request.
  • Method Details

    • ascendingOrder

      public static SortKey ascendingOrder(JsonPointer field)
      Creates a new ascending-order sort key for the provided JSON field.
      Parameters:
      field - The sort key field.
      Returns:
      A new ascending-order sort key.
    • ascendingOrder

      public static SortKey ascendingOrder(String field)
      Creates a new ascending-order sort key for the provided JSON field.
      Parameters:
      field - The sort key field.
      Returns:
      A new ascending-order sort key.
      Throws:
      IllegalArgumentException - If field is not a valid JSON pointer.
    • descendingOrder

      public static SortKey descendingOrder(JsonPointer field)
      Creates a new descending-order sort key for the provided JSON field.
      Parameters:
      field - The sort key field.
      Returns:
      A new descending-order sort key.
    • descendingOrder

      public static SortKey descendingOrder(String field)
      Creates a new descending-order sort key for the provided JSON field.
      Parameters:
      field - The sort key field.
      Returns:
      A new descending-order sort key.
      Throws:
      IllegalArgumentException - If field is not a valid JSON pointer.
    • reverseOrder

      public static SortKey reverseOrder(SortKey key)
      Creates a new sort key having the same field as the provided key, but in reverse sort order.
      Parameters:
      key - The sort key to be reversed.
      Returns:
      The reversed sort key.
    • getField

      public JsonPointer getField()
      Returns the sort key field.
      Returns:
      The sort key field.
    • isAscendingOrder

      public boolean isAscendingOrder()
      Returns true if this sort key is in ascending order, or false if it is in descending order.
      Returns:
      true if this sort key is in ascending order, or false if it is in descending ord)er.
    • valueOf

      public static SortKey valueOf(String s)
      Parses the provided string as a sort key. If the string does not begin with a plus or minus symbol, then the sort key will default to ascending order.
      Parameters:
      s - The string representation of a sort key as specified in toString().
      Returns:
      The parsed sort key.
      Throws:
      IllegalArgumentException - If s is not a valid sort key.
    • toString

      public String toString()
      Returns the string representation of this sort key. It will be composed of a plus symbol, if the key is ascending, or a minus symbol, if the key is descending, followed by the field name.
      Overrides:
      toString in class Object
      Returns:
      The string representation of this sort key.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object