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