1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.autofilter;
|
---|
3 |
|
---|
4 | import java.util.Objects;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * An auto filter is a graphical shortcut to enable a filter for a specific tag.
|
---|
8 | * @since 12400
|
---|
9 | */
|
---|
10 | public class AutoFilter {
|
---|
11 | private final String label;
|
---|
12 | private final String description;
|
---|
13 | private final AutoFilterManager.CompiledFilter filter;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Constructs a new {@code AutoFilter}.
|
---|
17 | * @param label button label
|
---|
18 | * @param description button tooltip
|
---|
19 | * @param filter associated filter
|
---|
20 | */
|
---|
21 | public AutoFilter(String label, String description, AutoFilterManager.CompiledFilter filter) {
|
---|
22 | this.label = label;
|
---|
23 | this.description = description;
|
---|
24 | this.filter = filter;
|
---|
25 | }
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Returns the button label.
|
---|
29 | * @return the button label
|
---|
30 | */
|
---|
31 | public String getLabel() {
|
---|
32 | return label;
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Returns the button tooltip.
|
---|
37 | * @return the button tooltip
|
---|
38 | */
|
---|
39 | public String getDescription() {
|
---|
40 | return description;
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Returns the filter.
|
---|
45 | * @return the filter
|
---|
46 | */
|
---|
47 | public AutoFilterManager.CompiledFilter getFilter() {
|
---|
48 | return filter;
|
---|
49 | }
|
---|
50 |
|
---|
51 | @Override
|
---|
52 | public int hashCode() {
|
---|
53 | return Objects.hash(filter);
|
---|
54 | }
|
---|
55 |
|
---|
56 | @Override
|
---|
57 | public boolean equals(Object obj) {
|
---|
58 | if (this == obj)
|
---|
59 | return true;
|
---|
60 | if (obj == null || getClass() != obj.getClass())
|
---|
61 | return false;
|
---|
62 | AutoFilter other = (AutoFilter) obj;
|
---|
63 | return Objects.equals(filter, other.filter);
|
---|
64 | }
|
---|
65 |
|
---|
66 | @Override
|
---|
67 | public String toString() {
|
---|
68 | return "AutoFilter [label=" + label + ", description=" + description + ", filter=" + filter + ']';
|
---|
69 | }
|
---|
70 | }
|
---|