Class CaseInsensitiveComparator

  • All Implemented Interfaces:
    java.util.Comparator

    class CaseInsensitiveComparator
    extends java.lang.Object
    implements java.util.Comparator
    Comparator that compares all strings differently, but if two strings are equal in case-insensitive match they are right next to each other.

    Note: strings that differ only in upper-lower case are treated by this comparator as distinct.

    In a collection sorted on this comparator, we can find case-insensitive matches for a given string using floorKey(java.lang.String) and ceilingKey(java.lang.String).

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  CaseInsensitiveComparator.Key
      Enables to create floor and ceiling keys for given string.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) java.lang.Object ceilingKey​(java.lang.String key)  
      int compare​(java.lang.Object o1, java.lang.Object o2)  
      (package private) java.lang.Object floorKey​(java.lang.String key)  
      • 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

      • CaseInsensitiveComparator

        CaseInsensitiveComparator()
    • Method Detail

      • floorKey

        java.lang.Object floorKey​(java.lang.String key)
      • ceilingKey

        java.lang.Object ceilingKey​(java.lang.String key)
      • compare

        public int compare​(java.lang.Object o1,
                           java.lang.Object o2)
        Specified by:
        compare in interface java.util.Comparator