Class | Line # | Actions | ||||
---|---|---|---|---|---|---|
FeatureSources | 13 | 4 | 4 | 0 |
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 | 141 | public static FeatureSources getInstance() |
25 | { | |
26 | 141 | return instance; |
27 | } | |
28 | ||
29 | 1 | private FeatureSources() |
30 | { | |
31 | 1 | 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 | 137 | public FeatureSourceI getSource(String sourceId) |
42 | { | |
43 | 137 | 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 | 4 | public void addSource(String sourceId, FeatureSource source) |
55 | { | |
56 | 4 | sources.put(sourceId, source); |
57 | } | |
58 | } |