2 * Class that splits {@link Services} to categories. Services themselves have no
\r
3 * knowledge which category they belongs to.
\r
5 * This class is responsible for initialization of all the categories (done
\r
6 * statically) and holds the category names as constrains.
\r
8 * Two categories considered equals if their names are equals.
\r
11 * @version 1.0 September 2011
\r
14 package compbio.data.msa;
\r
16 import java.util.HashSet;
\r
17 import java.util.Set;
\r
18 import java.util.TreeSet;
\r
20 import javax.xml.bind.annotation.XmlAccessType;
\r
21 import javax.xml.bind.annotation.XmlAccessorType;
\r
23 import compbio.ws.client.Services;
\r
25 @XmlAccessorType(XmlAccessType.FIELD)
\r
26 public class Category {
\r
28 * TODO refactor initialization and constrains into separate classes if
\r
29 * further complexity is expected.
\r
33 * All of the Category names
\r
35 public static final String CATEGORY_ALIGNMENT = "Alignment";
\r
36 public static final String CATEGORY_DISORDER = "Protein Disorder";
\r
37 public static final String CATEGORY_CONSERVATION = "Conservation";
\r
38 public static final String CATEGORY_PREDICTION = "Prediction";
\r
41 Set<Services> services;
\r
43 private Category(String name, Set<Services> services) {
\r
45 this.services = services;
\r
48 private Category() {
\r
49 // Default constructor for JAXB
\r
52 public Set<Services> getServices() {
\r
53 return new TreeSet<Services>(services);
\r
56 public static Set<Category> getCategories() {
\r
60 private static Set<Category> init() {
\r
61 Set<Services> align_services = new HashSet<Services>();
\r
62 align_services.add(Services.ClustalOWS);
\r
63 align_services.add(Services.ClustalWS);
\r
64 align_services.add(Services.MafftWS);
\r
65 align_services.add(Services.MuscleWS);
\r
66 align_services.add(Services.ProbconsWS);
\r
67 align_services.add(Services.TcoffeeWS);
\r
68 Category alignment = new Category(CATEGORY_ALIGNMENT, align_services);
\r
70 Set<Services> disorder_services = new HashSet<Services>();
\r
71 disorder_services.add(Services.DisemblWS);
\r
72 disorder_services.add(Services.GlobPlotWS);
\r
73 disorder_services.add(Services.IUPredWS);
\r
74 disorder_services.add(Services.JronnWS);
\r
75 Category disorder = new Category(CATEGORY_DISORDER, disorder_services);
\r
77 Set<Services> conservation_services = new HashSet<Services>();
\r
78 conservation_services.add(Services.AAConWS);
\r
79 Category conservation = new Category(CATEGORY_CONSERVATION, conservation_services);
\r
81 Set<Services> prediction_services = new HashSet<Services>();
\r
82 prediction_services.add(Services.JpredWS);
\r
83 Category prediction = new Category(CATEGORY_PREDICTION, prediction_services);
\r
85 Set<Category> categories = new HashSet<Category>();
\r
86 categories.add(alignment);
\r
87 categories.add(disorder);
\r
88 categories.add(conservation);
\r
89 categories.add(prediction);
\r
95 public int hashCode() {
\r
96 final int prime = 31;
\r
98 result = prime * result + ((name == null) ? 0 : name.hashCode());
\r
103 public boolean equals(Object obj) {
\r
108 if (getClass() != obj.getClass())
\r
110 Category other = (Category) obj;
\r
111 if (name == null) {
\r
112 if (other.name != null)
\r
114 } else if (!name.equals(other.name))
\r