All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.astar.strategy.ComposingSkipEdgeStrategy Maven / Gradle / Ivy

The newest version!
package org.opentripplanner.astar.strategy;

import org.opentripplanner.astar.spi.AStarEdge;
import org.opentripplanner.astar.spi.AStarState;
import org.opentripplanner.astar.spi.SkipEdgeStrategy;

/**
 * Use several strategies in composition with each other, for example by limiting by time and number
 * of stops visited. Only one needs to be skipped in order for {@link
 * SkipEdgeStrategy#shouldSkipEdge(State, Edge)} to return null.
 */
public record ComposingSkipEdgeStrategy<
  State extends AStarState, Edge extends AStarEdge
>(SkipEdgeStrategy... strategies)
  implements SkipEdgeStrategy {
  @Override
  public boolean shouldSkipEdge(State current, Edge edge) {
    for (var strategy : strategies) {
      if (strategy.shouldSkipEdge(current, edge)) {
        return true;
      }
    }
    return false;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy