Package net.datafaker.internal.helper
Class CopyOnWriteMap<K,V>
java.lang.Object
net.datafaker.internal.helper.CopyOnWriteMap<K,V>
- All Implemented Interfaces:
Map<K,
V>
This is a Copy On Write map. The main idea behind this is that
there is lots of static info per provider to make the providers operate.
At the same time there is no need to load all the info at the start since
we don't know which providers will be used and loading for all takes time.
For that reason it is loaded on request and stored in these Copy On Write maps.
Since it is loaded only once per provider and after that is only read then
it should be ok and moreover it will allow to have non-blocking reads.
In case for whatever reason there is a need to change this class,
please double-check jmh report before and after e.g.
mvn clean package exec:exec -Dbenchmarks="DatafakerSimpleMethods" -Ddatafaker.version=2.2.3-SNAPSHOT
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
getOrDefault
(Object key, V defaultValue) boolean
isEmpty()
keySet()
void
putIfAbsent
(K key, V value) int
size()
toString()
values()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, hashCode, merge, remove, replace, replace, replaceAll
-
Constructor Details
-
CopyOnWriteMap
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
get
-
putIfAbsent
- Specified by:
putIfAbsent
in interfaceMap<K,
V>
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
toString
-
getOrDefault
- Specified by:
getOrDefault
in interfaceMap<K,
V>
-