class Traversal implements Serializable {

    public double getSpeedAtDistance(double distance) {
        if (DoubleMath.fuzzyEquals(distance, totalDistance, totalDistance * ROUNDING_ERROR_FRACTION)) {
            TraversalSection lastSection = Iterables.getLast(sections);
            return lastSection.getSpeedAtTime(lastSection.getDuration());
        }

        if (distance < 0) {
            throw new TraversalCalculationException("Negative distance provided.");
        }
        if (distance >= totalDistance) {
            throw new TraversalCalculationException("Distance beyond end of traversal provided");
        }

        return SegmentGraphUtilities.getValueAt(
                sections,
                TraversalSection::getTotalDistance,
                TraversalSection::getSpeedAtDistance,
                distance);
    }

    public  Traversal(ImmutableList<TraversalSection> sections);

}