1 package org.djunits.value.vfloat.scalar;
2
3 import java.util.Locale;
4
5 import org.djunits.unit.AreaUnit;
6 import org.djunits.unit.DimensionlessUnit;
7 import org.djunits.unit.FlowMassUnit;
8 import org.djunits.unit.FlowVolumeUnit;
9 import org.djunits.unit.FrequencyUnit;
10 import org.djunits.unit.SpeedUnit;
11 import org.djunits.unit.VolumeUnit;
12 import org.djunits.value.vfloat.scalar.base.FloatScalar;
13 import org.djunits.value.vfloat.scalar.base.FloatScalarRel;
14 import org.djutils.base.NumberParser;
15 import org.djutils.exceptions.Throw;
16
17 import jakarta.annotation.Generated;
18
19
20
21
22
23
24
25
26
27
28 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
29 public class FloatFlowVolume extends FloatScalarRel<FlowVolumeUnit, FloatFlowVolume>
30 {
31
32 private static final long serialVersionUID = 20150901L;
33
34
35 public static final FloatFlowVolume ZERO = new FloatFlowVolume(0.0f, FlowVolumeUnit.SI);
36
37
38 public static final FloatFlowVolume ONE = new FloatFlowVolume(1.0f, FlowVolumeUnit.SI);
39
40
41 @SuppressWarnings("checkstyle:constantname")
42 public static final FloatFlowVolume NaN = new FloatFlowVolume(Float.NaN, FlowVolumeUnit.SI);
43
44
45 public static final FloatFlowVolume POSITIVE_INFINITY = new FloatFlowVolume(Float.POSITIVE_INFINITY, FlowVolumeUnit.SI);
46
47
48 public static final FloatFlowVolume NEGATIVE_INFINITY = new FloatFlowVolume(Float.NEGATIVE_INFINITY, FlowVolumeUnit.SI);
49
50
51 public static final FloatFlowVolume POS_MAXVALUE = new FloatFlowVolume(Float.MAX_VALUE, FlowVolumeUnit.SI);
52
53
54 public static final FloatFlowVolume NEG_MAXVALUE = new FloatFlowVolume(-Float.MAX_VALUE, FlowVolumeUnit.SI);
55
56
57
58
59
60
61 public FloatFlowVolume(final float value, final FlowVolumeUnit unit)
62 {
63 super(value, unit);
64 }
65
66
67
68
69
70 public FloatFlowVolume(final FloatFlowVolume value)
71 {
72 super(value);
73 }
74
75
76
77
78
79
80 public FloatFlowVolume(final double value, final FlowVolumeUnit unit)
81 {
82 super((float) value, unit);
83 }
84
85 @Override
86 public final FloatFlowVolume instantiateRel(final float value, final FlowVolumeUnit unit)
87 {
88 return new FloatFlowVolume(value, unit);
89 }
90
91
92
93
94
95
96 public static final FloatFlowVolume instantiateSI(final float value)
97 {
98 return new FloatFlowVolume(value, FlowVolumeUnit.SI);
99 }
100
101
102
103
104
105
106
107
108 public static FloatFlowVolume interpolate(final FloatFlowVolume zero, final FloatFlowVolume one, final float ratio)
109 {
110 return new FloatFlowVolume(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
111 zero.getDisplayUnit());
112 }
113
114
115
116
117
118
119
120 public static FloatFlowVolume max(final FloatFlowVolume r1, final FloatFlowVolume r2)
121 {
122 return r1.gt(r2) ? r1 : r2;
123 }
124
125
126
127
128
129
130
131
132 public static FloatFlowVolume max(final FloatFlowVolume r1, final FloatFlowVolume r2, final FloatFlowVolume... rn)
133 {
134 FloatFlowVolume maxr = r1.gt(r2) ? r1 : r2;
135 for (FloatFlowVolume r : rn)
136 {
137 if (r.gt(maxr))
138 {
139 maxr = r;
140 }
141 }
142 return maxr;
143 }
144
145
146
147
148
149
150
151 public static FloatFlowVolume min(final FloatFlowVolume r1, final FloatFlowVolume r2)
152 {
153 return r1.lt(r2) ? r1 : r2;
154 }
155
156
157
158
159
160
161
162
163 public static FloatFlowVolume min(final FloatFlowVolume r1, final FloatFlowVolume r2, final FloatFlowVolume... rn)
164 {
165 FloatFlowVolume minr = r1.lt(r2) ? r1 : r2;
166 for (FloatFlowVolume r : rn)
167 {
168 if (r.lt(minr))
169 {
170 minr = r;
171 }
172 }
173 return minr;
174 }
175
176
177
178
179
180
181
182
183
184
185 public static FloatFlowVolume valueOf(final String text)
186 {
187 Throw.whenNull(text, "Error parsing FloatFlowVolume: text to parse is null");
188 Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing FloatFlowVolume: empty text to parse");
189 try
190 {
191 NumberParser numberParser = new NumberParser().lenient().trailing();
192 float f = numberParser.parseFloat(text);
193 String unitString = text.substring(numberParser.getTrailingPosition()).trim();
194 FlowVolumeUnit unit = FlowVolumeUnit.BASE.getUnitByAbbreviation(unitString);
195 if (unit == null)
196 throw new IllegalArgumentException("Unit " + unitString + " not found");
197 return new FloatFlowVolume(f, unit);
198 }
199 catch (Exception exception)
200 {
201 throw new IllegalArgumentException(
202 "Error parsing FloatFlowVolume from " + text + " using Locale " + Locale.getDefault(Locale.Category.FORMAT),
203 exception);
204 }
205 }
206
207
208
209
210
211
212
213
214
215 public static FloatFlowVolume of(final float value, final String unitString)
216 {
217 Throw.whenNull(unitString, "Error parsing FloatFlowVolume: unitString is null");
218 Throw.when(unitString.length() == 0, IllegalArgumentException.class, "Error parsing FloatFlowVolume: empty unitString");
219 FlowVolumeUnit unit = FlowVolumeUnit.BASE.getUnitByAbbreviation(unitString);
220 if (unit != null)
221 {
222 return new FloatFlowVolume(value, unit);
223 }
224 throw new IllegalArgumentException("Error parsing FloatFlowVolume with unit " + unitString);
225 }
226
227
228
229
230
231
232 public final FloatDimensionless divide(final FloatFlowVolume v)
233 {
234 return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
235 }
236
237
238
239
240
241
242 public final FloatVolume times(final FloatDuration v)
243 {
244 return new FloatVolume(this.si * v.si, VolumeUnit.SI);
245 }
246
247
248
249
250
251
252 public final FloatVolume divide(final FloatFrequency v)
253 {
254 return new FloatVolume(this.si / v.si, VolumeUnit.SI);
255 }
256
257
258
259
260
261
262 public final FloatFrequency divide(final FloatVolume v)
263 {
264 return new FloatFrequency(this.si / v.si, FrequencyUnit.SI);
265 }
266
267
268
269
270
271
272 public final FloatSpeed divide(final FloatArea v)
273 {
274 return new FloatSpeed(this.si / v.si, SpeedUnit.SI);
275 }
276
277
278
279
280
281
282 public final FloatArea divide(final FloatSpeed v)
283 {
284 return new FloatArea(this.si / v.si, AreaUnit.SI);
285 }
286
287
288
289
290
291
292 public final FloatFlowMass times(final FloatDensity v)
293 {
294 return new FloatFlowMass(this.si * v.si, FlowMassUnit.SI);
295 }
296
297 @Override
298 public FloatSIScalar reciprocal()
299 {
300 return FloatScalar.divide(FloatDimensionless.ONE, this);
301 }
302
303 }