Ticket #14315: alignways-hashcode-fix.patch
| File alignways-hashcode-fix.patch, 3.0 KB (added by , 9 years ago) |
|---|
-
plugins/alignways/build.xml
13 13 <property name="plugin.description" value="Makes a pair of selected way segments parallel by rotating one of them around a chosen pivot."/> 14 14 <property name="plugin.icon" value="images/alignways.png"/> 15 15 <property name="plugin.link" value="https://wiki.openstreetmap.org/wiki/JOSM/Plugins/AlignWayS"/> 16 <property name="plugin.canloadatruntime" value="true"/> 16 17 17 18 <!-- ** include targets that all plugins have in common ** --> 18 19 <import file="../build-common.xml"/> -
plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysSegment.java
12 12 import java.awt.geom.Line2D; 13 13 import java.util.Collection; 14 14 import java.util.HashSet; 15 import java.util.Objects; 15 16 16 17 import org.openstreetmap.josm.Main; 17 18 import org.openstreetmap.josm.data.Bounds; … … 113 114 114 115 @Override 115 116 public int hashCode() { 116 final int prime = 31; 117 int result = 1; 118 result = prime * result + ((segment == null) ? 0 : segment.hashCode()); 119 result = prime * result 120 + ((segmentColor == null) ? 0 : segmentColor.hashCode()); 121 return result; 117 if (segment == null) { 118 return System.identityHashCode(this); 119 } 120 121 // hashCode and equals should be consistent during the lifetime of this segment, 122 // otherwise the temporary mapview overlay will not be properly removed on destroy() 123 return segment.hashCode(); 122 124 } 123 125 124 @Override 125 public boolean equals(Object obj) { 126 if (this == obj) 127 return true; 128 if (obj == null) 129 return false; 130 if (!(obj instanceof AlignWaysSegment)) 131 return false; 132 AlignWaysSegment other = (AlignWaysSegment) obj; 133 if (segment == null) { 134 if (other.segment != null) 135 return false; 136 } else if (!segment.equals(other.segment)) 137 return false; 138 /* Segment colour is ignored in comparison 139 if (segmentColor == null) { 140 if (other.segmentColor != null) 141 return false; 142 } else if (!segmentColor.equals(other.segmentColor)) 143 return false; 144 */ 145 return true; 146 } 126 @Override 127 public boolean equals(Object o) { 128 if (this == o) return true; 129 if (!(o instanceof AlignWaysSegment)) return false; 130 AlignWaysSegment that = (AlignWaysSegment) o; 131 return Objects.equals(segment, that.segment); 132 } 133 147 134 }
