Ticket #18232: 18232.patch
| File 18232.patch, 5.1 KB (added by , 6 years ago) |
|---|
-
src/org/openstreetmap/josm/data/validation/Test.java
7 7 import java.util.ArrayList; 8 8 import java.util.Collection; 9 9 import java.util.List; 10 import java.util.Objects;11 10 import java.util.Optional; 12 11 import java.util.function.Predicate; 13 12 … … 38 37 * 39 38 * @author frsantos 40 39 */ 41 public class Test implements OsmPrimitiveVisitor , Comparable<Test>{40 public class Test implements OsmPrimitiveVisitor { 42 41 43 42 protected static final Predicate<OsmPrimitive> IN_DOWNLOADED_AREA = new NotOutsideDataSourceArea(); 44 43 protected static final Predicate<OsmPrimitive> IN_DOWNLOADED_AREA_STRICT = new InDataSourceArea(true); … … 364 363 return p.hasTag("landuse", "residential"); 365 364 } 366 365 367 @Override368 public int hashCode() {369 return Objects.hash(name, description);370 }371 372 @Override373 public boolean equals(Object obj) {374 if (this == obj) return true;375 if (obj == null || getClass() != obj.getClass()) return false;376 Test test = (Test) obj;377 return Objects.equals(name, test.name) &&378 Objects.equals(description, test.description);379 }380 381 @Override382 public int compareTo(Test t) {383 return name.compareTo(t.name);384 }385 386 366 /** 387 367 * Free resources. 388 368 */ -
src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
681 681 } 682 682 683 683 @Override 684 public synchronized boolean equals(Object obj) {685 return super.equals(obj)686 || (obj instanceof TagCheck && rule.equals(((TagCheck) obj).rule))687 || (obj instanceof GroupedMapCSSRule && rule.equals(obj));688 }689 690 @Override691 public synchronized int hashCode() {692 return Objects.hash(super.hashCode(), rule);693 }694 695 @Override696 684 public String toString() { 697 685 return "MapCSSTagCheckerAndRule [rule=" + rule + ']'; 698 686 } … … 929 917 addPrimitive(ds, p); 930 918 final Collection<TestError> pErrors = getErrorsForPrimitive(p, true, checksToRun); 931 919 Logging.debug("- Errors: {0}", pErrors); 932 @SuppressWarnings({"EqualsBetweenInconvertibleTypes", "EqualsIncompatibleType"})933 final boolean isError = pErrors.stream().anyMatch(e -> e.getTester().equals(check.rule));920 final boolean isError = pErrors.stream().anyMatch(e -> e.getTester() instanceof MapCSSTagCheckerAndRule 921 && ((MapCSSTagCheckerAndRule) e.getTester()).rule.equals(check.rule)); 934 922 if (isError != i.getValue()) { 935 923 assertionErrors.add(MessageFormat.format("Expecting test ''{0}'' (i.e., {1}) to {2} {3} (i.e., {4})", 936 924 check.getMessage(p), check.rule.selectors, i.getValue() ? "match" : "not match", i.getKey(), p.getKeys())); … … 958 946 ds.addPrimitive(p); 959 947 } 960 948 961 @Override962 public synchronized int hashCode() {963 return Objects.hash(super.hashCode(), checks);964 }965 966 @Override967 public synchronized boolean equals(Object obj) {968 if (this == obj) return true;969 if (obj == null || getClass() != obj.getClass()) return false;970 if (!super.equals(obj)) return false;971 MapCSSTagChecker that = (MapCSSTagChecker) obj;972 return Objects.equals(checks, that.checks);973 }974 975 949 /** 976 950 * Reload tagchecker rule. 977 951 * @param rule tagchecker rule to reload -
src/org/openstreetmap/josm/data/validation/tests/SharpAngles.java
5 5 6 6 import java.util.Arrays; 7 7 import java.util.Collection; 8 import java.util.Objects;9 8 import java.util.TreeSet; 10 9 11 10 import org.openstreetmap.josm.data.coor.EastNorth; … … 151 150 maxAngle = angle; 152 151 } 153 152 154 @Override155 public int hashCode() {156 return 31 * super.hashCode() + Objects.hash(ignoreHighways, maxAngle, maxLength);157 }158 159 @Override160 public boolean equals(Object obj) {161 if (this == obj)162 return true;163 if (!super.equals(obj) || getClass() != obj.getClass())164 return false;165 SharpAngles other = (SharpAngles) obj;166 return Objects.equals(ignoreHighways, other.ignoreHighways)167 && Double.doubleToLongBits(maxAngle) == Double.doubleToLongBits(other.maxAngle)168 && Double.doubleToLongBits(maxLength) == Double.doubleToLongBits(other.maxLength);169 }170 153 }
