Class CaseInsensitiveMap.CaseInsensitiveEntry

java.lang.Object
java.util.AbstractMap.SimpleEntry<K,V>
com.cedarsoftware.util.CaseInsensitiveMap.CaseInsensitiveEntry
All Implemented Interfaces:
Serializable, Map.Entry<K,V>
Enclosing class:
CaseInsensitiveMap<K,V>

public class CaseInsensitiveMap.CaseInsensitiveEntry extends AbstractMap.SimpleEntry<K,V>
Entry implementation that returns a String key rather than a CaseInsensitiveString when getKey() is called.
See Also:
  • Constructor Details

    • CaseInsensitiveEntry

      public CaseInsensitiveEntry(Map.Entry<K,V> entry)
      Constructs a CaseInsensitiveEntry from the specified entry.
      Parameters:
      entry - the entry to wrap
  • Method Details

    • getKey

      public K getKey()

      Returns the key in its original String form if it was originally stored as a String, otherwise returns the key as is.

      Specified by:
      getKey in interface Map.Entry<K,V>
      Overrides:
      getKey in class AbstractMap.SimpleEntry<K,V>
    • getOriginalKey

      public K getOriginalKey()
      Returns the original key object used internally by the map. This may be a CaseInsensitiveString if the key was originally a String.
      Returns:
      the original key object
    • setValue

      public V setValue(V value)

      Sets the value associated with this entry's key in the underlying map.

      Specified by:
      setValue in interface Map.Entry<K,V>
      Overrides:
      setValue in class AbstractMap.SimpleEntry<K,V>
    • equals

      public boolean equals(Object o)

      For String keys, equality is based on the original String value rather than the case-insensitive representation. This ensures that entries with the same case-insensitive key but different original strings are considered distinct.

      Specified by:
      equals in interface Map.Entry<K,V>
      Overrides:
      equals in class AbstractMap.SimpleEntry<K,V>
      Parameters:
      o - object to be compared for equality with this map entry
      Returns:
      true if the specified object is equal to this map entry
      See Also:
    • hashCode

      public int hashCode()

      For String keys, the hash code is computed using the original String value rather than the case-insensitive representation.

      Specified by:
      hashCode in interface Map.Entry<K,V>
      Overrides:
      hashCode in class AbstractMap.SimpleEntry<K,V>
      Returns:
      the hash code value for this map entry
      See Also:
    • toString

      public String toString()

      Returns a string representation of this map entry. The string representation consists of this entry's key followed by the equals character ("=") followed by this entry's value. For String keys, the original string value is used.

      Overrides:
      toString in class AbstractMap.SimpleEntry<K,V>
      Returns:
      a string representation of this map entry