From 863f4d44531cb1f558ee3b4d4df1abb8134f7d5a Mon Sep 17 00:00:00 2001 From: steffenaxer <26229392+steffenaxer@users.noreply.github.com> Date: Mon, 15 Jan 2024 20:38:43 +0100 Subject: [PATCH] Move DRT_COMPANION_AGENT_PREFIX --- .../drt/extension/companions/DrtCompanionRideGenerator.java | 5 ++--- .../contrib/drt/extension/companions/DrtCompanionUtils.java | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java index 6b841cd0a75..e8a03d9ca2c 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java @@ -30,7 +30,6 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; -import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -46,15 +45,15 @@ import org.matsim.core.router.TripStructureUtils; import org.matsim.utils.objectattributes.attributable.AttributesUtils; +import static org.matsim.contrib.drt.extension.companions.DrtCompanionUtils.DRT_COMPANION_AGENT_PREFIX; + /** * @author Steffen Axer */ final class DrtCompanionRideGenerator implements BeforeMobsimListener, AfterMobsimListener { private static final Logger LOG = LogManager.getLogger(DrtCompanionRideGenerator.class); - public final static String DRT_COMPANION_AGENT_PREFIX = "COMPANION"; public static final String DRT_COMPANION_TYPE = "drtCompanion"; - private final Scenario scenario; private final String drtModes; private final MainModeIdentifier mainModeIdentifier; diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionUtils.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionUtils.java index 682d171814b..e7ed6132025 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionUtils.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionUtils.java @@ -37,6 +37,7 @@ public class DrtCompanionUtils { public final static String ADDITIONAL_GROUP_PART_ATTRIBUTE = "additionalGroupPart"; public static final String COMPANION_TYPE_ATTRIBUTE = "companionType"; public static final String GROUP_IDENTIFIER_ATTRIBUTE = "groupIdentifier"; + public static final String DRT_COMPANION_AGENT_PREFIX = "COMPANION"; private DrtCompanionUtils() { throw new IllegalStateException("Utility class"); @@ -46,6 +47,10 @@ public static boolean isDrtCompanion(Person person) { return getDRTCompanionType(person) != null; } + public static boolean isDrtCompanion(Id personId) { + return personId.toString().startsWith(DRT_COMPANION_AGENT_PREFIX); + } + public static void setDRTCompanionType(Person person, String drtCompanionType) { if (drtCompanionType == null) { person.getAttributes().removeAttribute(COMPANION_TYPE_ATTRIBUTE);