001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.autofilter;
003
004import java.util.Objects;
005
006/**
007 * An auto filter is a graphical shortcut to enable a filter for a specific tag.
008 * @since 12400
009 */
010public class AutoFilter {
011    private final String label;
012    private final String description;
013    private final AutoFilterManager.CompiledFilter filter;
014
015    /**
016     * Constructs a new {@code AutoFilter}.
017     * @param label button label
018     * @param description button tooltip
019     * @param filter associated filter
020     */
021    public AutoFilter(String label, String description, AutoFilterManager.CompiledFilter filter) {
022        this.label = label;
023        this.description = description;
024        this.filter = filter;
025    }
026
027    /**
028     * Returns the button label.
029     * @return the button label
030     */
031    public String getLabel() {
032        return label;
033    }
034
035    /**
036     * Returns the button tooltip.
037     * @return the button tooltip
038     */
039    public String getDescription() {
040        return description;
041    }
042
043    /**
044     * Returns the filter.
045     * @return the filter
046     */
047    public AutoFilterManager.CompiledFilter getFilter() {
048        return filter;
049    }
050
051    @Override
052    public int hashCode() {
053        return Objects.hash(filter);
054    }
055
056    @Override
057    public boolean equals(Object obj) {
058        if (this == obj)
059            return true;
060        if (obj == null || getClass() != obj.getClass())
061            return false;
062        AutoFilter other = (AutoFilter) obj;
063        return Objects.equals(filter, other.filter);
064    }
065
066    @Override
067    public String toString() {
068        return "AutoFilter [label=" + label + ", description=" + description + ", filter=" + filter + ']';
069    }
070}