Class TransformedKeyMap<OK,TK,V>

java.lang.Object
com.kingsrook.qqq.backend.core.utils.collections.TransformedKeyMap<OK,TK,V>
All Implemented Interfaces:
Map<OK,V>
Direct Known Subclasses:
CaseInsensitiveKeyMap

public class TransformedKeyMap<OK,TK,V> extends Object implements Map<OK,V>
Version of a map that uses a transformation function on keys. The original idea being, e.g., to support case-insensitive keys via a toLowerCase transform. e.g., map.put("One", 1); map.get("ONE") == 1. But, implemented generically to support any transformation function. keySet() and entries() should give only the first version of a key that overlapped. e.g., map.put("One", 1); map.put("one", 1); map.keySet() == Set.of("One");
  • Constructor Details

    • TransformedKeyMap

      public TransformedKeyMap(Function<OK,TK> keyTransformer)
      Constructor
    • TransformedKeyMap

      public TransformedKeyMap(Function<OK,TK> keyTransformer, Supplier<Map<TK,V>> supplier)
      Constructor
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface Map<OK,TK>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<OK,TK>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<OK,TK>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<OK,TK>
    • get

      public V get(Object key)
      Specified by:
      get in interface Map<OK,TK>
    • put

      @Nullable public V put(OK key, V value)
      Specified by:
      put in interface Map<OK,TK>
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface Map<OK,TK>
    • putAll

      public void putAll(@NotNull @NotNull Map<? extends OK,? extends V> m)
      Specified by:
      putAll in interface Map<OK,TK>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<OK,TK>
    • keySet

      @NotNull public @NotNull Set<OK> keySet()
      Specified by:
      keySet in interface Map<OK,TK>
    • values

      @NotNull public @NotNull Collection<V> values()
      Specified by:
      values in interface Map<OK,TK>
    • entrySet

      @NotNull public @NotNull Set<Map.Entry<OK,V>> entrySet()
      Specified by:
      entrySet in interface Map<OK,TK>