From 0e1ef80adfddf96429f7a044be0189369d91f720 Mon Sep 17 00:00:00 2001 From: rsynek Date: Wed, 23 Sep 2026 08:58:23 +0200 Subject: [PATCH 1/2] fix: polish map service API --- .../maps/service/client/api/TravelTimeMatrixEnricher.java | 6 ++++-- .../service/integration/api/LocationsAwareSolverModel.java | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/service/maps/service-client/src/main/java/ai/timefold/solver/service/maps/service/client/api/TravelTimeMatrixEnricher.java b/service/maps/service-client/src/main/java/ai/timefold/solver/service/maps/service/client/api/TravelTimeMatrixEnricher.java index 5ef4ebf85eb..00462c064af 100644 --- a/service/maps/service-client/src/main/java/ai/timefold/solver/service/maps/service/client/api/TravelTimeMatrixEnricher.java +++ b/service/maps/service-client/src/main/java/ai/timefold/solver/service/maps/service/client/api/TravelTimeMatrixEnricher.java @@ -3,6 +3,7 @@ import java.time.temporal.ChronoUnit; import java.util.Collections; import java.util.List; +import java.util.Objects; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; @@ -62,7 +63,8 @@ public LocationsAwareSolverModel enrich(LocationsAwareSolverModel solverMo } private LocationsAwareSolverModel enrichSingleMatrix(LocationsAwareSolverModel solverModel) { - List locations = solverModel.getLocations(); // Get all the locations from the model only once. + // Get all the locations from the model only once. + List locations = Objects.requireNonNull(solverModel.getLocations(), "List of locations cannot be null."); TravelTimeAndDistanceWithMetadata travelTimeAndDistance; try { travelTimeAndDistance = @@ -85,7 +87,7 @@ private LocationsAwareSolverModel enrichSingleMatrix(LocationsAwareSolverMode } private LocationsAwareSolverModel enrichAllTimeframes(LocationsAwareSolverModel solverModel) { - List locations = solverModel.getLocations(); + List locations = Objects.requireNonNull(solverModel.getLocations(), "List of locations cannot be null."); TravelTimesByTimeframeWithMetadata result; try { result = mapService.getTravelTimeAndDistanceByTimeframe(locations, optionsSupplier.getOptions()); diff --git a/service/maps/service-integration/src/main/java/ai/timefold/solver/service/maps/service/integration/api/LocationsAwareSolverModel.java b/service/maps/service-integration/src/main/java/ai/timefold/solver/service/maps/service/integration/api/LocationsAwareSolverModel.java index 5ab322f3cbe..209c3bcd9f6 100644 --- a/service/maps/service-integration/src/main/java/ai/timefold/solver/service/maps/service/integration/api/LocationsAwareSolverModel.java +++ b/service/maps/service-integration/src/main/java/ai/timefold/solver/service/maps/service/integration/api/LocationsAwareSolverModel.java @@ -11,7 +11,9 @@ public interface LocationsAwareSolverModel> extends List getLocations(); - Optional getLocationSetName(); + default Optional getLocationSetName() { + return Optional.empty(); + } void setLocationsNotInMap(List locationsNotInMap); From 388521db50f1acbe312efb1686c76d3ab66d7e01 Mon Sep 17 00:00:00 2001 From: Radovan Synek Date: Wed, 23 Sep 2026 11:27:08 +0200 Subject: [PATCH 2/2] add javadoc Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../service/integration/api/LocationsAwareSolverModel.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/service/maps/service-integration/src/main/java/ai/timefold/solver/service/maps/service/integration/api/LocationsAwareSolverModel.java b/service/maps/service-integration/src/main/java/ai/timefold/solver/service/maps/service/integration/api/LocationsAwareSolverModel.java index 209c3bcd9f6..4a2e8279975 100644 --- a/service/maps/service-integration/src/main/java/ai/timefold/solver/service/maps/service/integration/api/LocationsAwareSolverModel.java +++ b/service/maps/service-integration/src/main/java/ai/timefold/solver/service/maps/service/integration/api/LocationsAwareSolverModel.java @@ -11,6 +11,11 @@ public interface LocationsAwareSolverModel> extends List getLocations(); + /** + * Returns the optional name of the location set used for map-service requests. + * + * @return the location-set name, or {@link Optional#empty()} when no name is configured + */ default Optional getLocationSetName() { return Optional.empty(); }