Ignore:
Timestamp:
2019-10-19T08:08:54+02:00 (5 years ago)
Author:
GerdP
Message:

see #18232: remove Test.compareTo() and more

Location:
trunk/src/org/openstreetmap/josm/data/validation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r15121 r15463  
    88import java.util.Collection;
    99import java.util.List;
    10 import java.util.Objects;
    1110import java.util.Optional;
    1211import java.util.function.Predicate;
     
    3938 * @author frsantos
    4039 */
    41 public class Test implements OsmPrimitiveVisitor, Comparable<Test> {
     40public class Test implements OsmPrimitiveVisitor {
    4241
    4342    protected static final Predicate<OsmPrimitive> IN_DOWNLOADED_AREA = new NotOutsideDataSourceArea();
     
    365364    }
    366365
    367     @Override
    368     public int hashCode() {
    369         return Objects.hash(name, description);
    370     }
    371 
    372     @Override
    373     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     @Override
    382     public int compareTo(Test t) {
    383         return name.compareTo(t.name);
    384     }
    385 
    386366    /**
    387367     * Free resources.
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r15417 r15463  
    682682
    683683        @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         @Override
    691         public synchronized int hashCode() {
    692             return Objects.hash(super.hashCode(), rule);
    693         }
    694 
    695         @Override
    696684        public String toString() {
    697685            return "MapCSSTagCheckerAndRule [rule=" + rule + ']';
     
    930918                final Collection<TestError> pErrors = getErrorsForPrimitive(p, true, checksToRun);
    931919                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));
    934922                if (isError != i.getValue()) {
    935923                    assertionErrors.add(MessageFormat.format("Expecting test ''{0}'' (i.e., {1}) to {2} {3} (i.e., {4})",
     
    957945        }
    958946        ds.addPrimitive(p);
    959     }
    960 
    961     @Override
    962     public synchronized int hashCode() {
    963         return Objects.hash(super.hashCode(), checks);
    964     }
    965 
    966     @Override
    967     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);
    973947    }
    974948
  • trunk/src/org/openstreetmap/josm/data/validation/tests/SharpAngles.java

    r15448 r15463  
    66import java.util.Arrays;
    77import java.util.Collection;
    8 import java.util.Objects;
    98import java.util.TreeSet;
    109
     
    152151    }
    153152
    154     @Override
    155     public int hashCode() {
    156         return 31 * super.hashCode() + Objects.hash(ignoreHighways, maxAngle, maxLength);
    157     }
    158 
    159     @Override
    160     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     }
    170153}
Note: See TracChangeset for help on using the changeset viewer.