Merge branch 'kjvdh/features/PhylogenyViewer_tabbedsupport' into merge/2_11_2/kjvdh...
[jalview.git] / src / jalview / util / MappingUtils.java
index 25cb810..05fc1c6 100644 (file)
@@ -1109,4 +1109,21 @@ public final class MappingUtils
 
     return foundStart && to >= from ? new int[] { from, to } : null;
   }
+    
+  public static <K, V> Map<K, V> putWithDuplicationCheck(Map<K, V> map, K key,
+          V value)
+  {
+    if (!map.containsKey(key))
+    {
+      map.put(key, value);
+    }
+    else
+    {
+      jalview.bin.Cache.log.warn(
+              "Attempt to add duplicate entry detected for map with key: "
+                      + key.toString() + " and value: " + value.toString());
+    }
+  
+    return map;
+  }
 }