class RouteChangedEventPublisher {

    static RouteChangedEvent solutionToEvent(VehicleRoutingSolution solution, Object source) {
        List<ShallowRoute> routes = routes(solution);
        return new RouteChangedEvent(
                source,
                // Turn negative soft score into a positive amount of time.
                Distance.ofMillis(-solution.getScore().getSoftScore()),
                vehicleIds(solution),
                depotId(solution),
                visitIds(solution),
                routes);
    }

    @Autowired  RouteChangedEventPublisher(ApplicationEventPublisher eventPublisher);

}