Class CharSequenceMap<V>

  • Type Parameters:
    V - the type of values
    All Implemented Interfaces:, java.util.Map<java.lang.CharSequence,​V>

    public class CharSequenceMap<V>
    extends java.lang.Object
    implements java.util.Map<java.lang.CharSequence,​V>,
    A map that uses char sequences as keys.

    This implementation wraps provided keys into CharSequenceWrapper for consistent hashing and equals behavior. This ensures that objects of different types that represent the same sequence of characters are treated as equal keys in the map.

    Note: This map is not designed for concurrent modification by multiple threads. However, it supports safe concurrent reads, assuming there are no concurrent writes.

    Note: This map does not support null keys.

    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      V computeIfAbsent​(java.lang.CharSequence key, java.util.function.Supplier<V> valueSupplier)  
      boolean containsKey​(java.lang.Object key)  
      boolean containsValue​(java.lang.Object value)  
      static <T> CharSequenceMap<T> create()  
      java.util.Set<java.util.Map.Entry<java.lang.CharSequence,​V>> entrySet()  
      boolean equals​(java.lang.Object other)  
      V get​(java.lang.Object key)  
      int hashCode()  
      boolean isEmpty()  
      java.util.Set<java.lang.CharSequence> keySet()  
      V put​(java.lang.CharSequence key, V value)  
      void putAll​(java.util.Map<? extends java.lang.CharSequence,​? extends V> otherMap)  
      V remove​(java.lang.Object key)  
      int size()  
      java.lang.String toString()  
      java.util.Collection<V> values()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Method Detail

      • size

        public int size()
        Specified by:
        size in interface java.util.Map<java.lang.CharSequence,​V>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<java.lang.CharSequence,​V>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<java.lang.CharSequence,​V>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<java.lang.CharSequence,​V>
      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<java.lang.CharSequence,​V>
      • put

        public V put​(java.lang.CharSequence key,
                     V value)
        Specified by:
        put in interface java.util.Map<java.lang.CharSequence,​V>
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<java.lang.CharSequence,​V>
      • putAll

        public void putAll​(java.util.Map<? extends java.lang.CharSequence,​? extends V> otherMap)
        Specified by:
        putAll in interface java.util.Map<java.lang.CharSequence,​V>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<java.lang.CharSequence,​V>
      • keySet

        public java.util.Set<java.lang.CharSequence> keySet()
        Specified by:
        keySet in interface java.util.Map<java.lang.CharSequence,​V>
      • values

        public java.util.Collection<V> values()
        Specified by:
        values in interface java.util.Map<java.lang.CharSequence,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<java.lang.CharSequence,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<java.lang.CharSequence,​V>
      • computeIfAbsent

        public V computeIfAbsent​(java.lang.CharSequence key,
                                 java.util.function.Supplier<V> valueSupplier)
      • equals

        public boolean equals​(java.lang.Object other)
        Specified by:
        equals in interface java.util.Map<java.lang.CharSequence,​V>
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map<java.lang.CharSequence,​V>
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object