Skip to content

Commit

Permalink
Merge pull request #3054 from steffenaxer/drtCompanionPrefix
Browse files Browse the repository at this point in the history
Move DRT_COMPANION_AGENT_PREFIX
  • Loading branch information
steffenaxer authored Jan 15, 2024
2 parents b236f2d + 863f4d4 commit 48ea6b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -46,6 +47,10 @@ public static boolean isDrtCompanion(Person person) {
return getDRTCompanionType(person) != null;
}

public static boolean isDrtCompanion(Id<Person> 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);
Expand Down

0 comments on commit 48ea6b7

Please sign in to comment.