Skip to content

Commit

Permalink
Merge pull request #315 from conveyal/add-stoptime-hash
Browse files Browse the repository at this point in the history
Add hashCode and equals method to StopTime.java
  • Loading branch information
evansiroky authored May 2, 2021
2 parents 8d0a19f + 736541a commit a9eb787
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 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,37 @@ 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 a9eb787

Please sign in to comment.