Skip to content

Commit

Permalink
Add getter and setter for disallowedNextLinks
Browse files Browse the repository at this point in the history
  • Loading branch information
marecabo committed Oct 13, 2023
1 parent 57598c8 commit b80a197
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions matsim/src/main/java/org/matsim/core/network/NetworkUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import java.util.*;

import javax.annotation.Nullable;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -988,4 +990,29 @@ public static List<Node> getOriginalGeometry(Link link) {
result.add(link.getToNode());
return result;
}

private static final String DISALLOWED_NEXT_LINKS_ATTRIBUTE = "disallowedNextLinks";

@Nullable
public static DisallowedNextLinks getDisallowedNextLinks(Link link) {
return (DisallowedNextLinks) link.getAttributes().getAttribute(DISALLOWED_NEXT_LINKS_ATTRIBUTE);
}

public static DisallowedNextLinks getOrCreateDisallowedNextLinks(Link link) {
DisallowedNextLinks disallowedNextLinks = getDisallowedNextLinks(link);
if (disallowedNextLinks == null) {
disallowedNextLinks = new DisallowedNextLinks();
setDisallowedNextLinks(link, disallowedNextLinks);
}
return disallowedNextLinks;
}

public static void setDisallowedNextLinks(Link link, DisallowedNextLinks disallowedNextLinks) {
link.getAttributes().putAttribute(DISALLOWED_NEXT_LINKS_ATTRIBUTE, disallowedNextLinks);
}

public static boolean addDisallowedNextLinks(Link link, String mode, Collection<Id<Link>> linkIds) {
DisallowedNextLinks disallowedNextLinks = getOrCreateDisallowedNextLinks(link);
return disallowedNextLinks.addDisallowedLinkSequence(mode, linkIds);
}
}

0 comments on commit b80a197

Please sign in to comment.