Class SortKeyComparator

java.lang.Object
org.forgerock.json.resource.SortKeyComparator
All Implemented Interfaces:
Comparator<JsonValue>

public class SortKeyComparator extends Object implements Comparator<JsonValue>
This comparator iterates through the provided sortKeys and finds the first comparative difference between the left and right side JsonValues. To ensure consistency with sort order, at least one sortKey should be provided that will guarantee uniqueness between two JsonValues. A JsonValue that wraps a null object could be considered either as the lowest possible value (SortKeyComparator.NullPosition.NULL_FIRST, default) or the highest possible value (SortKeyComparator.NullPosition.NULL_LAST).
See Also:
  • Constructor Details

    • SortKeyComparator

      public SortKeyComparator(List<SortKey> sortKeys)
      Construct a Comparator that will compare two JsonValue objects based on the provided list of SortKeys.
      Parameters:
      sortKeys - the sortKeys to utilize for sorting.
    • SortKeyComparator

      public SortKeyComparator(List<SortKey> sortKeys, SortKeyComparator.NullPosition nullPosition)
      Construct a Comparator that will compare two JsonValue objects based on the provided list of SortKeys and options.
      Parameters:
      sortKeys - the sortKeys to utilize for sorting.
      nullPosition - Whether a JsonValue that wraps a null object should be considered less or more that one that is not.
      See Also:
  • Method Details