1 package jalview.datamodel.features;
3 import java.util.ArrayList;
4 import java.util.Collections;
5 import java.util.HashMap;
9 import java.util.TreeSet;
12 * A singleton class to hold the set of attributes known for each feature type
14 public class FeatureAttributes
16 private static FeatureAttributes instance = new FeatureAttributes();
18 private Map<String, Set<String>> attributes;
21 * Answers the singleton instance of this class
25 public static FeatureAttributes getInstance()
30 private FeatureAttributes()
32 attributes = new HashMap<>();
36 * Answers the attributes known for the given feature type, in alphabetical
37 * order (not case sensitive), or an empty set if no attributes are known
42 public List<String> getAttributes(String featureType)
44 if (!attributes.containsKey(featureType))
46 return Collections.<String> emptyList();
49 return new ArrayList<>(attributes.get(featureType));
53 * Answers true if at least one attribute is known for the given feature type,
59 public boolean hasAttributes(String featureType)
62 if (attributes.containsKey(featureType))
64 if (!attributes.get(featureType).isEmpty())
73 * Records the given attribute name for the given feature type
78 public void addAttribute(String featureType, String attName)
80 if (featureType == null || attName == null)
85 if (!attributes.containsKey(featureType))
87 attributes.put(featureType, new TreeSet<String>(
88 String.CASE_INSENSITIVE_ORDER));
91 attributes.get(featureType).add(attName);