f7317270d4ebb92bc6801ccfc79592ca830a104d
[jalview.git] / src / jalview / jbgui / FilterOption.java
1 package jalview.jbgui;
2
3 import jalview.gui.structurechooser.StructureChooserQuerySource;
4 import jalview.gui.structurechooser.ThreeDBStructureChooserQuerySource;
5
6 /**
7  * This inner class provides the data model for the structure filter combo-box
8  * 
9  * @author tcnofoegbu
10  *
11  */
12 public class FilterOption
13 {
14   private String name;
15
16   private String value;
17
18   private String view;
19
20   private boolean addSeparatorAfter;
21
22   private StructureChooserQuerySource querySource;
23
24   /**
25    * Model for structure filter option
26    * 
27    * @param name
28    *          - the name of the Option
29    * @param value
30    *          - the value of the option
31    * @param view
32    *          - the category of the filter option
33    * @param addSeparatorAfter
34    *          - if true, a horizontal separator is rendered immediately after
35    *          this filter option, otherwise
36    * @param structureChooserQuerySource
37    *          - the query source that actions this filter
38    */
39   public FilterOption(String name, String value, String view,
40           boolean addSeparatorAfter,
41           StructureChooserQuerySource structureChooserQuerySource)
42   {
43     this.name = name;
44     this.value = value;
45     this.view = view;
46     this.querySource = structureChooserQuerySource;
47     this.addSeparatorAfter = addSeparatorAfter;
48   }
49
50   public String getName()
51   {
52     return name;
53   }
54
55   public void setName(String name)
56   {
57     this.name = name;
58   }
59
60   public String getValue()
61   {
62     return value;
63   }
64
65   public void setValue(String value)
66   {
67     this.value = value;
68   }
69
70   public String getView()
71   {
72     return view;
73   }
74
75   public void setView(String view)
76   {
77     this.view = view;
78   }
79
80   @Override
81   public String toString()
82   {
83     return this.name;
84   }
85
86   public boolean isAddSeparatorAfter()
87   {
88     return addSeparatorAfter;
89   }
90
91   public void setAddSeparatorAfter(boolean addSeparatorAfter)
92   {
93     this.addSeparatorAfter = addSeparatorAfter;
94   }
95
96   public StructureChooserQuerySource getQuerySource()
97   {
98     return querySource;
99   }
100
101   @Override
102   public boolean equals(Object obj)
103   {
104     if (obj instanceof FilterOption)
105     {
106       FilterOption o = (FilterOption) obj;
107       return o.name.equals(name) && o.querySource == querySource
108               && o.value.equals(value) && o.view == view;
109     }
110     else
111     {
112       return super.equals(obj);
113     }
114   }
115
116   @Override
117   public int hashCode()
118   {
119     return ("" + name + ":" + value).hashCode()
120             + (view != null ? view.hashCode() : 0)
121             + (querySource != null ? querySource.hashCode() : 0);
122   }
123 }