Class CaseInsensitiveMap.CaseInsensitiveString

java.lang.Object
com.cedarsoftware.util.CaseInsensitiveMap.CaseInsensitiveString
All Implemented Interfaces:
Serializable, CharSequence, Comparable<Object>
Enclosing class:
CaseInsensitiveMap<K,V>

public static final class CaseInsensitiveMap.CaseInsensitiveString extends Object implements Comparable<Object>, CharSequence, Serializable
Wrapper class for String keys to enforce case-insensitive comparison. Implements CharSequence for compatibility with String operations and Serializable for persistence support.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    char
    charAt(int index)
    Returns the character at the specified index.
    Returns a stream of int zero-extending the char values from this sequence.
    Returns a stream of code point values from this sequence.
    int
    Compares this CaseInsensitiveString to another object.
    boolean
    Returns true if this case-insensitive string contains the specified character sequence.
    boolean
    equals(Object other)
    Compares this object to another for equality in a case-insensitive manner.
    int
    Returns the hash code for this object, computed in a case-insensitive manner.
    int
    Returns the length of this character sequence.
    Factory method to get a CaseInsensitiveString, using cached instances when possible.
    subSequence(int start, int end)
    Returns a CharSequence that is a subsequence of this sequence.
    Returns the original String.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • of

      Factory method to get a CaseInsensitiveString, using cached instances when possible. This method guarantees that the same CaseInsensitiveString instance will be returned for equal strings (ignoring case) as long as they're within the maxCacheLengthString limit.
    • toString

      public String toString()
      Returns the original String.
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object
      Returns:
      the original String
    • hashCode

      public int hashCode()
      Returns the hash code for this object, computed in a case-insensitive manner.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • equals

      public boolean equals(Object other)
      Compares this object to another for equality in a case-insensitive manner.
      Overrides:
      equals in class Object
      Parameters:
      other - the object to compare to
      Returns:
      true if they are equal ignoring case, false otherwise
    • compareTo

      public int compareTo(Object o)
      Compares this CaseInsensitiveString to another object. If the object is a String or CaseInsensitiveString, comparison is case-insensitive. Otherwise, Strings are considered "less" than non-Strings.
      Specified by:
      compareTo in interface Comparable<Object>
      Parameters:
      o - the object to compare to
      Returns:
      a negative integer, zero, or a positive integer depending on ordering
    • length

      public int length()
      Returns the length of this character sequence.
      Specified by:
      length in interface CharSequence
      Returns:
      the number of characters in this sequence
    • charAt

      public char charAt(int index)
      Returns the character at the specified index.
      Specified by:
      charAt in interface CharSequence
      Parameters:
      index - the index of the character to be returned
      Returns:
      the specified character
      Throws:
      IndexOutOfBoundsException - if the index is negative or greater than or equal to length()
    • subSequence

      public CharSequence subSequence(int start, int end)
      Returns a CharSequence that is a subsequence of this sequence.
      Specified by:
      subSequence in interface CharSequence
      Parameters:
      start - the start index, inclusive
      end - the end index, exclusive
      Returns:
      the specified subsequence
      Throws:
      IndexOutOfBoundsException - if start or end are negative, if end is greater than length(), or if start is greater than end
    • chars

      public IntStream chars()
      Returns a stream of int zero-extending the char values from this sequence.
      Specified by:
      chars in interface CharSequence
      Returns:
      an IntStream of char values from this sequence
    • codePoints

      public IntStream codePoints()
      Returns a stream of code point values from this sequence.
      Specified by:
      codePoints in interface CharSequence
      Returns:
      an IntStream of Unicode code points from this sequence
    • contains

      public boolean contains(CharSequence s)
      Returns true if this case-insensitive string contains the specified character sequence. The search is case-insensitive.
      Parameters:
      s - the sequence to search for
      Returns:
      true if this string contains s, false otherwise