1 package org.opentrafficsim.road.network.sampling;
2
3 import org.opentrafficsim.core.network.route.Route;
4 import org.opentrafficsim.kpi.interfaces.RouteDataInterface;
5
6 /**
7 * Route representation in road sampler.
8 * <p>
9 * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
10 * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
11 * <p>
12 * @version $Revision$, $LastChangedDate$, by $Author$, initial version 13 okt. 2016 <br>
13 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
14 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
15 * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
16 */
17 public class RouteData implements RouteDataInterface
18 {
19
20 /** Route. */
21 private final Route route;
22
23 /**
24 * @param route Route; route
25 */
26 public RouteData(final Route route)
27 {
28 this.route = route;
29 }
30
31 /**
32 * @return route.
33 */
34 public final Route getRoute()
35 {
36 return this.route;
37 }
38
39 /** {@inheritDoc} */
40 @Override
41 public final String getId()
42 {
43 return this.route.getId();
44 }
45
46 /** {@inheritDoc} */
47 @Override
48 public final int hashCode()
49 {
50 final int prime = 31;
51 int result = 1;
52 result = prime * result + ((this.route == null) ? 0 : this.route.hashCode());
53 return result;
54 }
55
56 /** {@inheritDoc} */
57 @Override
58 public final boolean equals(final Object obj)
59 {
60 if (this == obj)
61 {
62 return true;
63 }
64 if (obj == null)
65 {
66 return false;
67 }
68 if (getClass() != obj.getClass())
69 {
70 return false;
71 }
72 RouteData other = (RouteData) obj;
73 if (this.route == null)
74 {
75 if (other.route != null)
76 {
77 return false;
78 }
79 }
80 else if (!this.route.equals(other.route))
81 {
82 return false;
83 }
84 return true;
85 }
86
87 /** {@inheritDoc} */
88 @Override
89 public final String toString()
90 {
91 return "RouteData [route=" + this.route + "]";
92 }
93
94 }