1 package compbio.data.msa;
\r
3 import java.util.HashSet;
\r
4 import java.util.Set;
\r
5 import java.util.TreeSet;
\r
7 import javax.xml.bind.annotation.XmlAccessType;
\r
8 import javax.xml.bind.annotation.XmlAccessorType;
\r
10 import compbio.ws.client.Services;
\r
13 * Class that splits {@link Services} to categories. Services themselves have no
\r
14 * knowledge which category they belongs to.
\r
16 * This class is responsible for initialization of all the categories (done
\r
17 * statically) and holds the category names as constrains.
\r
19 * Two categories considered equals if their names are equals.
\r
22 * @version 1.0 September 2011
\r
24 @XmlAccessorType(XmlAccessType.FIELD)
\r
25 public class Category {
\r
27 * TODO refactor initialization and constrains into separate classes if
\r
28 * further complexity is expected.
\r
32 * All of the Category names
\r
34 public static final String CATEGORY_ALIGNMENT = "Alignment";
\r
35 public static final String CATEGORY_DISORDER = "Protein Disorder";
\r
36 public static final String CATEGORY_CONSERVATION = "Conservation";
\r
39 Set<Services> services;
\r
41 private Category(String name, Set<Services> services) {
\r
43 this.services = services;
\r
46 private Category() {
\r
47 // Default constructor for JAXB
\r
50 public Set<Services> getServices() {
\r
51 return new TreeSet<Services>(services);
\r
54 public static Set<Category> getCategories() {
\r
58 private static Set<Category> init() {
\r
59 Set<Services> align_services = new HashSet<Services>();
\r
60 align_services.add(Services.ClustalOWS);
\r
61 align_services.add(Services.ClustalWS);
\r
62 align_services.add(Services.MafftWS);
\r
63 align_services.add(Services.MuscleWS);
\r
64 align_services.add(Services.ProbconsWS);
\r
65 align_services.add(Services.TcoffeeWS);
\r
66 Category alignment = new Category(CATEGORY_ALIGNMENT, align_services);
\r
68 Set<Services> disorder_services = new HashSet<Services>();
\r
69 disorder_services.add(Services.DisemblWS);
\r
70 disorder_services.add(Services.GlobPlotWS);
\r
71 disorder_services.add(Services.IUPredWS);
\r
72 disorder_services.add(Services.JronnWS);
\r
74 Category disorder = new Category(CATEGORY_DISORDER, disorder_services);
\r
75 Set<Services> conservation_services = new HashSet<Services>();
\r
76 conservation_services.add(Services.AAConWS);
\r
78 Category conservation = new Category(CATEGORY_CONSERVATION,
\r
79 conservation_services);
\r
81 Set<Category> categories = new HashSet<Category>();
\r
82 categories.add(alignment);
\r
83 categories.add(disorder);
\r
84 categories.add(conservation);
\r
90 public int hashCode() {
\r
91 final int prime = 31;
\r
93 result = prime * result + ((name == null) ? 0 : name.hashCode());
\r
98 public boolean equals(Object obj) {
\r
103 if (getClass() != obj.getClass())
\r
105 Category other = (Category) obj;
\r
106 if (name == null) {
\r
107 if (other.name != null)
\r
109 } else if (!name.equals(other.name))
\r