1 package org.opentrafficsim.core.value;
2
3 import java.io.Serializable;
4
5 import org.opentrafficsim.core.unit.Unit;
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 public abstract class Scalar<U extends Unit<U>> extends Number implements Value<U>, Serializable
21 {
22
23 private static final long serialVersionUID = 20150309L;
24
25
26 private final U unit;
27
28
29
30
31
32 public Scalar(final U unit)
33 {
34 this.unit = unit;
35 }
36
37
38 @Override
39 public final U getUnit()
40 {
41 return this.unit;
42 }
43
44
45 @Override
46 public final double expressAsSIUnit(final double value)
47 {
48 return ValueUtil.expressAsSIUnit(value, this.unit);
49 }
50
51
52
53
54
55
56 protected final double expressAsSpecifiedUnit(final double value)
57 {
58 return ValueUtil.expressAsUnit(value, this.unit);
59 }
60
61
62 @Override
63 public final boolean isAbsolute()
64 {
65 return this instanceof Absolute;
66 }
67
68
69 @Override
70 public final boolean isRelative()
71 {
72 return this instanceof Relative;
73 }
74
75 }