27659d7182e76a157fadc6993749b9589bb1f899
[jalview.git] / src / jalview / ext / treeviewer / ExternalTreeBuilderI.java
1 package jalview.ext.treeviewer;
2
3 import jalview.datamodel.SequenceI;
4
5 import java.util.Map;
6
7 /**
8  * Note that this will take anything as a Tree or TreeNode object as no
9  * assumptions can be made about the inheritance structure of Tree or TreeNode
10  * (besides being Objects).
11  * 
12  * @author kjvanderheide
13  *
14  * @param <T>
15  *          Tree object that the tree viewer requires.
16  * @param <N>
17  *          Tree node object that the tree viewer requires.
18  */
19 public interface ExternalTreeBuilderI<T, N>
20 {
21   public T buildTree(N treeRoot);
22
23   public T buildTree();
24
25   public Map<SequenceI, N> getAlignmentBoundNodes();
26
27   public Map<N, SequenceI> getNodesBoundAlignment();
28
29   public String generateTreeName();
30
31   /**
32    * probably move
33    * 
34    * @param map
35    * @param key
36    * @param value
37    * @return
38    */
39   static <K, V> Map<K, V> putWithDuplicationCheck(Map<K, V> map, K key,
40           V value)
41   {
42     if (!map.containsKey(key))
43     {
44       map.put(key, value);
45     }
46     else
47     {
48       jalview.bin.Cache.log.warn(
49               "Attempt to add duplicate entry detected for map with key: "
50                       + key.toString() + " and value: " + value.toString());
51     }
52
53     return map;
54     
55   }
56
57 }