1 package jalview.datamodel.features;
3 import java.util.Collections;
4 import java.util.HashMap;
7 import java.util.TreeSet;
10 * A singleton class to hold the set of attributes known for each feature type
12 public class FeatureAttributes
14 private static FeatureAttributes instance = new FeatureAttributes();
16 private Map<String, Set<String>> attributes;
19 * Answers the singleton instance of this class
23 public static FeatureAttributes getInstance()
28 private FeatureAttributes()
30 attributes = new HashMap<>();
34 * Answers the attributes known for the given feature type, in alphabetical
35 * order (not case sensitive), or an empty set if no attributes are known
40 public Iterable<String> getAttributes(String featureType)
42 if (!attributes.containsKey(featureType))
44 return Collections.emptySet();
47 return attributes.get(featureType);
51 * Records the given attribute name for the given feature type
56 public void addAttribute(String featureType, String attName)
58 if (featureType == null || attName == null)
63 if (!attributes.containsKey(featureType))
65 attributes.put(featureType, new TreeSet<String>(
66 String.CASE_INSENSITIVE_ORDER));
69 attributes.get(featureType).add(attName);