Merge branch 'documentation/JAL-3407_2.11.1_release' into releases/Release_2_11_1_Branch
[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 /**
7  * A singleton to hold metadata about feature attributes, keyed by a unique
8  * feature source identifier
9  * 
10  * @author gmcarstairs
11  *
12  */
13 public class FeatureSources
14 {
15   private static FeatureSources instance = new FeatureSources();
16
17   private Map<String, FeatureSourceI> sources;
18
19   /**
20    * Answers the singleton instance of this class
21    * 
22    * @return
23    */
24   public static FeatureSources getInstance()
25   {
26     return instance;
27   }
28
29   private FeatureSources()
30   {
31     sources = new HashMap<>();
32   }
33
34   /**
35    * Answers the FeatureSource with the given unique identifier, or null if not
36    * known
37    * 
38    * @param sourceId
39    * @return
40    */
41   public FeatureSourceI getSource(String sourceId)
42   {
43     return sources.get(sourceId);
44   }
45
46   /**
47    * Adds the given source under the given key. This will replace any existing
48    * source with the same id, it is the caller's responsibility to ensure keys
49    * are unique if necessary.
50    * 
51    * @param sourceId
52    * @param source
53    */
54   public void addSource(String sourceId, FeatureSource source)
55   {
56     sources.put(sourceId, source);
57   }
58 }