JAL-3746 apply copyright to source
[jalview.git] / src / jalview / jbgui / FilterOption.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.jbgui;
22
23 import jalview.gui.structurechooser.StructureChooserQuerySource;
24 import jalview.gui.structurechooser.ThreeDBStructureChooserQuerySource;
25
26 /**
27  * This inner class provides the data model for the structure filter combo-box
28  * 
29  * @author tcnofoegbu
30  *
31  */
32 public class FilterOption
33 {
34   private String name;
35
36   private String value;
37
38   private String view;
39
40   private boolean addSeparatorAfter;
41
42   private StructureChooserQuerySource querySource;
43
44   /**
45    * Model for structure filter option
46    * 
47    * @param name
48    *          - the name of the Option
49    * @param value
50    *          - the value of the option
51    * @param view
52    *          - the category of the filter option
53    * @param addSeparatorAfter
54    *          - if true, a horizontal separator is rendered immediately after
55    *          this filter option, otherwise
56    * @param structureChooserQuerySource
57    *          - the query source that actions this filter
58    */
59   public FilterOption(String name, String value, String view,
60           boolean addSeparatorAfter,
61           StructureChooserQuerySource structureChooserQuerySource)
62   {
63     this.name = name;
64     this.value = value;
65     this.view = view;
66     this.querySource = structureChooserQuerySource;
67     this.addSeparatorAfter = addSeparatorAfter;
68   }
69
70   public String getName()
71   {
72     return name;
73   }
74
75   public void setName(String name)
76   {
77     this.name = name;
78   }
79
80   public String getValue()
81   {
82     return value;
83   }
84
85   public void setValue(String value)
86   {
87     this.value = value;
88   }
89
90   public String getView()
91   {
92     return view;
93   }
94
95   public void setView(String view)
96   {
97     this.view = view;
98   }
99
100   @Override
101   public String toString()
102   {
103     return this.name;
104   }
105
106   public boolean isAddSeparatorAfter()
107   {
108     return addSeparatorAfter;
109   }
110
111   public void setAddSeparatorAfter(boolean addSeparatorAfter)
112   {
113     this.addSeparatorAfter = addSeparatorAfter;
114   }
115
116   public StructureChooserQuerySource getQuerySource()
117   {
118     return querySource;
119   }
120
121   @Override
122   public boolean equals(Object obj)
123   {
124     if (obj instanceof FilterOption)
125     {
126       FilterOption o = (FilterOption) obj;
127       return o.name.equals(name) && o.querySource == querySource
128               && o.value.equals(value) && o.view == view;
129     }
130     else
131     {
132       return super.equals(obj);
133     }
134   }
135
136   @Override
137   public int hashCode()
138   {
139     return ("" + name + ":" + value).hashCode()
140             + (view != null ? view.hashCode() : 0)
141             + (querySource != null ? querySource.hashCode() : 0);
142   }
143 }