]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/symbollibrary/ui/GroupFilter.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / symbollibrary / ui / GroupFilter.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.diagram.symbollibrary.ui;\r
13 \r
14 /**\r
15  * @author Tuukka Lehtonen\r
16  */\r
17 class GroupFilter implements Comparable<GroupFilter> {\r
18     private String name;\r
19     private String filterText;\r
20     private boolean active;\r
21 \r
22     public GroupFilter(String name, String filterText, boolean active) {\r
23         assert name != null;\r
24         assert filterText != null;\r
25         this.name = name;\r
26         this.filterText = filterText;\r
27         this.active = active;\r
28     }\r
29 \r
30     public String getName() {\r
31         return name;\r
32     }\r
33 \r
34     public void setName(String name) {\r
35         this.name = name;\r
36     }\r
37 \r
38     public String getFilterText() {\r
39         return filterText;\r
40     }\r
41 \r
42     public void setFilterText(String filterText) {\r
43         this.filterText = filterText;\r
44     }\r
45 \r
46     public boolean isActive() {\r
47         return active;\r
48     }\r
49 \r
50     public void setActive(boolean active) {\r
51         this.active = active;\r
52     }\r
53 \r
54     @Override\r
55     public String toString() {\r
56         return getClass().getSimpleName() + "[" + name + ", filter=" + filterText + ", active=" + active + "]";\r
57     }\r
58 \r
59     @Override\r
60     public int hashCode() {\r
61         final int prime = 31;\r
62         int result = 1;\r
63         result = prime * result + filterText.hashCode();\r
64         result = prime * result + name.hashCode();\r
65         return result;\r
66     }\r
67 \r
68     @Override\r
69     public boolean equals(Object obj) {\r
70         if (this == obj)\r
71             return true;\r
72         if (obj == null)\r
73             return false;\r
74         if (!(obj instanceof GroupFilter))\r
75             return false;\r
76         GroupFilter other = (GroupFilter) obj;\r
77         if (!filterText.equals(other.filterText))\r
78             return false;\r
79         if (!name.equals(other.name))\r
80             return false;\r
81         return true;\r
82     }\r
83 \r
84     @Override\r
85     public int compareTo(GroupFilter o) {\r
86         return name.compareToIgnoreCase(o.name);\r
87     }\r
88 }