1 package org.opentrafficsim.kpi.sampling.meta;
2
3 import org.opentrafficsim.kpi.interfaces.GtuDataInterface;
4 import org.opentrafficsim.kpi.interfaces.NodeDataInterface;
5
6 import nl.tudelft.simulation.language.Throw;
7
8 /**
9 * Accepts trajectories with an origin node included in a set in a query.
10 * <p>
11 * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
12 * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
13 * <p>
14 * @version $Revision$, $LastChangedDate$, by $Author$, initial version Sep 22, 2016 <br>
15 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
16 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
17 * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
18 */
19 public class MetaDataOrigin extends MetaDataType<NodeDataInterface>
20 {
21
22 /**
23 *
24 */
25 public MetaDataOrigin()
26 {
27 super("origin");
28 }
29
30 /** {@inheritDoc} */
31 @Override
32 public final NodeDataInterface getValue(final GtuDataInterface gtu)
33 {
34 Throw.whenNull(gtu, "GTU may not be null.");
35 return gtu.getOriginNodeData();
36 }
37
38 /** {@inheritDoc} */
39 @Override
40 public String formatValue(String format, NodeDataInterface value)
41 {
42 return value.getId();
43 }
44
45 /** {@inheritDoc} */
46 @Override
47 @SuppressWarnings("checkstyle:designforextension")
48 public String toString()
49 {
50 return "MetaDataOrigin: [id=" + getId() + "]";
51 }
52
53 }