Class BlackholeMap<K,​V>

  • Type Parameters:
    K - the type of the keys for the map
    V - the type of the values for the map
    All Implemented Interfaces:

    final class BlackholeMap<K,​V>
    extends java.util.AbstractMap<K,​V>
    An implementation of java.util.Map that ignores any put operation.

    The implementation does not fully conform to java.util.Map API, as any write operation would succeed, but any read operation would not return any value.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  BlackholeMap.BHIterator<E>
      Blackhole implementation of Iterator.
      private static class  BlackholeMap.BHSet<E>
      Blackhole implementation of Set.
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

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

      Modifier and Type Field Description
      private static java.util.Map INSTANCE  
    • Constructor Summary

      Modifier Constructor Description
      private BlackholeMap()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      static <K,​V>
      Gets an instance of BlackholeMap
      V put​(K key, V value)  
      • Methods inherited from class java.util.AbstractMap

        clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
      • Methods inherited from class java.lang.Object

        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
    • Field Detail

      • INSTANCE

        private static final java.util.Map INSTANCE
    • Constructor Detail

      • BlackholeMap

        private BlackholeMap()
    • Method Detail

      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
        put in class java.util.AbstractMap<K,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
        Specified by:
        entrySet in class java.util.AbstractMap<K,​V>
      • of

        public static <K,​V> java.util.Map<K,​V> of()
        Gets an instance of BlackholeMap
        Type Parameters:
        K - type of the keys for the map
        V - type of the values for the map
        a blackhole map