Package org.forgerock.json.resource
Class SortKeyComparator
java.lang.Object
org.forgerock.json.resource.SortKeyComparator
- All Implemented Interfaces:
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
).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Defines possible positions for JsonValue that wraps anull
object. -
Constructor Summary
ConstructorsConstructorDescriptionSortKeyComparator
(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
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 Details
-
SortKeyComparator
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
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:
-
-
Method Details
-
compare
- Specified by:
compare
in interfaceComparator<JsonValue>
-