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