Ignore:
Timestamp:
2016-01-09T23:20:37+01:00 (8 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/AddPrimitivesCommand.java

    r8840 r9371  
    88import java.util.HashSet;
    99import java.util.List;
     10import java.util.Objects;
    1011
    1112import javax.swing.Icon;
     
    176177    @Override
    177178    public int hashCode() {
    178         final int prime = 31;
    179         int result = super.hashCode();
    180         result = prime * result + ((createdPrimitives == null) ? 0 : createdPrimitives.hashCode());
    181         result = prime * result + ((createdPrimitivesToSelect == null) ? 0 : createdPrimitivesToSelect.hashCode());
    182         result = prime * result + ((data == null) ? 0 : data.hashCode());
    183         result = prime * result + ((toSelect == null) ? 0 : toSelect.hashCode());
    184         return result;
     179        return Objects.hash(super.hashCode(), data, toSelect, createdPrimitives, createdPrimitivesToSelect);
    185180    }
    186181
    187182    @Override
    188183    public boolean equals(Object obj) {
    189         if (this == obj)
    190             return true;
    191         if (!super.equals(obj))
    192             return false;
    193         if (getClass() != obj.getClass())
    194             return false;
    195         AddPrimitivesCommand other = (AddPrimitivesCommand) obj;
    196         if (createdPrimitives == null) {
    197             if (other.createdPrimitives != null)
    198                 return false;
    199         } else if (!createdPrimitives.equals(other.createdPrimitives))
    200             return false;
    201         if (createdPrimitivesToSelect == null) {
    202             if (other.createdPrimitivesToSelect != null)
    203                 return false;
    204         } else if (!createdPrimitivesToSelect.equals(other.createdPrimitivesToSelect))
    205             return false;
    206         if (data == null) {
    207             if (other.data != null)
    208                 return false;
    209         } else if (!data.equals(other.data))
    210             return false;
    211         if (toSelect == null) {
    212             if (other.toSelect != null)
    213                 return false;
    214         } else if (!toSelect.equals(other.toSelect))
    215             return false;
    216         return true;
     184        if (this == obj) return true;
     185        if (obj == null || getClass() != obj.getClass()) return false;
     186        if (!super.equals(obj)) return false;
     187        AddPrimitivesCommand that = (AddPrimitivesCommand) obj;
     188        return Objects.equals(data, that.data) &&
     189                Objects.equals(toSelect, that.toSelect) &&
     190                Objects.equals(createdPrimitives, that.createdPrimitives) &&
     191                Objects.equals(createdPrimitivesToSelect, that.createdPrimitivesToSelect);
    217192    }
    218193}
Note: See TracChangeset for help on using the changeset viewer.