Ignore:
Timestamp:
2020-02-22T13:50:02+01:00 (5 years ago)
Author:
simon04
Message:

Fix SearchCompilerTest.testEqualsContract

Location:
trunk/src/org/openstreetmap/josm/gui/autofilter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java

    r15851 r15893  
    159159        @Override
    160160        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);
    167191        }
    168192    }
  • trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterRule.java

    r15843 r15893  
    192192
    193193    @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
    194207    public String toString() {
    195208        return key + '[' + minZoomLevel + ']';
Note: See TracChangeset for help on using the changeset viewer.