1 package org.opentrafficsim.core.unit;
2
3 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.IMPERIAL;
4 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.MTS;
5 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.SI_ACCEPTED;
6 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.SI_BASE;
7 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.US_CUSTOMARY;
8
9 import org.opentrafficsim.core.unit.unitsystem.UnitSystem;
10
11
12
13
14
15
16
17
18
19
20
21 public class MassUnit extends Unit<MassUnit>
22 {
23
24 private static final long serialVersionUID = 20140607L;
25
26
27 public static final MassUnit SI;
28
29
30 public static final MassUnit KILOGRAM;
31
32
33 public static final MassUnit GRAM;
34
35
36 public static final MassUnit POUND;
37
38
39 public static final MassUnit OUNCE;
40
41
42 public static final MassUnit TON_LONG;
43
44
45 public static final MassUnit TON_SHORT;
46
47
48 public static final MassUnit TON_METRIC;
49
50
51 public static final MassUnit TONNE;
52
53
54 public static final MassUnit ELECTRONVOLT;
55
56
57 public static final MassUnit DALTON;
58
59 static
60 {
61 SI = new MassUnit("MassUnit.kilogram", "MassUnit.kg", SI_BASE);
62 KILOGRAM = SI;
63 GRAM = new MassUnit("MassUnit.gram", "MassUnit.g", SI_BASE, KILOGRAM, 0.001);
64 POUND = new MassUnit("MassUnit.pound", "MassUnit.lb", IMPERIAL, KILOGRAM, 0.45359237);
65 OUNCE = new MassUnit("MassUnit.ounce", "MassUnit.oz", IMPERIAL, POUND, 1.0 / 16.0);
66 TON_LONG = new MassUnit("MassUnit.long_ton", "MassUnit.long_tn", IMPERIAL, POUND, 2240.0);
67 TON_SHORT = new MassUnit("MassUnit.short_ton", "MassUnit.sh_tn", US_CUSTOMARY, POUND, 2000.0);
68 TON_METRIC = new MassUnit("MassUnit.metric_ton", "MassUnit.t", SI_ACCEPTED, KILOGRAM, 1000.0);
69 TONNE = new MassUnit("MassUnit.tonne_(mts)", "MassUnit.t_(mts)", MTS, KILOGRAM, 1000.0);
70 ELECTRONVOLT = new MassUnit("MassUnit.electronvolt", "MassUnit.eV", SI_ACCEPTED, KILOGRAM, 1.78266184539E-36);
71 DALTON = new MassUnit("MassUnit.dalton", "MassUnit.Da", SI_ACCEPTED, KILOGRAM, 1.6605388628E-27);
72 }
73
74
75
76
77
78
79
80 public MassUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem)
81 {
82 super(nameKey, abbreviationKey, unitSystem, true);
83 }
84
85
86
87
88
89
90
91
92
93
94 public MassUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem,
95 final MassUnit referenceUnit, final double conversionFactorToReferenceUnit)
96 {
97 super(nameKey, abbreviationKey, unitSystem, referenceUnit, conversionFactorToReferenceUnit, true);
98 }
99
100
101 @Override
102 public final MassUnit getStandardUnit()
103 {
104 return KILOGRAM;
105 }
106
107
108 @Override
109 public final String getSICoefficientsString()
110 {
111 return "kg";
112 }
113
114 }