Skip to content

Commit a9eb787

Browse files
authored
Merge pull request #315 from conveyal/add-stoptime-hash
Add hashCode and equals method to StopTime.java
2 parents 8d0a19f + 736541a commit a9eb787

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/main/java/com/conveyal/gtfs/model/StopTime.java

+34
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.sql.PreparedStatement;
1010
import java.sql.SQLException;
1111
import java.util.Iterator;
12+
import java.util.Objects;
1213

1314
/**
1415
* Represents a GTFS StopTime. Note that once created and saved in a feed, stop times are by convention immutable
@@ -141,4 +142,37 @@ public StopTime clone () {
141142
throw new RuntimeException(e);
142143
}
143144
}
145+
146+
@Override
147+
public boolean equals(Object o) {
148+
if (this == o) return true;
149+
if (o == null || getClass() != o.getClass()) return false;
150+
StopTime stopTime = (StopTime) o;
151+
return arrival_time == stopTime.arrival_time &&
152+
departure_time == stopTime.departure_time &&
153+
stop_sequence == stopTime.stop_sequence &&
154+
pickup_type == stopTime.pickup_type &&
155+
drop_off_type == stopTime.drop_off_type &&
156+
Double.compare(stopTime.shape_dist_traveled, shape_dist_traveled) == 0 &&
157+
timepoint == stopTime.timepoint &&
158+
Objects.equals(trip_id, stopTime.trip_id) &&
159+
Objects.equals(stop_id, stopTime.stop_id) &&
160+
Objects.equals(stop_headsign, stopTime.stop_headsign);
161+
}
162+
163+
@Override
164+
public int hashCode() {
165+
return Objects.hash(
166+
trip_id,
167+
arrival_time,
168+
departure_time,
169+
stop_id,
170+
stop_sequence,
171+
stop_headsign,
172+
pickup_type,
173+
drop_off_type,
174+
shape_dist_traveled,
175+
timepoint
176+
);
177+
}
144178
}

0 commit comments

Comments
 (0)