MCPcopy Create free account
hub / github.com/PCGen/pcgen / clone

Method clone

PCGen-base/code/src/java/pcgen/base/util/DoubleKeyMap.java:479–501  ·  view source on GitHub ↗

Produces a clone of the DoubleKeyMap. This means the internal maps used to store keys and values are not shared between the original DoubleKeyMap and the clone (modifying one DoubleKeyMap will not impact the other). However, this does not perform a true "deep" clone, in the sense that the actual key

()

Source from the content-addressed store, hash-verified

477 * (should not be thrown)
478 */
479 @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
480 @Override
481 public DoubleKeyMap<K1, K2, V> clone() throws CloneNotSupportedException
482 {
483 @SuppressWarnings("unchecked")
484 DoubleKeyMap<K1, K2, V> dkm = (DoubleKeyMap<K1, K2, V>) super.clone();
485 dkm.map = createGlobalMap();
486 for (Map.Entry<K1, Map<K2, V>> me : map.entrySet())
487 {
488 /*
489 * Can be empty if a read-only view was previously captured, but we
490 * don't need to keep those around since nothing is attached to the
491 * copy
492 */
493 if (!me.getValue().isEmpty())
494 {
495 dkm.map.put(me.getKey(), new HashMap<>(me.getValue()));
496 }
497 }
498 //Nothing can be connected (see above)
499 dkm.cleanup = true;
500 return dkm;
501 }
502
503 /**
504 * Removes the given value from DoubleKeyMap for the given primary key.

Callers 1

testCloneMethod · 0.95

Calls 6

createGlobalMapMethod · 0.95
isEmptyMethod · 0.65
getValueMethod · 0.65
putMethod · 0.65
getKeyMethod · 0.65
entrySetMethod · 0.45

Tested by 1

testCloneMethod · 0.76