- Timestamp:
- 2020-02-22T13:50:02+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
r15764 r15893 1971 1971 try { 1972 1972 final List<Selector> selectors = new MapCSSParser(new StringReader(mapCSS)).selectors_for_search(); 1973 return new Match() { 1974 @Override 1975 public boolean match(OsmPrimitive osm) { 1976 for (Selector selector : selectors) { 1977 if (selector.matches(new Environment(osm))) { 1978 return true; 1979 } 1980 } 1981 return false; 1982 } 1983 }; 1973 return new MapCSSMatch(selectors); 1984 1974 } catch (ParseException | IllegalArgumentException e) { 1985 1975 throw new SearchParseError(tr("Failed to parse MapCSS selector"), e); 1976 } 1977 } 1978 1979 private static class MapCSSMatch extends Match { 1980 private final List<Selector> selectors; 1981 1982 MapCSSMatch(List<Selector> selectors) { 1983 this.selectors = selectors; 1984 } 1985 1986 @Override 1987 public boolean match(OsmPrimitive osm) { 1988 return selectors.stream() 1989 .anyMatch(selector -> selector.matches(new Environment(osm))); 1990 } 1991 1992 @Override 1993 public boolean equals(Object o) { 1994 if (this == o) return true; 1995 if (o == null || getClass() != o.getClass()) return false; 1996 MapCSSMatch that = (MapCSSMatch) o; 1997 return Objects.equals(selectors, that.selectors); 1998 } 1999 2000 @Override 2001 public int hashCode() { 2002 return Objects.hash(selectors); 1986 2003 } 1987 2004 } -
trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java
r15851 r15893 159 159 @Override 160 160 public SearchCompiler.Match get() { 161 return new SearchCompiler.Match() { 162 @Override 163 public boolean match(OsmPrimitive osm) { 164 return rule.getTagValuesForPrimitive(osm).anyMatch(v -> v == value); 165 } 166 }; 161 return new Match(rule, value); 162 } 163 } 164 165 static class Match extends SearchCompiler.Match { 166 final AutoFilterRule rule; 167 final int value; 168 169 Match(AutoFilterRule rule, int value) { 170 this.rule = rule; 171 this.value = value; 172 } 173 174 @Override 175 public boolean match(OsmPrimitive osm) { 176 return rule.getTagValuesForPrimitive(osm).anyMatch(v -> v == value); 177 } 178 179 @Override 180 public boolean equals(Object o) { 181 if (this == o) return true; 182 if (o == null || getClass() != o.getClass()) return false; 183 Match match = (Match) o; 184 return value == match.value && 185 Objects.equals(rule, match.rule); 186 } 187 188 @Override 189 public int hashCode() { 190 return Objects.hash(rule, value); 167 191 } 168 192 } -
trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterRule.java
r15843 r15893 192 192 193 193 @Override 194 public boolean equals(Object o) { 195 if (this == o) return true; 196 if (o == null || getClass() != o.getClass()) return false; 197 AutoFilterRule that = (AutoFilterRule) o; 198 return Objects.equals(key, that.key); 199 } 200 201 @Override 202 public int hashCode() { 203 return Objects.hash(key); 204 } 205 206 @Override 194 207 public String toString() { 195 208 return key + '[' + minZoomLevel + ']';
Note:
See TracChangeset
for help on using the changeset viewer.