1 package org.opentrafficsim.road.network.lane;
2
3 import java.io.Serializable;
4
5 import org.opentrafficsim.core.gtu.GTUDirectionality;
6
7
8
9
10
11
12
13
14
15
16
17 public class LaneDirection implements Serializable
18 {
19
20 private static final long serialVersionUID = 20160330L;
21
22
23 private final Lane lane;
24
25
26 private final GTUDirectionality direction;
27
28
29
30
31
32 public LaneDirection(final Lane lane, final GTUDirectionality direction)
33 {
34 super();
35 this.lane = lane;
36 this.direction = direction;
37 }
38
39
40
41
42 public final Lane getLane()
43 {
44 return this.lane;
45 }
46
47
48
49
50 public final GTUDirectionality getDirection()
51 {
52 return this.direction;
53 }
54
55
56 @Override
57 public String toString()
58 {
59 return "[" + this.lane + (this.direction.isPlus() ? " +]" : " -]");
60 }
61
62
63 @Override
64 public final int hashCode()
65 {
66 final int prime = 31;
67 int result = 1;
68 result = prime * result + ((this.direction == null) ? 0 : this.direction.hashCode());
69 result = prime * result + ((this.lane == null) ? 0 : this.lane.hashCode());
70 return result;
71 }
72
73
74 @Override
75 public final boolean equals(final Object obj)
76 {
77 if (this == obj)
78 {
79 return true;
80 }
81 if (obj == null)
82 {
83 return false;
84 }
85 if (getClass() != obj.getClass())
86 {
87 return false;
88 }
89 LaneDirection other = (LaneDirection) obj;
90 if (this.direction != other.direction)
91 {
92 return false;
93 }
94 if (this.lane == null)
95 {
96 if (other.lane != null)
97 {
98 return false;
99 }
100 }
101 else if (!this.lane.equals(other.lane))
102 {
103 return false;
104 }
105 return true;
106 }
107
108 }