Class CompactMap.CompactMapComparator

java.lang.Object
com.cedarsoftware.util.CompactMap.CompactMapComparator
All Implemented Interfaces:
Comparator<Object>
Enclosing class:
CompactMap<K,V>

public static class CompactMap.CompactMapComparator extends Object implements Comparator<Object>
Comparator implementation for CompactMap key ordering.

Provides comparison logic that:

  • Handles case sensitivity for String keys
  • Supports natural or reverse ordering
  • Maintains consistent ordering for different key types
  • Properly handles null keys (always last)
Used by sorted CompactMaps and during compact array sorting.
  • Constructor Details

    • CompactMapComparator

      public CompactMapComparator(boolean caseInsensitive, boolean reverse)
  • Method Details

    • get

      public static CompactMap.CompactMapComparator get(boolean caseInsensitive, boolean reverse)
      Returns a cached comparator instance for the specified configuration. Since there are only 4 possible combinations, all instances are pre-created.
      Parameters:
      caseInsensitive - true for case-insensitive String comparison
      reverse - true for reverse ordering
      Returns:
      a cached CompactMapComparator instance
    • compare

      public int compare(Object key1, Object key2)
      Specified by:
      compare in interface Comparator<Object>
    • toString

      public String toString()
      Overrides:
      toString in class Object