Package org.forgerock.json.resource
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 anull
object could be considered either as the lowest possible value (SortKeyComparator.NullPosition.NULL_FIRST
, default) or the highest possible value (SortKeyComparator.NullPosition.NULL_LAST
).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SortKeyComparator.NullPosition
Defines possible positions for JsonValue that wraps anull
object.
-
Constructor Summary
Constructors Constructor Description SortKeyComparator(List<SortKey> sortKeys)
Construct a Comparator that will compare two JsonValue objects based on the provided list of SortKeys.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(JsonValue left, JsonValue right)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Constructor Detail
-
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 anull
object should be considered less or more that one that is not.- See Also:
SortKeyComparator.NullPosition
-
-
Method Detail
-
compare
public int compare(JsonValue left, JsonValue right)
- Specified by:
compare
in interfaceComparator<JsonValue>
-
-