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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all of the mappings from the map.boolean
containsKey
(Object key) Returnstrue
if this map contains a mapping for the specified key.boolean
containsValue
(Object value) Returnstrue
if the map maps one or more keys to the specified value.entrySet()
Returns aSet
view of the mappings contained in the map.boolean
Compares the specified object with the map for equality.Returns the value to which the specified key is mapped, ornull
if the map contains no mapping for the key.int
hashCode()
Returns the hash code value for the map.boolean
isEmpty()
Returnstrue
if the map contains no key-value mappings.keySet()
Returns aSet
view of the keys contained in the map.Associates the specified value with the specified key in the map.void
Copies all of the mappings from the specified map to the map.Removes the mapping for a key from the map if it is present.int
size()
Returns the number of key-value mappings in this map.values()
Returns aCollection
view of the values contained in the map.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods 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()Returnstrue
if the map contains no key-value mappings. -
containsKey
Returnstrue
if this map contains a mapping for the specified key.- Specified by:
containsKey
in interfaceMap<K,
V> - Parameters:
key
- the key whose presence in this map is to be tested.- Returns:
true
if this map contains a mapping for the specified key.
-
containsValue
Returnstrue
if the map maps one or more keys to the specified value.- Specified by:
containsValue
in interfaceMap<K,
V> - Parameters:
value
- the value whose presence in the map is to be tested.- Returns:
true
if the map maps one or more keys to the specified value.
-
get
Returns the value to which the specified key is mapped, ornull
if 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 aSet
view of the keys contained in the map. -
values
Returns aCollection
view of the values contained in the map. -
entrySet
Returns aSet
view 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.
-