1 package org.djunits.unit;
2
3 import static org.djunits.unit.unitsystem.UnitSystem.IMPERIAL;
4 import static org.djunits.unit.unitsystem.UnitSystem.SI_ACCEPTED;
5 import static org.djunits.unit.unitsystem.UnitSystem.SI_DERIVED;
6 import static org.djunits.unit.unitsystem.UnitSystem.US_CUSTOMARY;
7
8 import org.djunits.unit.unitsystem.UnitSystem;
9
10
11
12
13
14
15
16
17
18
19
20 public class FlowVolumeUnit extends LinearUnit<FlowVolumeUnit>
21 {
22
23 private static final long serialVersionUID = 20140607L;
24
25
26 private final LengthUnit lengthUnit;
27
28
29 private final DurationUnit durationUnit;
30
31
32 public static final FlowVolumeUnit SI;
33
34
35 public static final FlowVolumeUnit CUBIC_METER_PER_SECOND;
36
37
38 public static final FlowVolumeUnit CUBIC_METER_PER_MINUTE;
39
40
41 public static final FlowVolumeUnit CUBIC_METER_PER_HOUR;
42
43
44 public static final FlowVolumeUnit CUBIC_METER_PER_DAY;
45
46
47 public static final FlowVolumeUnit LITER_PER_SECOND;
48
49
50 public static final FlowVolumeUnit LITER_PER_MINUTE;
51
52
53 public static final FlowVolumeUnit LITER_PER_HOUR;
54
55
56 public static final FlowVolumeUnit LITER_PER_DAY;
57
58
59 public static final FlowVolumeUnit CUBIC_FEET_PER_SECOND;
60
61
62 public static final FlowVolumeUnit CUBIC_FEET_PER_MINUTE;
63
64
65 public static final FlowVolumeUnit CUBIC_INCH_PER_SECOND;
66
67
68 public static final FlowVolumeUnit CUBIC_INCH_PER_MINUTE;
69
70
71 public static final FlowVolumeUnit GALLON_PER_SECOND;
72
73
74 public static final FlowVolumeUnit GALLON_PER_MINUTE;
75
76
77 public static final FlowVolumeUnit GALLON_PER_HOUR;
78
79
80 public static final FlowVolumeUnit GALLON_PER_DAY;
81
82 static
83 {
84 SI = new FlowVolumeUnit(LengthUnit.METER, DurationUnit.SECOND, "FlowVolumeUnit.cubic_meter_per_second",
85 "FlowVolumeUnit.m^3/s", SI_DERIVED, true);
86 CUBIC_METER_PER_SECOND = SI;
87 CUBIC_METER_PER_MINUTE = new FlowVolumeUnit(LengthUnit.METER, DurationUnit.MINUTE,
88 "FlowVolumeUnit.cubic_meter_per_minute", "FlowVolumeUnit.m^3/min", SI_ACCEPTED, true);
89 CUBIC_METER_PER_HOUR = new FlowVolumeUnit(LengthUnit.METER, DurationUnit.HOUR, "FlowVolumeUnit.cubic_meter_per_hour",
90 "FlowVolumeUnit.m^3/h", SI_ACCEPTED, true);
91 CUBIC_METER_PER_DAY = new FlowVolumeUnit(LengthUnit.METER, DurationUnit.DAY, "FlowVolumeUnit.cubic_meter_per_day",
92 "FlowVolumeUnit.m^3/d", SI_ACCEPTED, true);
93 LITER_PER_SECOND = new FlowVolumeUnit(VolumeUnit.LITER, DurationUnit.SECOND, "FlowVolumeUnit.liter_per_second",
94 "FlowVolumeUnit.L/s", SI_ACCEPTED, true);
95 LITER_PER_MINUTE = new FlowVolumeUnit(VolumeUnit.LITER, DurationUnit.MINUTE, "FlowVolumeUnit.liter_per_minute",
96 "FlowVolumeUnit.L/min", SI_ACCEPTED, true);
97 LITER_PER_HOUR = new FlowVolumeUnit(VolumeUnit.LITER, DurationUnit.HOUR, "FlowVolumeUnit.liter_per_hour",
98 "FlowVolumeUnit.L/h", SI_ACCEPTED, true);
99 LITER_PER_DAY = new FlowVolumeUnit(VolumeUnit.LITER, DurationUnit.DAY, "FlowVolumeUnit.liter_per_day",
100 "FlowVolumeUnit.L/d", SI_ACCEPTED, true);
101 CUBIC_FEET_PER_SECOND = new FlowVolumeUnit(LengthUnit.FOOT, DurationUnit.SECOND, "FlowVolumeUnit.cubic_feet_per_second",
102 "FlowVolumeUnit.ft^3/s", IMPERIAL, true);
103 CUBIC_FEET_PER_MINUTE = new FlowVolumeUnit(LengthUnit.FOOT, DurationUnit.MINUTE, "FlowVolumeUnit.cubic_feet_per_minute",
104 "FlowVolumeUnit.ft^3/min", IMPERIAL, true);
105 CUBIC_INCH_PER_SECOND = new FlowVolumeUnit(LengthUnit.INCH, DurationUnit.SECOND, "FlowVolumeUnit.cubic_inch_per_second",
106 "FlowVolumeUnit.in^3/s", IMPERIAL, true);
107 CUBIC_INCH_PER_MINUTE = new FlowVolumeUnit(LengthUnit.INCH, DurationUnit.MINUTE, "FlowVolumeUnit.cubic_inch_per_minute",
108 "FlowVolumeUnit.in^3/min", IMPERIAL, true);
109 GALLON_PER_SECOND = new FlowVolumeUnit(VolumeUnit.GALLON_US_FLUID, DurationUnit.SECOND,
110 "FlowVolumeUnit.gallon_(US)_per_second", "FlowVolumeUnit.gal/s", US_CUSTOMARY, true);
111 GALLON_PER_MINUTE = new FlowVolumeUnit(VolumeUnit.GALLON_US_FLUID, DurationUnit.MINUTE,
112 "FlowVolumeUnit.gallon_(US)_per_minute", "FlowVolumeUnit.gal/min", US_CUSTOMARY, true);
113 GALLON_PER_HOUR = new FlowVolumeUnit(VolumeUnit.GALLON_US_FLUID, DurationUnit.HOUR,
114 "FlowVolumeUnit.gallon_(US)_per_hour", "FlowVolumeUnit.gal/h", US_CUSTOMARY, true);
115 GALLON_PER_DAY = new FlowVolumeUnit(VolumeUnit.GALLON_US_FLUID, DurationUnit.DAY, "FlowVolumeUnit.gallon_(US)_per_day",
116 "FlowVolumeUnit.gal/d", US_CUSTOMARY, true);
117 }
118
119
120
121
122
123
124
125
126
127
128
129 private FlowVolumeUnit(final LengthUnit lengthUnit, final DurationUnit durationUnit, final String nameOrNameKey,
130 final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem, final boolean standardUnit)
131 {
132 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, CUBIC_METER_PER_SECOND,
133 Math.pow(lengthUnit.getScaleFactor(), 3.0) / durationUnit.getScaleFactor(), standardUnit);
134 this.lengthUnit = lengthUnit;
135 this.durationUnit = durationUnit;
136 }
137
138
139
140
141
142
143
144
145
146 public FlowVolumeUnit(final LengthUnit lengthUnit, final DurationUnit durationUnit, final String name,
147 final String abbreviation, final UnitSystem unitSystem)
148 {
149 this(lengthUnit, durationUnit, name, abbreviation, unitSystem, false);
150 }
151
152
153
154
155
156
157
158
159
160
161
162 private FlowVolumeUnit(final VolumeUnit volumeUnit, final DurationUnit durationUnit, final String nameOrNameKey,
163 final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem, final boolean standardUnit)
164 {
165 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, CUBIC_METER_PER_SECOND,
166 volumeUnit.getScaleFactor() / durationUnit.getScaleFactor(), standardUnit);
167 this.lengthUnit = volumeUnit.getLengthUnit();
168 this.durationUnit = durationUnit;
169 }
170
171
172
173
174
175
176
177
178
179 public FlowVolumeUnit(final VolumeUnit volumeUnit, final DurationUnit durationUnit, final String name,
180 final String abbreviation, final UnitSystem unitSystem)
181 {
182 this(volumeUnit, durationUnit, name, abbreviation, unitSystem, false);
183 }
184
185
186
187
188
189
190
191
192
193
194
195 private FlowVolumeUnit(final String nameOrNameKey, final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem,
196 final FlowVolumeUnit referenceUnit, final double scaleFactorToReferenceUnit, final boolean standardUnit)
197 {
198 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, referenceUnit, scaleFactorToReferenceUnit,
199 standardUnit);
200 this.lengthUnit = referenceUnit.getLengthUnit();
201 this.durationUnit = referenceUnit.getDurationUnit();
202 }
203
204
205
206
207
208
209
210
211
212 public FlowVolumeUnit(final String name, final String abbreviation, final UnitSystem unitSystem,
213 final FlowVolumeUnit referenceUnit, final double scaleFactorToReferenceUnit)
214 {
215 this(name, abbreviation, unitSystem, referenceUnit, scaleFactorToReferenceUnit, false);
216 }
217
218
219
220
221 public final LengthUnit getLengthUnit()
222 {
223 return this.lengthUnit;
224 }
225
226
227
228
229 public final DurationUnit getDurationUnit()
230 {
231 return this.durationUnit;
232 }
233
234
235 @Override
236 public final FlowVolumeUnit getStandardUnit()
237 {
238 return CUBIC_METER_PER_SECOND;
239 }
240
241
242 @Override
243 public final String getSICoefficientsString()
244 {
245 return "m3/s";
246 }
247
248 }