From: kjvdheide Date: Tue, 14 Nov 2017 16:57:36 +0000 (+0000) Subject: JAL-2805 added static method for logging duplications when using map.put X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a955f43a1e654c70e8b91f73279e6dc5f5e2a5e6;p=jalview.git JAL-2805 added static method for logging duplications when using map.put --- diff --git a/src/jalview/ext/archaeopteryx/AptxNodeAssociation.java b/src/jalview/ext/archaeopteryx/AptxNodeAssociation.java index 5d126f3..d5262c5 100644 --- a/src/jalview/ext/archaeopteryx/AptxNodeAssociation.java +++ b/src/jalview/ext/archaeopteryx/AptxNodeAssociation.java @@ -50,8 +50,6 @@ public class AptxNodeAssociation { SequenceIdMatcher algnIds = new SequenceIdMatcher(alignSequences); - - List leaves = tree.getExternalNodes(); SequenceI nodeSequence; String nodeSequenceName; @@ -67,8 +65,12 @@ public class AptxNodeAssociation .createForesterSequence(nodeSequence, true); treeNode.getNodeData().setSequence(foresterNodeSeq); - alignmentWithNodes.put(nodeSequence, treeNode); - nodesWithAlignment.put(treeNode, nodeSequence); + ExternalTreeBuilderI.putWithDuplicationCheck(alignmentWithNodes, + nodeSequence, treeNode); + ExternalTreeBuilderI.putWithDuplicationCheck(nodesWithAlignment, + treeNode, nodeSequence); + + } } diff --git a/src/jalview/ext/archaeopteryx/ExternalTreeBuilderI.java b/src/jalview/ext/archaeopteryx/ExternalTreeBuilderI.java index 17ae7f8..d30be0e 100644 --- a/src/jalview/ext/archaeopteryx/ExternalTreeBuilderI.java +++ b/src/jalview/ext/archaeopteryx/ExternalTreeBuilderI.java @@ -28,4 +28,30 @@ interface ExternalTreeBuilderI public String generateTreeName(); + /** + * probably move + * + * @param map + * @param key + * @param value + * @return + */ + static Map putWithDuplicationCheck(Map 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; + + } + }