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

Java 7: use Objects.equals and Objects.hash

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java

    r8975 r9371  
    1414import java.util.List;
    1515import java.util.Map;
     16import java.util.Objects;
    1617
    1718import javax.swing.Icon;
     
    249250    @Override
    250251    public int hashCode() {
    251         final int prime = 31;
    252         int result = super.hashCode();
    253         result = prime * result + ((objects == null) ? 0 : objects.hashCode());
    254         result = prime * result + ((tags == null) ? 0 : tags.hashCode());
    255         return result;
     252        return Objects.hash(super.hashCode(), objects, tags);
    256253    }
    257254
    258255    @Override
    259256    public boolean equals(Object obj) {
    260         if (this == obj)
    261             return true;
    262         if (!super.equals(obj))
    263             return false;
    264         if (getClass() != obj.getClass())
    265             return false;
    266         ChangePropertyCommand other = (ChangePropertyCommand) obj;
    267         if (objects == null) {
    268             if (other.objects != null)
    269                 return false;
    270         } else if (!objects.equals(other.objects))
    271             return false;
    272         if (tags == null) {
    273             if (other.tags != null)
    274                 return false;
    275         } else if (!tags.equals(other.tags))
    276             return false;
    277         return true;
     257        if (this == obj) return true;
     258        if (obj == null || getClass() != obj.getClass()) return false;
     259        if (!super.equals(obj)) return false;
     260        ChangePropertyCommand that = (ChangePropertyCommand) obj;
     261        return Objects.equals(objects, that.objects) &&
     262                Objects.equals(tags, that.tags);
    278263    }
    279264}
Note: See TracChangeset for help on using the changeset viewer.