Package org.cip4.jdflib.util
Class ListMap<key,listObject>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<key,List<listObject>>
org.cip4.jdflib.util.ListMap<key,listObject>
- Type Parameters:
key- the type used for the keylistObject- the type used for individual elements of each vector in the map
- All Implemented Interfaces:
Serializable,Cloneable,Map<key,List<listObject>>
- Direct Known Subclasses:
JDFAmountPool.AmountMap
HashMap of multiple elements utility class
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendUnique(key key, List<listObject> vVal) append a map, ensuring uniquenessvoidappendUnique(ListMap<key, listObject> map) append a VectorMap, ensuring uniquenessvoidfillInvertedMap(Map<listObject, key> map) fill this with the values in map by switching key and valueget all values as one big vector, multiple entries are retained (seeContainerUtil.unify())intgetIndex(key key, listObject singleObject) get the index of singleObject in the vector of keyget an inverted map that uses all entries a s keys and vice versa
note that the behavior is undefined in case of multiple identical valuesget the value for keybooleanisUnique()Getter for bUnique attribute.voidputOne(key key, listObject val) put the value for key, ensuring uniquenessvoidremoveOne(key key, listObject val) remove the value for key,also remove key if the vector is emptyvoidsetOne(key key, listObject newObj, int pos) insert the value for keyat position posvoidsetOne(key key, listObject newObj, listObject oldObj) replace the value for key, add if oldObj==null or is not therevoidsetUnique(boolean bUnique) Setter for bUnique attribute.intget the size of the vector for keyMethods 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, valuesMethods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Constructor Details
-
ListMap
public ListMap()null constructor
-
-
Method Details
-
fillInvertedMap
fill this with the values in map by switching key and value- Parameters:
map-
-
getOne
get the value for key- Parameters:
key- the search keyi- 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
get the index of singleObject in the vector of key- Parameters:
key- the key of the vectorsingleObject- the object to search- Returns:
- -2: no such key; -1: no value in key; else the index in the vexctor of key
-
size
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
put the value for key, ensuring uniqueness- Parameters:
key- the key of the vectorval- the vector element
-
appendUnique
append a map, ensuring uniqueness- Parameters:
key- the key of the vectorvVal- the vector of elements
-
appendUnique
append a VectorMap, ensuring uniqueness- Parameters:
map- the map to add
-
getAllValues
get all values as one big vector, multiple entries are retained (seeContainerUtil.unify())- Returns:
- a vector of all values, null if empty
-
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
remove the value for key,also remove key if the vector is empty- Parameters:
key- the key of the vectorval- the vector element
-
setOne
replace the value for key, add if oldObj==null or is not there- Parameters:
key- the key of the vectornewObj- the new object to setoldObj- the old object to replace
-
setOne
insert the value for keyat position pos- Parameters:
key- the key of the vectornewObj- the new object to setpos- the index in the vector, may be <0 to count from the end- Throws:
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
-