Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move DRT_COMPANION_AGENT_PREFIX #3054

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading