org.opentrafficsim.road.gtu.lane.MultiLaneBasedMoveChecker Maven / Gradle / Ivy
package org.opentrafficsim.road.gtu.lane;
import java.util.LinkedHashSet;
import java.util.Set;
import org.djutils.exceptions.Throw;
import org.opentrafficsim.core.network.Network;
/**
* Checker that invokes multiple checkers.
*
* Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
* @author Alexander Verbraeck
* @author Peter Knoppers
* @author Wouter Schakel
*/
public class MultiLaneBasedMoveChecker extends AbstractLaneBasedMoveChecker
{
/** Checkers. */
private Set checkers = new LinkedHashSet<>();
/**
* Constructor.
* @param network Network; network
*/
public MultiLaneBasedMoveChecker(final Network network)
{
super(network);
}
/**
* Constructor.
* @param network Network; network
* @param checkers AbstractLaneBasedMoveChecker...; checkers
*/
public MultiLaneBasedMoveChecker(final Network network, final AbstractLaneBasedMoveChecker... checkers)
{
super(network);
for (AbstractLaneBasedMoveChecker checker : checkers)
{
addChecker(checker);
}
}
/**
* Add checker.
* @param checker AbstractLaneBasedMoveChecker; checker to add
*/
final void addChecker(final AbstractLaneBasedMoveChecker checker)
{
Throw.whenNull(checker, "Checker may not be null.");
this.checkers.add(checker);
}
/** {@inheritDoc} */
@Override
public void checkMove(final LaneBasedGtu gtu) throws Exception
{
for (AbstractLaneBasedMoveChecker checker : this.checkers)
{
checker.checkMove(gtu);
}
}
}