JAL-4124 MappableContactMatrix equivalence and hashCode ensuring non-redundant set...
[jalview.git] / src / jalview / datamodel / ContactMapHolder.java
index af083dd..3a64917 100644 (file)
@@ -3,6 +3,7 @@ package jalview.datamodel;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 
 import jalview.ws.datamodel.MappableContactMatrixI;
@@ -17,7 +18,8 @@ public class ContactMapHolder implements ContactMapHolderI
   {
     if (contactmaps != null && contactmaps.size() > 0)
     {
-      return contactmaps.values();
+      // defensive copy, and return non redundant set of ContactMatrixI instances
+      return new HashSet<ContactMatrixI>(contactmaps.values());
     }
     return Collections.EMPTY_LIST;
   }