1 package org.opentrafficsim.xml.bindings.types;
2
3 import org.djunits.value.vdouble.scalar.Length;
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 public class LengthBeginEnd
20 {
21
22 private final boolean begin;
23
24
25 private final boolean absolute;
26
27
28 private final Length offset;
29
30
31 private final double fraction;
32
33
34
35
36
37 public LengthBeginEnd(final boolean begin, final Length offset)
38 {
39 this.begin = begin;
40 this.absolute = true;
41 this.offset = offset;
42 this.fraction = 0.0;
43 }
44
45
46
47
48 public LengthBeginEnd(final double fraction)
49 {
50 this.begin = true;
51 this.absolute = false;
52 this.offset = Length.ZERO;
53 this.fraction = fraction;
54 }
55
56
57
58
59 public final boolean isBegin()
60 {
61 return this.begin;
62 }
63
64
65
66
67 public final boolean isAbsolute()
68 {
69 return this.absolute;
70 }
71
72
73
74
75 public final Length getOffset()
76 {
77 return this.offset;
78 }
79
80
81
82
83 public final double getFraction()
84 {
85 return this.fraction;
86 }
87
88
89 @Override
90 public int hashCode()
91 {
92 final int prime = 31;
93 int result = 1;
94 result = prime * result + (this.absolute ? 1231 : 1237);
95 result = prime * result + (this.begin ? 1231 : 1237);
96 long temp;
97 temp = Double.doubleToLongBits(this.fraction);
98 result = prime * result + (int) (temp ^ (temp >>> 32));
99 result = prime * result + ((this.offset == null) ? 0 : this.offset.hashCode());
100 return result;
101 }
102
103
104 @Override
105 public boolean equals(Object obj)
106 {
107 if (this == obj)
108 return true;
109 if (obj == null)
110 return false;
111 if (getClass() != obj.getClass())
112 return false;
113 LengthBeginEnd other = (LengthBeginEnd) obj;
114 if (this.absolute != other.absolute)
115 return false;
116 if (this.begin != other.begin)
117 return false;
118 if (Double.doubleToLongBits(this.fraction) != Double.doubleToLongBits(other.fraction))
119 return false;
120 if (this.offset == null)
121 {
122 if (other.offset != null)
123 return false;
124 }
125 else if (!this.offset.equals(other.offset))
126 return false;
127 return true;
128 }
129
130
131 @Override
132 public String toString()
133 {
134 return "LengthBeginEnd [begin=" + this.begin + ", absolute=" + this.absolute + ", offset=" + this.offset + ", fraction="
135 + this.fraction + "]";
136 }
137
138 }