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
()
| 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. |