Class ListMap<key,​listObject>

  • Type Parameters:
    key - the type used for the key
    listObject - the type used for individual elements of each vector in the map
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<key,​java.util.List<listObject>>
    Direct Known Subclasses:
    JDFAmountPool.AmountMap

    public class ListMap<key,​listObject>
    extends java.util.HashMap<key,​java.util.List<listObject>>
    HashMap of multiple elements utility class
    See Also:
    Serialized Form
    • Nested Class Summary

      • 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>
    • Constructor Summary

      Constructors 
      Constructor Description
      ListMap()
      null constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appendUnique​(key key, java.util.List<listObject> vVal)
      append a map, ensuring uniqueness
      void appendUnique​(ListMap<key,​listObject> map)
      append a VectorMap, ensuring uniqueness
      void fillInvertedMap​(java.util.Map<listObject,​key> map)
      fill this with the values in map by switching key and value
      java.util.List<listObject> getAllValues()
      get all values as one big vector, multiple entries are retained (see ContainerUtil.unify())
      int getIndex​(key key, listObject singleObject)
      get the index of singleObject in the vector of key
      java.util.Map<listObject,​key> getInvertedMap()
      get an inverted map that uses all entries a s keys and vice versa
      note that the behavior is undefined in case of multiple identical values
      listObject getOne​(java.lang.Object key, int i)
      get the value for key
      boolean isUnique()
      Getter for bUnique attribute.
      void putOne​(key key, listObject val)
      put the value for key, ensuring uniqueness
      void removeOne​(key key, listObject val)
      remove the value for key,also remove key if the vector is empty
      void setOne​(key key, listObject newObj, int pos)
      insert the value for keyat position pos
      void setOne​(key key, listObject newObj, listObject oldObj)
      replace the value for key, add if oldObj==null or is not there
      void setUnique​(boolean bUnique)
      Setter for bUnique attribute.
      int size​(key key)
      get the size of the vector for key
      • Methods inherited from class java.util.HashMap

        clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

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

        equals, hashCode
    • Constructor Detail

      • ListMap

        public ListMap()
        null constructor
    • Method Detail

      • fillInvertedMap

        public void fillInvertedMap​(java.util.Map<listObject,​key> map)
        fill this with the values in map by switching key and value
        Parameters:
        map -
      • getOne

        public listObject getOne​(java.lang.Object key,
                                 int i)
        get the value for key
        Parameters:
        key - the search key
        i - the index in the vecor matching key; if <0 count from the back of the vector
        Returns:
        the matching vectorObject; null if the key does not exist or i is out of range
      • getIndex

        public int getIndex​(key key,
                            listObject singleObject)
        get the index of singleObject in the vector of key
        Parameters:
        key - the key of the vector
        singleObject - the object to search
        Returns:
        -2: no such key; -1: no value in key; else the index in the vexctor of key
      • size

        public int size​(key key)
        get the size of the vector for key
        Parameters:
        key - the key of the vector
        Returns:
        the size of the vector for key, 0 if no key exists
      • putOne

        public void putOne​(key key,
                           listObject val)
        put the value for key, ensuring uniqueness
        Parameters:
        key - the key of the vector
        val - the vector element
      • appendUnique

        public void appendUnique​(key key,
                                 java.util.List<listObject> vVal)
        append a map, ensuring uniqueness
        Parameters:
        key - the key of the vector
        vVal - the vector of elements
      • appendUnique

        public void appendUnique​(ListMap<key,​listObject> map)
        append a VectorMap, ensuring uniqueness
        Parameters:
        map - the map to add
      • getAllValues

        public java.util.List<listObject> getAllValues()
        get all values as one big vector, multiple entries are retained (see ContainerUtil.unify())
        Returns:
        a vector of all values, null if empty
      • getInvertedMap

        public java.util.Map<listObject,​key> getInvertedMap()
        get an inverted map that uses all entries a s keys and vice versa
        note that the behavior is undefined in case of multiple identical values
        Returns:
        an inverted map
      • removeOne

        public void removeOne​(key key,
                              listObject val)
        remove the value for key,also remove key if the vector is empty
        Parameters:
        key - the key of the vector
        val - the vector element
      • setOne

        public void setOne​(key key,
                           listObject newObj,
                           listObject oldObj)
        replace the value for key, add if oldObj==null or is not there
        Parameters:
        key - the key of the vector
        newObj - the new object to set
        oldObj - the old object to replace
      • setOne

        public void setOne​(key key,
                           listObject newObj,
                           int pos)
        insert the value for keyat position pos
        Parameters:
        key - the key of the vector
        newObj - the new object to set
        pos - the index in the vector, may be <0 to count from the end
        Throws:
        java.lang.IllegalArgumentException - if pos is negative and abs(pos)>size()
      • isUnique

        public boolean isUnique()
        Getter for bUnique attribute.
        Returns:
        the bUnique
      • setUnique

        public void setUnique​(boolean bUnique)
        Setter for bUnique attribute.
        Parameters:
        bUnique - the bUnique to set