Class ExtMap

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.concurrent.ConcurrentMap<ExtKey,​java.lang.Object>, java.util.Map<ExtKey,​java.lang.Object>

    public class ExtMap
    extends java.lang.Object
    implements java.util.concurrent.ConcurrentMap<ExtKey,​java.lang.Object>, java.lang.Cloneable, java.io.Serializable
    Type safe map. Keys are bundle of uuid and type, each value added is checked against key type.
    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>
    • Constructor Summary

      Constructors 
      Constructor Description
      ExtMap()
      Constructs an empty ExtMap with the default initial capacity (16) and the default load factor (0.75).
      ExtMap​(int initialCapacity)
      Constructs an empty ExtMap with the specified initial capacity and the default load factor (0.75).
      ExtMap​(int initialCapacity, float loadFactor)
      Constructs an empty ExtMap with the specified initial capacity and load factor.
      ExtMap​(java.util.Map<ExtKey,​java.lang.Object> m)
      Constructs a new ExtMap with the same mappings as the specified Map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      ExtMap clone()
      boolean containsKey​(java.lang.Object key)
      boolean containsValue​(java.lang.Object value)
      java.util.Set<java.util.Map.Entry<ExtKey,​java.lang.Object>> entrySet()
      boolean equals​(java.lang.Object obj)
      java.lang.Object get​(java.lang.Object key)
      <T> T get​(ExtKey key)
      Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
      <T> T get​(ExtKey key, java.lang.Class<T> type)
      Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
      <T> T get​(ExtKey key, java.lang.Class<T> type, T defaultValue)
      Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
      <T> T get​(ExtKey key, java.lang.Object defaultValue)
      Returns the value to which the specified key is mapped, or default.
      int hashCode()
      boolean isEmpty()
      java.util.Set<ExtKey> keySet()
      ExtMap mput​(java.util.Map<? extends ExtKey,​? extends java.lang.Object> m)
      Multiple putAll.
      ExtMap mput​(ExtKey key, java.lang.Object value)
      Multiple put.
      java.lang.Object put​(ExtKey key, java.lang.Object value)
      void putAll​(java.util.Map<? extends ExtKey,​? extends java.lang.Object> m)
      java.lang.Object putIfAbsent​(ExtKey key, java.lang.Object value)
      java.lang.Object remove​(java.lang.Object key)
      boolean remove​(java.lang.Object key, java.lang.Object value)
      java.lang.Object replace​(ExtKey key, java.lang.Object value)
      boolean replace​(ExtKey key, java.lang.Object oldValue, java.lang.Object newValue)
      int size()
      java.lang.String toString()
      java.util.Collection<java.lang.Object> values()
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.ConcurrentMap

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
    • Constructor Detail

      • ExtMap

        public ExtMap​(int initialCapacity,
                      float loadFactor)
        Constructs an empty ExtMap with the specified initial capacity and load factor.
        Parameters:
        initialCapacity - the initial capacity.
        loadFactor - the load factor.
        Throws:
        java.lang.IllegalArgumentException - if the initial capacity is negative or the load factor is nonpositive.
      • ExtMap

        public ExtMap​(int initialCapacity)
        Constructs an empty ExtMap with the specified initial capacity and the default load factor (0.75).
        Parameters:
        initialCapacity - the initial capacity.
        Throws:
        java.lang.IllegalArgumentException - if the initial capacity is negative or the load factor is nonpositive.
      • ExtMap

        public ExtMap()
        Constructs an empty ExtMap with the default initial capacity (16) and the default load factor (0.75).
      • ExtMap

        public ExtMap​(java.util.Map<ExtKey,​java.lang.Object> m)
        Constructs a new ExtMap with the same mappings as the specified Map. The ExtMap is created with default load factor (0.75) and an initial capacity sufficient to hold the mappings in the specified Map.
        Parameters:
        m - the map whose mappings are to be placed in this map.
        Throws:
        java.lang.NullPointerException - if the specified map is null.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Map<ExtKey,​java.lang.Object>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map<ExtKey,​java.lang.Object>
        Overrides:
        hashCode in class java.lang.Object
      • clone

        public ExtMap clone()
        Overrides:
        clone in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<ExtKey,​java.lang.Object>
      • containsKey

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

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

        public java.util.Set<java.util.Map.Entry<ExtKey,​java.lang.Object>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<ExtKey,​java.lang.Object>
      • get

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

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<ExtKey,​java.lang.Object>
      • keySet

        public java.util.Set<ExtKey> keySet()
        Specified by:
        keySet in interface java.util.Map<ExtKey,​java.lang.Object>
      • put

        public java.lang.Object put​(ExtKey key,
                                    java.lang.Object value)
        Specified by:
        put in interface java.util.Map<ExtKey,​java.lang.Object>
      • putAll

        public void putAll​(java.util.Map<? extends ExtKey,​? extends java.lang.Object> m)
        Specified by:
        putAll in interface java.util.Map<ExtKey,​java.lang.Object>
      • remove

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

        public int size()
        Specified by:
        size in interface java.util.Map<ExtKey,​java.lang.Object>
      • values

        public java.util.Collection<java.lang.Object> values()
        Specified by:
        values in interface java.util.Map<ExtKey,​java.lang.Object>
      • putIfAbsent

        public java.lang.Object putIfAbsent​(ExtKey key,
                                            java.lang.Object value)
        Specified by:
        putIfAbsent in interface java.util.concurrent.ConcurrentMap<ExtKey,​java.lang.Object>
        Specified by:
        putIfAbsent in interface java.util.Map<ExtKey,​java.lang.Object>
      • remove

        public boolean remove​(java.lang.Object key,
                              java.lang.Object value)
        Specified by:
        remove in interface java.util.concurrent.ConcurrentMap<ExtKey,​java.lang.Object>
        Specified by:
        remove in interface java.util.Map<ExtKey,​java.lang.Object>
      • replace

        public java.lang.Object replace​(ExtKey key,
                                        java.lang.Object value)
        Specified by:
        replace in interface java.util.concurrent.ConcurrentMap<ExtKey,​java.lang.Object>
        Specified by:
        replace in interface java.util.Map<ExtKey,​java.lang.Object>
      • replace

        public boolean replace​(ExtKey key,
                               java.lang.Object oldValue,
                               java.lang.Object newValue)
        Specified by:
        replace in interface java.util.concurrent.ConcurrentMap<ExtKey,​java.lang.Object>
        Specified by:
        replace in interface java.util.Map<ExtKey,​java.lang.Object>
      • mput

        public ExtMap mput​(ExtKey key,
                           java.lang.Object value)
        Multiple put. Usable for adding multiple entries:
        
         ExtMap = new ExtMap().mput(key1, value1).mput(key2, value2);
         
        Parameters:
        key - key with which the specified value is to be associated.
        value - value to be associated with the specified key.
        Returns:
        this.
      • mput

        public ExtMap mput​(java.util.Map<? extends ExtKey,​? extends java.lang.Object> m)
        Multiple putAll. Usable for adding multiple entries:
        
         ExtMap = new ExtMap().mputAll(map1).mputAll(map2);
         
        Parameters:
        m - map to add.
        Returns:
        this.
      • get

        public <T> T get​(ExtKey key,
                         java.lang.Class<T> type,
                         T defaultValue)
        Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. Safe version of get().
        
         Integer i = <Integer> map.get(key1, Integer);
         
        Type Parameters:
        T - type of return and default value, inferred
        Parameters:
        key - key with which the specified value is to be associated.
        type - expected type.
        defaultValue - default value to return.
        Returns:
        Value.
      • get

        public <T> T get​(ExtKey key,
                         java.lang.Class<T> type)
        Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. Safe version of get().
        Type Parameters:
        T - type of return value, inferred
        Parameters:
        key - key with which the specified value is to be associated.
        type - expected type.
        Returns:
        Value.
        See Also:
        get(ExtKey key, Class type, Object defaultValue)
      • get

        public <T> T get​(ExtKey key)
        Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. Unsafe method of get with cast.
        
         Integer i = <Integer> map.get(key1);
         
        Type Parameters:
        T - type of return value
        Parameters:
        key - key.
        Returns:
        Value.
      • get

        public <T> T get​(ExtKey key,
                         java.lang.Object defaultValue)
        Returns the value to which the specified key is mapped, or default. Unsafe method of get with cast.
        
         Integer i = <Integer> map.get(key1, 5);
         
        Type Parameters:
        T - type of return and default value, inferred
        Parameters:
        key - key.
        defaultValue - default value.
        Returns:
        Value.