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