1 package org.opentrafficsim.road.gtu.lane;
2
3 import java.util.LinkedHashSet;
4 import java.util.Set;
5
6 import org.djutils.exceptions.Throw;
7 import org.opentrafficsim.core.network.Network;
8
9 /**
10 * Checker that invokes multiple checkers.
11 * <p>
12 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
14 * </p>
15 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
16 * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
17 * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
18 */
19 public class MultiLaneBasedMoveChecker extends AbstractLaneBasedMoveChecker
20 {
21
22 /** Checkers. */
23 private Set<AbstractLaneBasedMoveChecker> checkers = new LinkedHashSet<>();
24
25 /**
26 * Constructor.
27 * @param network Network; network
28 */
29 public MultiLaneBasedMoveChecker(final Network network)
30 {
31 super(network);
32 }
33
34 /**
35 * Constructor.
36 * @param network Network; network
37 * @param checkers AbstractLaneBasedMoveChecker...; checkers
38 */
39 public MultiLaneBasedMoveChecker(final Network network, final AbstractLaneBasedMoveChecker... checkers)
40 {
41 super(network);
42 for (AbstractLaneBasedMoveChecker checker : checkers)
43 {
44 addChecker(checker);
45 }
46 }
47
48 /**
49 * Add checker.
50 * @param checker AbstractLaneBasedMoveChecker; checker to add
51 */
52 final void addChecker(final AbstractLaneBasedMoveChecker checker)
53 {
54 Throw.whenNull(checker, "Checker may not be null.");
55 this.checkers.add(checker);
56 }
57
58 /** {@inheritDoc} */
59 @Override
60 public void checkMove(final LaneBasedGtu gtu) throws Exception
61 {
62 for (AbstractLaneBasedMoveChecker checker : this.checkers)
63 {
64 checker.checkMove(gtu);
65 }
66 }
67
68 }