Package org.forgerock.util
Class LazyMap<K,V>
java.lang.Object
org.forgerock.util.LazyMap<K,V>
- Type Parameters:
K- The type of key.V- The type of value.
- All Implemented Interfaces:
Map<K,V>
A map with lazy initialization. The factory is called to initialize the map
on the first call to one of this object's methods.
-
Nested Class Summary
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all of the mappings from the map.booleancontainsKey(Object key) Returnstrueif this map contains a mapping for the specified key.booleancontainsValue(Object value) Returnstrueif the map maps one or more keys to the specified value.entrySet()Returns aSetview of the mappings contained in the map.booleanCompares the specified object with the map for equality.Returns the value to which the specified key is mapped, ornullif the map contains no mapping for the key.inthashCode()Returns the hash code value for the map.booleanisEmpty()Returnstrueif the map contains no key-value mappings.keySet()Returns aSetview of the keys contained in the map.Associates the specified value with the specified key in the map.voidCopies all of the mappings from the specified map to the map.Removes the mapping for a key from the map if it is present.intsize()Returns the number of key-value mappings in this map.values()Returns aCollectionview of the values contained in the map.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
factory
Factory to create the instance of the map to expose.
-
-
Constructor Details
-
LazyMap
protected LazyMap()Constructs a new lazy map. Allows factory to be set in subclass constructor. -
LazyMap
Constructs a new lazy map.- Parameters:
factory- factory to create the map instance to expose.
-
-
Method Details
-
size
public int size()Returns the number of key-value mappings in this map. -
isEmpty
public boolean isEmpty()Returnstrueif the map contains no key-value mappings. -
containsKey
Returnstrueif this map contains a mapping for the specified key.- Specified by:
containsKeyin interfaceMap<K,V> - Parameters:
key- the key whose presence in this map is to be tested.- Returns:
trueif this map contains a mapping for the specified key.
-
containsValue
Returnstrueif the map maps one or more keys to the specified value.- Specified by:
containsValuein interfaceMap<K,V> - Parameters:
value- the value whose presence in the map is to be tested.- Returns:
trueif the map maps one or more keys to the specified value.
-
get
Returns the value to which the specified key is mapped, ornullif the map contains no mapping for the key. -
put
Associates the specified value with the specified key in the map. -
remove
Removes the mapping for a key from the map if it is present. -
putAll
Copies all of the mappings from the specified map to the map. -
clear
public void clear()Removes all of the mappings from the map. -
keySet
Returns aSetview of the keys contained in the map. -
values
Returns aCollectionview of the values contained in the map. -
entrySet
Returns aSetview of the mappings contained in the map. -
hashCode
public int hashCode()Returns the hash code value for the map. -
equals
Compares the specified object with the map for equality.
-