96efb41634f7b06dab9f1ecc635b25ca8120025c
[jalview.git] / src / jalview / datamodel / features / FeatureSources.java
1 package jalview.datamodel.features;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 public class FeatureSources
7 {
8   private static FeatureSources instance = new FeatureSources();
9
10   private Map<String, FeatureSourceI> sources;
11
12   /**
13    * Answers the singelton instance of this class
14    * 
15    * @return
16    */
17   public static FeatureSources getInstance()
18   {
19     return instance;
20   }
21
22   private FeatureSources()
23   {
24     sources = new HashMap<>();
25   }
26
27   /**
28    * Answers the FeatureSource with the given unique identifier, or null if not
29    * known
30    * 
31    * @param sourceId
32    * @return
33    */
34   public FeatureSourceI getSource(String sourceId)
35   {
36     return sources.get(sourceId);
37   }
38
39   /**
40    * Adds the given source under the given key. This will replace any existing
41    * source with the same id, it is the caller's responsibility to ensure keys
42    * are unique if necessary.
43    * 
44    * @param sourceId
45    * @param source
46    */
47   public void addSource(String sourceId, FeatureSource source)
48   {
49     sources.put(sourceId, source);
50   }
51 }