Ignore:
Timestamp:
2016-01-09T23:20:37+01:00 (8 years ago)
Author:
simon04
Message:

Java 7: use Objects.equals and Objects.hash

Location:
trunk/src/org/openstreetmap/josm/data/imagery
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r9135 r9371  
    134134        @Override
    135135        public int hashCode() {
    136             final int prime = 31;
    137             int result = super.hashCode();
    138             result = prime * result + ((shapes == null) ? 0 : shapes.hashCode());
    139             return result;
     136            return Objects.hash(super.hashCode(), shapes);
    140137        }
    141138
    142139        @Override
    143         public boolean equals(Object obj) {
    144             if (this == obj)
    145                 return true;
    146             if (!super.equals(obj))
    147                 return false;
    148             if (getClass() != obj.getClass())
    149                 return false;
    150             ImageryBounds other = (ImageryBounds) obj;
    151             if (shapes == null) {
    152                 if (other.shapes != null)
    153                     return false;
    154             } else if (!shapes.equals(other.shapes))
    155                 return false;
    156             return true;
     140        public boolean equals(Object o) {
     141            if (this == o) return true;
     142            if (o == null || getClass() != o.getClass()) return false;
     143            if (!super.equals(o)) return false;
     144            ImageryBounds that = (ImageryBounds) o;
     145            return Objects.equals(shapes, that.shapes);
    157146        }
    158147    }
     
    457446
    458447    @Override
    459     public boolean equals(Object o) {
    460         if (this == o) return true;
    461         if (o == null || getClass() != o.getClass()) return false;
    462 
    463         ImageryInfo that = (ImageryInfo) o;
    464 
    465         if (imageryType != that.imageryType) return false;
    466         if (url != null ? !url.equals(that.url) : that.url != null) return false;
    467         if (name != null ? !name.equals(that.name) : that.name != null) return false;
    468 
    469         return true;
     448    public int hashCode() {
     449        return Objects.hash(url, imageryType);
    470450    }
    471451
     
    509489
    510490    @Override
    511     public int hashCode() {
    512         int result = url != null ? url.hashCode() : 0;
    513         result = 31 * result + (imageryType != null ? imageryType.hashCode() : 0);
    514         return result;
     491    public boolean equals(Object o) {
     492        if (this == o) return true;
     493        if (o == null || getClass() != o.getClass()) return false;
     494        ImageryInfo that = (ImageryInfo) o;
     495        return imageryType == that.imageryType && Objects.equals(url, that.url);
    515496    }
    516497
  • trunk/src/org/openstreetmap/josm/data/imagery/Shape.java

    r8510 r9371  
    9393    @Override
    9494    public int hashCode() {
    95         int hash = 5;
    96         hash = 47 * hash + Objects.hashCode(this.coords);
    97         return hash;
     95        return Objects.hash(coords);
    9896    }
    9997
    10098    @Override
    10199    public boolean equals(Object obj) {
    102         if (obj == null) {
    103             return false;
    104         }
    105         if (getClass() != obj.getClass()) {
    106             return false;
    107         }
    108         final Shape other = (Shape) obj;
    109         if (!Objects.equals(this.coords, other.coords)) {
    110             return false;
    111         }
    112         return true;
     100        if (this == obj) return true;
     101        if (obj == null || getClass() != obj.getClass()) return false;
     102        Shape shape = (Shape) obj;
     103        return Objects.equals(coords, shape.coords);
    113104    }
    114105}
Note: See TracChangeset for help on using the changeset viewer.