1 package org.djunits.value.vfloat.scalar;
2
3 import java.util.Locale;
4
5 import org.djunits.unit.AbsorbedDoseUnit;
6 import org.djunits.unit.AccelerationUnit;
7 import org.djunits.unit.AmountOfSubstanceUnit;
8 import org.djunits.unit.AngleUnit;
9 import org.djunits.unit.AngularAccelerationUnit;
10 import org.djunits.unit.AngularVelocityUnit;
11 import org.djunits.unit.AreaUnit;
12 import org.djunits.unit.CatalyticActivityUnit;
13 import org.djunits.unit.DensityUnit;
14 import org.djunits.unit.DimensionlessUnit;
15 import org.djunits.unit.DurationUnit;
16 import org.djunits.unit.ElectricalCapacitanceUnit;
17 import org.djunits.unit.ElectricalChargeUnit;
18 import org.djunits.unit.ElectricalConductanceUnit;
19 import org.djunits.unit.ElectricalCurrentUnit;
20 import org.djunits.unit.ElectricalInductanceUnit;
21 import org.djunits.unit.ElectricalPotentialUnit;
22 import org.djunits.unit.ElectricalResistanceUnit;
23 import org.djunits.unit.EnergyUnit;
24 import org.djunits.unit.EquivalentDoseUnit;
25 import org.djunits.unit.FlowMassUnit;
26 import org.djunits.unit.FlowVolumeUnit;
27 import org.djunits.unit.ForceUnit;
28 import org.djunits.unit.FrequencyUnit;
29 import org.djunits.unit.IlluminanceUnit;
30 import org.djunits.unit.LengthUnit;
31 import org.djunits.unit.LinearDensityUnit;
32 import org.djunits.unit.LuminousFluxUnit;
33 import org.djunits.unit.LuminousIntensityUnit;
34 import org.djunits.unit.MagneticFluxDensityUnit;
35 import org.djunits.unit.MagneticFluxUnit;
36 import org.djunits.unit.MassUnit;
37 import org.djunits.unit.MomentumUnit;
38 import org.djunits.unit.PowerUnit;
39 import org.djunits.unit.PressureUnit;
40 import org.djunits.unit.RadioActivityUnit;
41 import org.djunits.unit.SIUnit;
42 import org.djunits.unit.SolidAngleUnit;
43 import org.djunits.unit.SpeedUnit;
44 import org.djunits.unit.TemperatureUnit;
45 import org.djunits.unit.TorqueUnit;
46 import org.djunits.unit.Unit;
47 import org.djunits.unit.VolumeUnit;
48 import org.djunits.unit.si.SIDimensions;
49 import org.djunits.unit.util.UnitRuntimeException;
50 import org.djunits.value.vfloat.scalar.base.FloatScalar;
51 import org.djunits.value.vfloat.scalar.base.FloatScalarRel;
52 import org.djutils.base.NumberParser;
53 import org.djutils.exceptions.Throw;
54
55 import jakarta.annotation.Generated;
56
57
58
59
60
61
62
63
64
65
66
67 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
68 public class FloatSIScalar extends FloatScalarRel<SIUnit, FloatSIScalar>
69 {
70
71 private static final long serialVersionUID = 20150901L;
72
73
74
75
76
77
78 public FloatSIScalar(final float value, final SIUnit unit)
79 {
80 super(value, unit);
81 }
82
83
84
85
86
87 public FloatSIScalar(final FloatSIScalar value)
88 {
89 super(value);
90 }
91
92 @Override
93 public final FloatSIScalar instantiateRel(final float value, final SIUnit unit)
94 {
95 return new FloatSIScalar(value, unit);
96 }
97
98
99
100
101
102
103
104 public static final FloatSIScalar instantiateSI(final float value, final SIUnit unit)
105 {
106 return new FloatSIScalar(value, unit);
107 }
108
109
110
111
112
113
114
115
116 public static FloatSIScalar interpolate(final FloatSIScalar zero, final FloatSIScalar one, final float ratio)
117 {
118 return new FloatSIScalar(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
119 zero.getDisplayUnit());
120 }
121
122
123
124
125
126
127
128 public static FloatSIScalar max(final FloatSIScalar r1, final FloatSIScalar r2)
129 {
130 return r1.gt(r2) ? r1 : r2;
131 }
132
133
134
135
136
137
138
139
140 public static FloatSIScalar max(final FloatSIScalar r1, final FloatSIScalar r2, final FloatSIScalar... rn)
141 {
142 FloatSIScalar maxr = r1.gt(r2) ? r1 : r2;
143 for (FloatSIScalar r : rn)
144 {
145 if (r.gt(maxr))
146 {
147 maxr = r;
148 }
149 }
150 return maxr;
151 }
152
153
154
155
156
157
158
159 public static FloatSIScalar min(final FloatSIScalar r1, final FloatSIScalar r2)
160 {
161 return r1.lt(r2) ? r1 : r2;
162 }
163
164
165
166
167
168
169
170
171 public static FloatSIScalar min(final FloatSIScalar r1, final FloatSIScalar r2, final FloatSIScalar... rn)
172 {
173 FloatSIScalar minr = r1.lt(r2) ? r1 : r2;
174 for (FloatSIScalar r : rn)
175 {
176 if (r.lt(minr))
177 {
178 minr = r;
179 }
180 }
181 return minr;
182 }
183
184 @Override
185 public FloatSIScalar reciprocal()
186 {
187 return FloatScalar.divide(FloatDimensionless.ONE, this);
188 }
189
190
191
192
193
194
195
196
197
198
199 public static FloatSIScalar valueOf(final String text)
200 {
201 Throw.whenNull(text, "Error parsing SIScalar: unitString is null");
202 Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing SIScalar: empty unitString");
203 try
204 {
205 NumberParser numberParser = new NumberParser().lenient().trailing();
206 float f = numberParser.parseFloat(text);
207 String unitString = text.substring(numberParser.getTrailingPosition()).trim();
208 SIUnit unit = Unit.lookupOrCreateUnitWithSIDimensions(SIDimensions.of(unitString));
209 if (unit == null)
210 throw new IllegalArgumentException("Unit " + unitString + " for FloatSIScalar not found");
211 return new FloatSIScalar(f, unit);
212 }
213 catch (Exception exception)
214 {
215 throw new IllegalArgumentException(
216 "Error parsing FloatSIScalar from " + text + " using Locale " + Locale.getDefault(Locale.Category.FORMAT),
217 exception);
218 }
219 }
220
221
222
223
224
225
226
227
228
229 public static FloatSIScalar of(final float value, final String unitString)
230 {
231 Throw.whenNull(unitString, "Error parsing FloatSIScalar: unitString is null");
232 try
233 {
234 SIUnit unit = Unit.lookupOrCreateUnitWithSIDimensions(SIDimensions.of(unitString));
235 if (unit != null)
236 {
237 return new FloatSIScalar(value, unit);
238 }
239 }
240 catch (Exception exception)
241 {
242 throw new IllegalArgumentException("Error parsing SIUnit from " + unitString, exception);
243 }
244 throw new IllegalArgumentException("Error parsing FloatSIScalar with unit " + unitString);
245 }
246
247 @Override
248 public String toString(final SIUnit displayUnit, final boolean verbose, final boolean withUnit)
249 {
250 return super.toString(displayUnit, verbose, withUnit).replaceAll("!", "");
251 }
252
253
254
255
256
257
258
259
260
261
262
263
264
265 public final <U extends Unit<U>, S extends FloatScalarRel<U, S>> S as(final U displayUnit)
266 {
267 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(displayUnit.getQuantity().getSiDimensions())),
268 UnitRuntimeException.class, "FloatSIScalar with unit %s cannot be converted to a scalar with unit %s",
269 getDisplayUnit(), displayUnit);
270 S result = FloatScalar.instantiate(this.si, displayUnit.getStandardUnit());
271 result.setDisplayUnit(displayUnit);
272 return result;
273 }
274
275
276
277
278
279 public final FloatAbsorbedDose asAbsorbedDose()
280 {
281 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AbsorbedDoseUnit.BASE.getSiDimensions())),
282 UnitRuntimeException.class, "cannot cast %s to FloatAbsorbedDose", this.toString());
283 return new FloatAbsorbedDose(getSI(), AbsorbedDoseUnit.SI);
284 }
285
286
287
288
289
290
291 public final FloatAbsorbedDose asAbsorbedDose(final AbsorbedDoseUnit displayUnit)
292 {
293 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AbsorbedDoseUnit.BASE.getSiDimensions())),
294 UnitRuntimeException.class, "cannot cast %s to FloatAbsorbedDose", this.toString());
295 FloatAbsorbedDose result = new FloatAbsorbedDose(getSI(), displayUnit.getStandardUnit());
296 result.setDisplayUnit(displayUnit);
297 return result;
298 }
299
300
301
302
303
304 public final FloatAcceleration asAcceleration()
305 {
306 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AccelerationUnit.BASE.getSiDimensions())),
307 UnitRuntimeException.class, "cannot cast %s to FloatAcceleration", this.toString());
308 return new FloatAcceleration(getSI(), AccelerationUnit.SI);
309 }
310
311
312
313
314
315
316 public final FloatAcceleration asAcceleration(final AccelerationUnit displayUnit)
317 {
318 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AccelerationUnit.BASE.getSiDimensions())),
319 UnitRuntimeException.class, "cannot cast %s to FloatAcceleration", this.toString());
320 FloatAcceleration result = new FloatAcceleration(getSI(), displayUnit.getStandardUnit());
321 result.setDisplayUnit(displayUnit);
322 return result;
323 }
324
325
326
327
328
329 public final FloatAmountOfSubstance asAmountOfSubstance()
330 {
331 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AmountOfSubstanceUnit.BASE.getSiDimensions())),
332 UnitRuntimeException.class, "cannot cast %s to FloatAmountOfSubstance", this.toString());
333 return new FloatAmountOfSubstance(getSI(), AmountOfSubstanceUnit.SI);
334 }
335
336
337
338
339
340
341 public final FloatAmountOfSubstance asAmountOfSubstance(final AmountOfSubstanceUnit displayUnit)
342 {
343 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AmountOfSubstanceUnit.BASE.getSiDimensions())),
344 UnitRuntimeException.class, "cannot cast %s to FloatAmountOfSubstance", this.toString());
345 FloatAmountOfSubstance result = new FloatAmountOfSubstance(getSI(), displayUnit.getStandardUnit());
346 result.setDisplayUnit(displayUnit);
347 return result;
348 }
349
350
351
352
353
354 public final FloatAngularAcceleration asAngularAcceleration()
355 {
356 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularAccelerationUnit.BASE.getSiDimensions())),
357 UnitRuntimeException.class, "cannot cast %s to FloatAngularAcceleration", this.toString());
358 return new FloatAngularAcceleration(getSI(), AngularAccelerationUnit.SI);
359 }
360
361
362
363
364
365
366 public final FloatAngularAcceleration asAngularAcceleration(final AngularAccelerationUnit displayUnit)
367 {
368 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularAccelerationUnit.BASE.getSiDimensions())),
369 UnitRuntimeException.class, "cannot cast %s to FloatAngularAcceleration", this.toString());
370 FloatAngularAcceleration result = new FloatAngularAcceleration(getSI(), displayUnit.getStandardUnit());
371 result.setDisplayUnit(displayUnit);
372 return result;
373 }
374
375
376
377
378
379 public final FloatAngularVelocity asAngularVelocity()
380 {
381 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularVelocityUnit.BASE.getSiDimensions())),
382 UnitRuntimeException.class, "cannot cast %s to FloatAngularVelocity", this.toString());
383 return new FloatAngularVelocity(getSI(), AngularVelocityUnit.SI);
384 }
385
386
387
388
389
390
391 public final FloatAngularVelocity asAngularVelocity(final AngularVelocityUnit displayUnit)
392 {
393 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularVelocityUnit.BASE.getSiDimensions())),
394 UnitRuntimeException.class, "cannot cast %s to FloatAngularVelocity", this.toString());
395 FloatAngularVelocity result = new FloatAngularVelocity(getSI(), displayUnit.getStandardUnit());
396 result.setDisplayUnit(displayUnit);
397 return result;
398 }
399
400
401
402
403
404 public final FloatArea asArea()
405 {
406 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AreaUnit.BASE.getSiDimensions())),
407 UnitRuntimeException.class, "cannot cast %s to FloatArea", this.toString());
408 return new FloatArea(getSI(), AreaUnit.SI);
409 }
410
411
412
413
414
415
416 public final FloatArea asArea(final AreaUnit displayUnit)
417 {
418 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AreaUnit.BASE.getSiDimensions())),
419 UnitRuntimeException.class, "cannot cast %s to FloatArea", this.toString());
420 FloatArea result = new FloatArea(getSI(), displayUnit.getStandardUnit());
421 result.setDisplayUnit(displayUnit);
422 return result;
423 }
424
425
426
427
428
429 public final FloatCatalyticActivity asCatalyticActivity()
430 {
431 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(CatalyticActivityUnit.BASE.getSiDimensions())),
432 UnitRuntimeException.class, "cannot cast %s to FloatCatalyticActivity", this.toString());
433 return new FloatCatalyticActivity(getSI(), CatalyticActivityUnit.SI);
434 }
435
436
437
438
439
440
441 public final FloatCatalyticActivity asCatalyticActivity(final CatalyticActivityUnit displayUnit)
442 {
443 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(CatalyticActivityUnit.BASE.getSiDimensions())),
444 UnitRuntimeException.class, "cannot cast %s to FloatCatalyticActivity", this.toString());
445 FloatCatalyticActivity result = new FloatCatalyticActivity(getSI(), displayUnit.getStandardUnit());
446 result.setDisplayUnit(displayUnit);
447 return result;
448 }
449
450
451
452
453
454 public final FloatDensity asDensity()
455 {
456 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DensityUnit.BASE.getSiDimensions())),
457 UnitRuntimeException.class, "cannot cast %s to FloatDensity", this.toString());
458 return new FloatDensity(getSI(), DensityUnit.SI);
459 }
460
461
462
463
464
465
466 public final FloatDensity asDensity(final DensityUnit displayUnit)
467 {
468 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DensityUnit.BASE.getSiDimensions())),
469 UnitRuntimeException.class, "cannot cast %s to FloatDensity", this.toString());
470 FloatDensity result = new FloatDensity(getSI(), displayUnit.getStandardUnit());
471 result.setDisplayUnit(displayUnit);
472 return result;
473 }
474
475
476
477
478
479 public final FloatDimensionless asDimensionless()
480 {
481 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DimensionlessUnit.BASE.getSiDimensions())),
482 UnitRuntimeException.class, "cannot cast %s to FloatDimensionless", this.toString());
483 return new FloatDimensionless(getSI(), DimensionlessUnit.SI);
484 }
485
486
487
488
489
490
491 public final FloatDimensionless asDimensionless(final DimensionlessUnit displayUnit)
492 {
493 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DimensionlessUnit.BASE.getSiDimensions())),
494 UnitRuntimeException.class, "cannot cast %s to FloatDimensionless", this.toString());
495 FloatDimensionless result = new FloatDimensionless(getSI(), displayUnit.getStandardUnit());
496 result.setDisplayUnit(displayUnit);
497 return result;
498 }
499
500
501
502
503
504 public final FloatElectricalCapacitance asElectricalCapacitance()
505 {
506 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCapacitanceUnit.BASE.getSiDimensions())),
507 UnitRuntimeException.class, "cannot cast %s to FloatElectricalCapacitance", this.toString());
508 return new FloatElectricalCapacitance(getSI(), ElectricalCapacitanceUnit.SI);
509 }
510
511
512
513
514
515
516 public final FloatElectricalCapacitance asElectricalCapacitance(final ElectricalCapacitanceUnit displayUnit)
517 {
518 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCapacitanceUnit.BASE.getSiDimensions())),
519 UnitRuntimeException.class, "cannot cast %s to FloatElectricalCapacitance", this.toString());
520 FloatElectricalCapacitance result = new FloatElectricalCapacitance(getSI(), displayUnit.getStandardUnit());
521 result.setDisplayUnit(displayUnit);
522 return result;
523 }
524
525
526
527
528
529 public final FloatElectricalCharge asElectricalCharge()
530 {
531 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalChargeUnit.BASE.getSiDimensions())),
532 UnitRuntimeException.class, "cannot cast %s to FloatElectricalCharge", this.toString());
533 return new FloatElectricalCharge(getSI(), ElectricalChargeUnit.SI);
534 }
535
536
537
538
539
540
541 public final FloatElectricalCharge asElectricalCharge(final ElectricalChargeUnit displayUnit)
542 {
543 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalChargeUnit.BASE.getSiDimensions())),
544 UnitRuntimeException.class, "cannot cast %s to FloatElectricalCharge", this.toString());
545 FloatElectricalCharge result = new FloatElectricalCharge(getSI(), displayUnit.getStandardUnit());
546 result.setDisplayUnit(displayUnit);
547 return result;
548 }
549
550
551
552
553
554 public final FloatElectricalConductance asElectricalConductance()
555 {
556 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalConductanceUnit.BASE.getSiDimensions())),
557 UnitRuntimeException.class, "cannot cast %s to FloatElectricalConductance", this.toString());
558 return new FloatElectricalConductance(getSI(), ElectricalConductanceUnit.SI);
559 }
560
561
562
563
564
565
566 public final FloatElectricalConductance asElectricalConductance(final ElectricalConductanceUnit displayUnit)
567 {
568 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalConductanceUnit.BASE.getSiDimensions())),
569 UnitRuntimeException.class, "cannot cast %s to FloatElectricalConductance", this.toString());
570 FloatElectricalConductance result = new FloatElectricalConductance(getSI(), displayUnit.getStandardUnit());
571 result.setDisplayUnit(displayUnit);
572 return result;
573 }
574
575
576
577
578
579 public final FloatElectricalCurrent asElectricalCurrent()
580 {
581 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCurrentUnit.BASE.getSiDimensions())),
582 UnitRuntimeException.class, "cannot cast %s to FloatElectricalCurrent", this.toString());
583 return new FloatElectricalCurrent(getSI(), ElectricalCurrentUnit.SI);
584 }
585
586
587
588
589
590
591 public final FloatElectricalCurrent asElectricalCurrent(final ElectricalCurrentUnit displayUnit)
592 {
593 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCurrentUnit.BASE.getSiDimensions())),
594 UnitRuntimeException.class, "cannot cast %s to FloatElectricalCurrent", this.toString());
595 FloatElectricalCurrent result = new FloatElectricalCurrent(getSI(), displayUnit.getStandardUnit());
596 result.setDisplayUnit(displayUnit);
597 return result;
598 }
599
600
601
602
603
604 public final FloatElectricalInductance asElectricalInductance()
605 {
606 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalInductanceUnit.BASE.getSiDimensions())),
607 UnitRuntimeException.class, "cannot cast %s to FloatElectricalInductance", this.toString());
608 return new FloatElectricalInductance(getSI(), ElectricalInductanceUnit.SI);
609 }
610
611
612
613
614
615
616 public final FloatElectricalInductance asElectricalInductance(final ElectricalInductanceUnit displayUnit)
617 {
618 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalInductanceUnit.BASE.getSiDimensions())),
619 UnitRuntimeException.class, "cannot cast %s to FloatElectricalInductance", this.toString());
620 FloatElectricalInductance result = new FloatElectricalInductance(getSI(), displayUnit.getStandardUnit());
621 result.setDisplayUnit(displayUnit);
622 return result;
623 }
624
625
626
627
628
629 public final FloatElectricalPotential asElectricalPotential()
630 {
631 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalPotentialUnit.BASE.getSiDimensions())),
632 UnitRuntimeException.class, "cannot cast %s to FloatElectricalPotential", this.toString());
633 return new FloatElectricalPotential(getSI(), ElectricalPotentialUnit.SI);
634 }
635
636
637
638
639
640
641 public final FloatElectricalPotential asElectricalPotential(final ElectricalPotentialUnit displayUnit)
642 {
643 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalPotentialUnit.BASE.getSiDimensions())),
644 UnitRuntimeException.class, "cannot cast %s to FloatElectricalPotential", this.toString());
645 FloatElectricalPotential result = new FloatElectricalPotential(getSI(), displayUnit.getStandardUnit());
646 result.setDisplayUnit(displayUnit);
647 return result;
648 }
649
650
651
652
653
654 public final FloatElectricalResistance asElectricalResistance()
655 {
656 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalResistanceUnit.BASE.getSiDimensions())),
657 UnitRuntimeException.class, "cannot cast %s to FloatElectricalResistance", this.toString());
658 return new FloatElectricalResistance(getSI(), ElectricalResistanceUnit.SI);
659 }
660
661
662
663
664
665
666 public final FloatElectricalResistance asElectricalResistance(final ElectricalResistanceUnit displayUnit)
667 {
668 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalResistanceUnit.BASE.getSiDimensions())),
669 UnitRuntimeException.class, "cannot cast %s to FloatElectricalResistance", this.toString());
670 FloatElectricalResistance result = new FloatElectricalResistance(getSI(), displayUnit.getStandardUnit());
671 result.setDisplayUnit(displayUnit);
672 return result;
673 }
674
675
676
677
678
679 public final FloatEnergy asEnergy()
680 {
681 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EnergyUnit.BASE.getSiDimensions())),
682 UnitRuntimeException.class, "cannot cast %s to FloatEnergy", this.toString());
683 return new FloatEnergy(getSI(), EnergyUnit.SI);
684 }
685
686
687
688
689
690
691 public final FloatEnergy asEnergy(final EnergyUnit displayUnit)
692 {
693 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EnergyUnit.BASE.getSiDimensions())),
694 UnitRuntimeException.class, "cannot cast %s to FloatEnergy", this.toString());
695 FloatEnergy result = new FloatEnergy(getSI(), displayUnit.getStandardUnit());
696 result.setDisplayUnit(displayUnit);
697 return result;
698 }
699
700
701
702
703
704 public final FloatEquivalentDose asEquivalentDose()
705 {
706 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EquivalentDoseUnit.BASE.getSiDimensions())),
707 UnitRuntimeException.class, "cannot cast %s to FloatEquivalentDose", this.toString());
708 return new FloatEquivalentDose(getSI(), EquivalentDoseUnit.SI);
709 }
710
711
712
713
714
715
716 public final FloatEquivalentDose asEquivalentDose(final EquivalentDoseUnit displayUnit)
717 {
718 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EquivalentDoseUnit.BASE.getSiDimensions())),
719 UnitRuntimeException.class, "cannot cast %s to FloatEquivalentDose", this.toString());
720 FloatEquivalentDose result = new FloatEquivalentDose(getSI(), displayUnit.getStandardUnit());
721 result.setDisplayUnit(displayUnit);
722 return result;
723 }
724
725
726
727
728
729 public final FloatFlowMass asFlowMass()
730 {
731 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowMassUnit.BASE.getSiDimensions())),
732 UnitRuntimeException.class, "cannot cast %s to FloatFlowMass", this.toString());
733 return new FloatFlowMass(getSI(), FlowMassUnit.SI);
734 }
735
736
737
738
739
740
741 public final FloatFlowMass asFlowMass(final FlowMassUnit displayUnit)
742 {
743 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowMassUnit.BASE.getSiDimensions())),
744 UnitRuntimeException.class, "cannot cast %s to FloatFlowMass", this.toString());
745 FloatFlowMass result = new FloatFlowMass(getSI(), displayUnit.getStandardUnit());
746 result.setDisplayUnit(displayUnit);
747 return result;
748 }
749
750
751
752
753
754 public final FloatFlowVolume asFlowVolume()
755 {
756 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowVolumeUnit.BASE.getSiDimensions())),
757 UnitRuntimeException.class, "cannot cast %s to FloatFlowVolume", this.toString());
758 return new FloatFlowVolume(getSI(), FlowVolumeUnit.SI);
759 }
760
761
762
763
764
765
766 public final FloatFlowVolume asFlowVolume(final FlowVolumeUnit displayUnit)
767 {
768 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowVolumeUnit.BASE.getSiDimensions())),
769 UnitRuntimeException.class, "cannot cast %s to FloatFlowVolume", this.toString());
770 FloatFlowVolume result = new FloatFlowVolume(getSI(), displayUnit.getStandardUnit());
771 result.setDisplayUnit(displayUnit);
772 return result;
773 }
774
775
776
777
778
779 public final FloatForce asForce()
780 {
781 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ForceUnit.BASE.getSiDimensions())),
782 UnitRuntimeException.class, "cannot cast %s to FloatForce", this.toString());
783 return new FloatForce(getSI(), ForceUnit.SI);
784 }
785
786
787
788
789
790
791 public final FloatForce asForce(final ForceUnit displayUnit)
792 {
793 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ForceUnit.BASE.getSiDimensions())),
794 UnitRuntimeException.class, "cannot cast %s to FloatForce", this.toString());
795 FloatForce result = new FloatForce(getSI(), displayUnit.getStandardUnit());
796 result.setDisplayUnit(displayUnit);
797 return result;
798 }
799
800
801
802
803
804 public final FloatFrequency asFrequency()
805 {
806 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FrequencyUnit.BASE.getSiDimensions())),
807 UnitRuntimeException.class, "cannot cast %s to FloatFrequency", this.toString());
808 return new FloatFrequency(getSI(), FrequencyUnit.SI);
809 }
810
811
812
813
814
815
816 public final FloatFrequency asFrequency(final FrequencyUnit displayUnit)
817 {
818 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FrequencyUnit.BASE.getSiDimensions())),
819 UnitRuntimeException.class, "cannot cast %s to FloatFrequency", this.toString());
820 FloatFrequency result = new FloatFrequency(getSI(), displayUnit.getStandardUnit());
821 result.setDisplayUnit(displayUnit);
822 return result;
823 }
824
825
826
827
828
829 public final FloatIlluminance asIlluminance()
830 {
831 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(IlluminanceUnit.BASE.getSiDimensions())),
832 UnitRuntimeException.class, "cannot cast %s to FloatIlluminance", this.toString());
833 return new FloatIlluminance(getSI(), IlluminanceUnit.SI);
834 }
835
836
837
838
839
840
841 public final FloatIlluminance asIlluminance(final IlluminanceUnit displayUnit)
842 {
843 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(IlluminanceUnit.BASE.getSiDimensions())),
844 UnitRuntimeException.class, "cannot cast %s to FloatIlluminance", this.toString());
845 FloatIlluminance result = new FloatIlluminance(getSI(), displayUnit.getStandardUnit());
846 result.setDisplayUnit(displayUnit);
847 return result;
848 }
849
850
851
852
853
854 public final FloatLinearDensity asLinearDensity()
855 {
856 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LinearDensityUnit.BASE.getSiDimensions())),
857 UnitRuntimeException.class, "cannot cast %s to FloatLinearDensity", this.toString());
858 return new FloatLinearDensity(getSI(), LinearDensityUnit.SI);
859 }
860
861
862
863
864
865
866 public final FloatLinearDensity asLinearDensity(final LinearDensityUnit displayUnit)
867 {
868 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LinearDensityUnit.BASE.getSiDimensions())),
869 UnitRuntimeException.class, "cannot cast %s to FloatLinearDensity", this.toString());
870 FloatLinearDensity result = new FloatLinearDensity(getSI(), displayUnit.getStandardUnit());
871 result.setDisplayUnit(displayUnit);
872 return result;
873 }
874
875
876
877
878
879 public final FloatLuminousFlux asLuminousFlux()
880 {
881 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousFluxUnit.BASE.getSiDimensions())),
882 UnitRuntimeException.class, "cannot cast %s to FloatLuminousFlux", this.toString());
883 return new FloatLuminousFlux(getSI(), LuminousFluxUnit.SI);
884 }
885
886
887
888
889
890
891 public final FloatLuminousFlux asLuminousFlux(final LuminousFluxUnit displayUnit)
892 {
893 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousFluxUnit.BASE.getSiDimensions())),
894 UnitRuntimeException.class, "cannot cast %s to FloatLuminousFlux", this.toString());
895 FloatLuminousFlux result = new FloatLuminousFlux(getSI(), displayUnit.getStandardUnit());
896 result.setDisplayUnit(displayUnit);
897 return result;
898 }
899
900
901
902
903
904 public final FloatLuminousIntensity asLuminousIntensity()
905 {
906 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousIntensityUnit.BASE.getSiDimensions())),
907 UnitRuntimeException.class, "cannot cast %s to FloatLuminousIntensity", this.toString());
908 return new FloatLuminousIntensity(getSI(), LuminousIntensityUnit.SI);
909 }
910
911
912
913
914
915
916 public final FloatLuminousIntensity asLuminousIntensity(final LuminousIntensityUnit displayUnit)
917 {
918 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousIntensityUnit.BASE.getSiDimensions())),
919 UnitRuntimeException.class, "cannot cast %s to FloatLuminousIntensity", this.toString());
920 FloatLuminousIntensity result = new FloatLuminousIntensity(getSI(), displayUnit.getStandardUnit());
921 result.setDisplayUnit(displayUnit);
922 return result;
923 }
924
925
926
927
928
929 public final FloatMagneticFluxDensity asMagneticFluxDensity()
930 {
931 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxDensityUnit.BASE.getSiDimensions())),
932 UnitRuntimeException.class, "cannot cast %s to FloatMagneticFluxDensity", this.toString());
933 return new FloatMagneticFluxDensity(getSI(), MagneticFluxDensityUnit.SI);
934 }
935
936
937
938
939
940
941 public final FloatMagneticFluxDensity asMagneticFluxDensity(final MagneticFluxDensityUnit displayUnit)
942 {
943 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxDensityUnit.BASE.getSiDimensions())),
944 UnitRuntimeException.class, "cannot cast %s to FloatMagneticFluxDensity", this.toString());
945 FloatMagneticFluxDensity result = new FloatMagneticFluxDensity(getSI(), displayUnit.getStandardUnit());
946 result.setDisplayUnit(displayUnit);
947 return result;
948 }
949
950
951
952
953
954 public final FloatMagneticFlux asMagneticFlux()
955 {
956 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxUnit.BASE.getSiDimensions())),
957 UnitRuntimeException.class, "cannot cast %s to FloatMagneticFlux", this.toString());
958 return new FloatMagneticFlux(getSI(), MagneticFluxUnit.SI);
959 }
960
961
962
963
964
965
966 public final FloatMagneticFlux asMagneticFlux(final MagneticFluxUnit displayUnit)
967 {
968 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxUnit.BASE.getSiDimensions())),
969 UnitRuntimeException.class, "cannot cast %s to FloatMagneticFlux", this.toString());
970 FloatMagneticFlux result = new FloatMagneticFlux(getSI(), displayUnit.getStandardUnit());
971 result.setDisplayUnit(displayUnit);
972 return result;
973 }
974
975
976
977
978
979 public final FloatMass asMass()
980 {
981 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MassUnit.BASE.getSiDimensions())),
982 UnitRuntimeException.class, "cannot cast %s to FloatMass", this.toString());
983 return new FloatMass(getSI(), MassUnit.SI);
984 }
985
986
987
988
989
990
991 public final FloatMass asMass(final MassUnit displayUnit)
992 {
993 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MassUnit.BASE.getSiDimensions())),
994 UnitRuntimeException.class, "cannot cast %s to FloatMass", this.toString());
995 FloatMass result = new FloatMass(getSI(), displayUnit.getStandardUnit());
996 result.setDisplayUnit(displayUnit);
997 return result;
998 }
999
1000
1001
1002
1003
1004 public final FloatMomentum asMomentum()
1005 {
1006 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MomentumUnit.BASE.getSiDimensions())),
1007 UnitRuntimeException.class, "cannot cast %s to FloatMomentum", this.toString());
1008 return new FloatMomentum(getSI(), MomentumUnit.SI);
1009 }
1010
1011
1012
1013
1014
1015
1016 public final FloatMomentum asMomentum(final MomentumUnit displayUnit)
1017 {
1018 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MomentumUnit.BASE.getSiDimensions())),
1019 UnitRuntimeException.class, "cannot cast %s to FloatMomentum", this.toString());
1020 FloatMomentum result = new FloatMomentum(getSI(), displayUnit.getStandardUnit());
1021 result.setDisplayUnit(displayUnit);
1022 return result;
1023 }
1024
1025
1026
1027
1028
1029 public final FloatPower asPower()
1030 {
1031 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PowerUnit.BASE.getSiDimensions())),
1032 UnitRuntimeException.class, "cannot cast %s to FloatPower", this.toString());
1033 return new FloatPower(getSI(), PowerUnit.SI);
1034 }
1035
1036
1037
1038
1039
1040
1041 public final FloatPower asPower(final PowerUnit displayUnit)
1042 {
1043 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PowerUnit.BASE.getSiDimensions())),
1044 UnitRuntimeException.class, "cannot cast %s to FloatPower", this.toString());
1045 FloatPower result = new FloatPower(getSI(), displayUnit.getStandardUnit());
1046 result.setDisplayUnit(displayUnit);
1047 return result;
1048 }
1049
1050
1051
1052
1053
1054 public final FloatPressure asPressure()
1055 {
1056 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PressureUnit.BASE.getSiDimensions())),
1057 UnitRuntimeException.class, "cannot cast %s to FloatPressure", this.toString());
1058 return new FloatPressure(getSI(), PressureUnit.SI);
1059 }
1060
1061
1062
1063
1064
1065
1066 public final FloatPressure asPressure(final PressureUnit displayUnit)
1067 {
1068 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PressureUnit.BASE.getSiDimensions())),
1069 UnitRuntimeException.class, "cannot cast %s to FloatPressure", this.toString());
1070 FloatPressure result = new FloatPressure(getSI(), displayUnit.getStandardUnit());
1071 result.setDisplayUnit(displayUnit);
1072 return result;
1073 }
1074
1075
1076
1077
1078
1079 public final FloatRadioActivity asRadioActivity()
1080 {
1081 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(RadioActivityUnit.BASE.getSiDimensions())),
1082 UnitRuntimeException.class, "cannot cast %s to FloatRadioActivity", this.toString());
1083 return new FloatRadioActivity(getSI(), RadioActivityUnit.SI);
1084 }
1085
1086
1087
1088
1089
1090
1091 public final FloatRadioActivity asRadioActivity(final RadioActivityUnit displayUnit)
1092 {
1093 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(RadioActivityUnit.BASE.getSiDimensions())),
1094 UnitRuntimeException.class, "cannot cast %s to FloatRadioActivity", this.toString());
1095 FloatRadioActivity result = new FloatRadioActivity(getSI(), displayUnit.getStandardUnit());
1096 result.setDisplayUnit(displayUnit);
1097 return result;
1098 }
1099
1100
1101
1102
1103
1104 public final FloatSolidAngle asSolidAngle()
1105 {
1106 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SolidAngleUnit.BASE.getSiDimensions())),
1107 UnitRuntimeException.class, "cannot cast %s to FloatSolidAngle", this.toString());
1108 return new FloatSolidAngle(getSI(), SolidAngleUnit.SI);
1109 }
1110
1111
1112
1113
1114
1115
1116 public final FloatSolidAngle asSolidAngle(final SolidAngleUnit displayUnit)
1117 {
1118 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SolidAngleUnit.BASE.getSiDimensions())),
1119 UnitRuntimeException.class, "cannot cast %s to FloatSolidAngle", this.toString());
1120 FloatSolidAngle result = new FloatSolidAngle(getSI(), displayUnit.getStandardUnit());
1121 result.setDisplayUnit(displayUnit);
1122 return result;
1123 }
1124
1125
1126
1127
1128
1129 public final FloatSpeed asSpeed()
1130 {
1131 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SpeedUnit.BASE.getSiDimensions())),
1132 UnitRuntimeException.class, "cannot cast %s to FloatSpeed", this.toString());
1133 return new FloatSpeed(getSI(), SpeedUnit.SI);
1134 }
1135
1136
1137
1138
1139
1140
1141 public final FloatSpeed asSpeed(final SpeedUnit displayUnit)
1142 {
1143 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SpeedUnit.BASE.getSiDimensions())),
1144 UnitRuntimeException.class, "cannot cast %s to FloatSpeed", this.toString());
1145 FloatSpeed result = new FloatSpeed(getSI(), displayUnit.getStandardUnit());
1146 result.setDisplayUnit(displayUnit);
1147 return result;
1148 }
1149
1150
1151
1152
1153
1154 public final FloatTorque asTorque()
1155 {
1156 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TorqueUnit.BASE.getSiDimensions())),
1157 UnitRuntimeException.class, "cannot cast %s to FloatTorque", this.toString());
1158 return new FloatTorque(getSI(), TorqueUnit.SI);
1159 }
1160
1161
1162
1163
1164
1165
1166 public final FloatTorque asTorque(final TorqueUnit displayUnit)
1167 {
1168 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TorqueUnit.BASE.getSiDimensions())),
1169 UnitRuntimeException.class, "cannot cast %s to FloatTorque", this.toString());
1170 FloatTorque result = new FloatTorque(getSI(), displayUnit.getStandardUnit());
1171 result.setDisplayUnit(displayUnit);
1172 return result;
1173 }
1174
1175
1176
1177
1178
1179 public final FloatVolume asVolume()
1180 {
1181 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(VolumeUnit.BASE.getSiDimensions())),
1182 UnitRuntimeException.class, "cannot cast %s to FloatVolume", this.toString());
1183 return new FloatVolume(getSI(), VolumeUnit.SI);
1184 }
1185
1186
1187
1188
1189
1190
1191 public final FloatVolume asVolume(final VolumeUnit displayUnit)
1192 {
1193 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(VolumeUnit.BASE.getSiDimensions())),
1194 UnitRuntimeException.class, "cannot cast %s to FloatVolume", this.toString());
1195 FloatVolume result = new FloatVolume(getSI(), displayUnit.getStandardUnit());
1196 result.setDisplayUnit(displayUnit);
1197 return result;
1198 }
1199
1200
1201
1202
1203
1204 public final FloatAngle asAngle()
1205 {
1206 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngleUnit.BASE.getSiDimensions())),
1207 UnitRuntimeException.class, "cannot cast %s to FloatAngle", this.toString());
1208 return new FloatAngle(getSI(), AngleUnit.SI);
1209 }
1210
1211
1212
1213
1214
1215
1216 public final FloatAngle asAngle(final AngleUnit displayUnit)
1217 {
1218 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngleUnit.BASE.getSiDimensions())),
1219 UnitRuntimeException.class, "cannot cast %s to FloatAngle", this.toString());
1220 FloatAngle result = new FloatAngle(getSI(), displayUnit.getStandardUnit());
1221 result.setDisplayUnit(displayUnit);
1222 return result;
1223 }
1224
1225
1226
1227
1228
1229 public final FloatLength asLength()
1230 {
1231 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LengthUnit.BASE.getSiDimensions())),
1232 UnitRuntimeException.class, "cannot cast %s to FloatLength", this.toString());
1233 return new FloatLength(getSI(), LengthUnit.SI);
1234 }
1235
1236
1237
1238
1239
1240
1241 public final FloatLength asLength(final LengthUnit displayUnit)
1242 {
1243 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LengthUnit.BASE.getSiDimensions())),
1244 UnitRuntimeException.class, "cannot cast %s to FloatLength", this.toString());
1245 FloatLength result = new FloatLength(getSI(), displayUnit.getStandardUnit());
1246 result.setDisplayUnit(displayUnit);
1247 return result;
1248 }
1249
1250
1251
1252
1253
1254 public final FloatTemperature asTemperature()
1255 {
1256 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TemperatureUnit.BASE.getSiDimensions())),
1257 UnitRuntimeException.class, "cannot cast %s to FloatTemperature", this.toString());
1258 return new FloatTemperature(getSI(), TemperatureUnit.SI);
1259 }
1260
1261
1262
1263
1264
1265
1266 public final FloatTemperature asTemperature(final TemperatureUnit displayUnit)
1267 {
1268 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TemperatureUnit.BASE.getSiDimensions())),
1269 UnitRuntimeException.class, "cannot cast %s to FloatTemperature", this.toString());
1270 FloatTemperature result = new FloatTemperature(getSI(), displayUnit.getStandardUnit());
1271 result.setDisplayUnit(displayUnit);
1272 return result;
1273 }
1274
1275
1276
1277
1278
1279 public final FloatDuration asDuration()
1280 {
1281 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DurationUnit.BASE.getSiDimensions())),
1282 UnitRuntimeException.class, "cannot cast %s to FloatDuration", this.toString());
1283 return new FloatDuration(getSI(), DurationUnit.SI);
1284 }
1285
1286
1287
1288
1289
1290
1291 public final FloatDuration asDuration(final DurationUnit displayUnit)
1292 {
1293 Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DurationUnit.BASE.getSiDimensions())),
1294 UnitRuntimeException.class, "cannot cast %s to FloatDuration", this.toString());
1295 FloatDuration result = new FloatDuration(getSI(), displayUnit.getStandardUnit());
1296 result.setDisplayUnit(displayUnit);
1297 return result;
1298 }
1299
1300 }