
org.opentripplanner.graph_builder.module.osm.StreetEdgePair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
The newest version!
package org.opentripplanner.graph_builder.module.osm;
import java.util.ArrayList;
import org.opentripplanner.street.model.edge.StreetEdge;
public record StreetEdgePair(StreetEdge main, StreetEdge back) {
/**
* Return the non-null elements of this pair as an Iterable.
*/
public Iterable asIterable() {
var ret = new ArrayList(2);
if (main != null) {
ret.add(main);
}
if (back != null) {
ret.add(back);
}
return ret;
}
/**
* Select one of the edges contained in this pair that is not null. No particular algorithm is
* guaranteed, and it may change in the future.
*/
public StreetEdge pickAny() {
if (main != null) {
return main;
} else if (back != null) {
return back;
}
throw new IllegalStateException(
"%s must not contain two null elements".formatted(getClass().getSimpleName())
);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy