Skip to content

Commit

Permalink
fix(StopTime): add hashCode and equals method
Browse files Browse the repository at this point in the history
  • Loading branch information
landonreed committed Apr 23, 2021
1 parent 8d0a19f commit c454db9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/com/conveyal/gtfs/model/StopTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Objects;

/**
* Represents a GTFS StopTime. Note that once created and saved in a feed, stop times are by convention immutable
Expand Down Expand Up @@ -141,4 +142,17 @@ public StopTime clone () {
throw new RuntimeException(e);
}
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StopTime stopTime = (StopTime) o;
return arrival_time == stopTime.arrival_time && departure_time == stopTime.departure_time && stop_sequence == stopTime.stop_sequence && pickup_type == stopTime.pickup_type && drop_off_type == stopTime.drop_off_type && Double.compare(stopTime.shape_dist_traveled, shape_dist_traveled) == 0 && timepoint == stopTime.timepoint && Objects.equals(trip_id, stopTime.trip_id) && Objects.equals(stop_id, stopTime.stop_id) && Objects.equals(stop_headsign, stopTime.stop_headsign);
}

@Override
public int hashCode() {
return Objects.hash(trip_id, arrival_time, departure_time, stop_id, stop_sequence, stop_headsign, pickup_type, drop_off_type, shape_dist_traveled, timepoint);
}
}

0 comments on commit c454db9

Please # to comment.