View Javadoc
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   * Easy access methods for the generic Relative SI FloatScalar.
59   * <p>
60   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. <br>
61   * All rights reserved. <br>
62   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
63   * </p>
64   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
65   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
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       * Construct SI scalar.
75       * @param value float; the float value
76       * @param unit SIUnit; unit for the float value
77       */
78      public FloatSIScalar(final float value, final SIUnit unit)
79      {
80          super(value, unit);
81      }
82  
83      /**
84       * Construct SI scalar.
85       * @param value FloatSIScalar; Scalar from which to construct this instance
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       * Construct SI scalar.
100      * @param value float; the float value in SI units
101      * @param unit SIUnit; the unit to use for the SI scalar
102      * @return FloatSIScalar; the new scalar with the SI value
103      */
104     public static final FloatSIScalar instantiateSI(final float value, final SIUnit unit)
105     {
106         return new FloatSIScalar(value, unit);
107     }
108 
109     /**
110      * Interpolate between two values.
111      * @param zero FloatSIScalar; the low value
112      * @param one FloatSIScalar; the high value
113      * @param ratio float; the ratio between 0 and 1, inclusive
114      * @return FloatSIScalar; a Scalar at the ratio between
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      * Return the maximum value of two relative scalars.
124      * @param r1 FloatSIScalar; the first scalar
125      * @param r2 FloatSIScalar; the second scalar
126      * @return FloatSIScalar; the maximum value of two relative scalars
127      */
128     public static FloatSIScalar max(final FloatSIScalar r1, final FloatSIScalar r2)
129     {
130         return r1.gt(r2) ? r1 : r2;
131     }
132 
133     /**
134      * Return the maximum value of more than two relative scalars.
135      * @param r1 FloatSIScalar; the first scalar
136      * @param r2 FloatSIScalar; the second scalar
137      * @param rn FloatSIScalar...; the other scalars
138      * @return FloatSIScalar; the maximum value of more than two relative scalars
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      * Return the minimum value of two relative scalars.
155      * @param r1 FloatSIScalar; the first scalar
156      * @param r2 FloatSIScalar; the second scalar
157      * @return FloatSIScalar; the minimum value of two relative scalars
158      */
159     public static FloatSIScalar min(final FloatSIScalar r1, final FloatSIScalar r2)
160     {
161         return r1.lt(r2) ? r1 : r2;
162     }
163 
164     /**
165      * Return the minimum value of more than two relative scalars.
166      * @param r1 FloatSIScalar; the first scalar
167      * @param r2 FloatSIScalar; the second scalar
168      * @param rn FloatSIScalar...; the other scalars
169      * @return FloatSIScalar; the minimum value of more than two relative scalars
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      * Returns an FloatSIScalar representation of a textual representation of a value with a unit. The String representation
192      * that can be parsed is the float value in the unit, followed by the official abbreviation of the unit. Spaces are allowed,
193      * but not required, between the value and the unit.
194      * @param text String; the textual representation to parse into a FloatSIScalar
195      * @return FloatSIScalar; the Scalar representation of the value in its unit
196      * @throws IllegalArgumentException when the text cannot be parsed
197      * @throws NullPointerException when the text argument is null
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      * Returns an FloatSIScalar based on a value and the textual representation of the unit.
223      * @param value float; the value to use
224      * @param unitString String; the textual representation of the unit
225      * @return FloatSIScalar; the Scalar representation of the value in its unit
226      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
227      * @throws NullPointerException when the unitString argument is null
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     /******************************** 'CAST AS' METHODS *******************************/
255     /**********************************************************************************/
256 
257     /**
258      * Return the current scalar transformed to a scalar in the given unit. Of course the SI dimensionality has to match,
259      * otherwise the scalar cannot be transformed. The compiler will check the alignment between the return value and the unit.
260      * @param displayUnit KU; the unit in which the scalar needs to be expressed
261      * @return S; the scalar that has been transformed into the right scalar type and unit
262      * @param <U> the unit type
263      * @param <S> the scalar type
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      * Return the current scalar as a absorbeddose.
277      * @return FloatAbsorbedDose; the current scalar as a absorbeddose
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      * Return the current scalar as a absorbeddose, and provide a display unit.
288      * @param displayUnit the unit in which the value will be displayed
289      * @return FloatAbsorbedDose; the current scalar as a absorbeddose
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      * Return the current scalar as a acceleration.
302      * @return FloatAcceleration; the current scalar as a acceleration
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      * Return the current scalar as a acceleration, and provide a display unit.
313      * @param displayUnit the unit in which the value will be displayed
314      * @return FloatAcceleration; the current scalar as a acceleration
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      * Return the current scalar as a amountofsubstance.
327      * @return FloatAmountOfSubstance; the current scalar as a amountofsubstance
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      * Return the current scalar as a amountofsubstance, and provide a display unit.
338      * @param displayUnit the unit in which the value will be displayed
339      * @return FloatAmountOfSubstance; the current scalar as a amountofsubstance
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      * Return the current scalar as a angularacceleration.
352      * @return FloatAngularAcceleration; the current scalar as a angularacceleration
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      * Return the current scalar as a angularacceleration, and provide a display unit.
363      * @param displayUnit the unit in which the value will be displayed
364      * @return FloatAngularAcceleration; the current scalar as a angularacceleration
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      * Return the current scalar as a angularvelocity.
377      * @return FloatAngularVelocity; the current scalar as a angularvelocity
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      * Return the current scalar as a angularvelocity, and provide a display unit.
388      * @param displayUnit the unit in which the value will be displayed
389      * @return FloatAngularVelocity; the current scalar as a angularvelocity
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      * Return the current scalar as a area.
402      * @return FloatArea; the current scalar as a area
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      * Return the current scalar as a area, and provide a display unit.
413      * @param displayUnit the unit in which the value will be displayed
414      * @return FloatArea; the current scalar as a area
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      * Return the current scalar as a catalyticactivity.
427      * @return FloatCatalyticActivity; the current scalar as a catalyticactivity
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      * Return the current scalar as a catalyticactivity, and provide a display unit.
438      * @param displayUnit the unit in which the value will be displayed
439      * @return FloatCatalyticActivity; the current scalar as a catalyticactivity
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      * Return the current scalar as a density.
452      * @return FloatDensity; the current scalar as a density
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      * Return the current scalar as a density, and provide a display unit.
463      * @param displayUnit the unit in which the value will be displayed
464      * @return FloatDensity; the current scalar as a density
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      * Return the current scalar as a dimensionless.
477      * @return FloatDimensionless; the current scalar as a dimensionless
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      * Return the current scalar as a dimensionless, and provide a display unit.
488      * @param displayUnit the unit in which the value will be displayed
489      * @return FloatDimensionless; the current scalar as a dimensionless
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      * Return the current scalar as a electricalcapacitance.
502      * @return FloatElectricalCapacitance; the current scalar as a electricalcapacitance
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      * Return the current scalar as a electricalcapacitance, and provide a display unit.
513      * @param displayUnit the unit in which the value will be displayed
514      * @return FloatElectricalCapacitance; the current scalar as a electricalcapacitance
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      * Return the current scalar as a electricalcharge.
527      * @return FloatElectricalCharge; the current scalar as a electricalcharge
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      * Return the current scalar as a electricalcharge, and provide a display unit.
538      * @param displayUnit the unit in which the value will be displayed
539      * @return FloatElectricalCharge; the current scalar as a electricalcharge
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      * Return the current scalar as a electricalconductance.
552      * @return FloatElectricalConductance; the current scalar as a electricalconductance
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      * Return the current scalar as a electricalconductance, and provide a display unit.
563      * @param displayUnit the unit in which the value will be displayed
564      * @return FloatElectricalConductance; the current scalar as a electricalconductance
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      * Return the current scalar as a electricalcurrent.
577      * @return FloatElectricalCurrent; the current scalar as a electricalcurrent
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      * Return the current scalar as a electricalcurrent, and provide a display unit.
588      * @param displayUnit the unit in which the value will be displayed
589      * @return FloatElectricalCurrent; the current scalar as a electricalcurrent
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      * Return the current scalar as a electricalinductance.
602      * @return FloatElectricalInductance; the current scalar as a electricalinductance
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      * Return the current scalar as a electricalinductance, and provide a display unit.
613      * @param displayUnit the unit in which the value will be displayed
614      * @return FloatElectricalInductance; the current scalar as a electricalinductance
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      * Return the current scalar as a electricalpotential.
627      * @return FloatElectricalPotential; the current scalar as a electricalpotential
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      * Return the current scalar as a electricalpotential, and provide a display unit.
638      * @param displayUnit the unit in which the value will be displayed
639      * @return FloatElectricalPotential; the current scalar as a electricalpotential
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      * Return the current scalar as a electricalresistance.
652      * @return FloatElectricalResistance; the current scalar as a electricalresistance
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      * Return the current scalar as a electricalresistance, and provide a display unit.
663      * @param displayUnit the unit in which the value will be displayed
664      * @return FloatElectricalResistance; the current scalar as a electricalresistance
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      * Return the current scalar as a energy.
677      * @return FloatEnergy; the current scalar as a energy
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      * Return the current scalar as a energy, and provide a display unit.
688      * @param displayUnit the unit in which the value will be displayed
689      * @return FloatEnergy; the current scalar as a energy
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      * Return the current scalar as a equivalentdose.
702      * @return FloatEquivalentDose; the current scalar as a equivalentdose
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      * Return the current scalar as a equivalentdose, and provide a display unit.
713      * @param displayUnit the unit in which the value will be displayed
714      * @return FloatEquivalentDose; the current scalar as a equivalentdose
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      * Return the current scalar as a flowmass.
727      * @return FloatFlowMass; the current scalar as a flowmass
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      * Return the current scalar as a flowmass, and provide a display unit.
738      * @param displayUnit the unit in which the value will be displayed
739      * @return FloatFlowMass; the current scalar as a flowmass
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      * Return the current scalar as a flowvolume.
752      * @return FloatFlowVolume; the current scalar as a flowvolume
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      * Return the current scalar as a flowvolume, and provide a display unit.
763      * @param displayUnit the unit in which the value will be displayed
764      * @return FloatFlowVolume; the current scalar as a flowvolume
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      * Return the current scalar as a force.
777      * @return FloatForce; the current scalar as a force
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      * Return the current scalar as a force, and provide a display unit.
788      * @param displayUnit the unit in which the value will be displayed
789      * @return FloatForce; the current scalar as a force
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      * Return the current scalar as a frequency.
802      * @return FloatFrequency; the current scalar as a frequency
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      * Return the current scalar as a frequency, and provide a display unit.
813      * @param displayUnit the unit in which the value will be displayed
814      * @return FloatFrequency; the current scalar as a frequency
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      * Return the current scalar as a illuminance.
827      * @return FloatIlluminance; the current scalar as a illuminance
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      * Return the current scalar as a illuminance, and provide a display unit.
838      * @param displayUnit the unit in which the value will be displayed
839      * @return FloatIlluminance; the current scalar as a illuminance
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      * Return the current scalar as a lineardensity.
852      * @return FloatLinearDensity; the current scalar as a lineardensity
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      * Return the current scalar as a lineardensity, and provide a display unit.
863      * @param displayUnit the unit in which the value will be displayed
864      * @return FloatLinearDensity; the current scalar as a lineardensity
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      * Return the current scalar as a luminousflux.
877      * @return FloatLuminousFlux; the current scalar as a luminousflux
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      * Return the current scalar as a luminousflux, and provide a display unit.
888      * @param displayUnit the unit in which the value will be displayed
889      * @return FloatLuminousFlux; the current scalar as a luminousflux
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      * Return the current scalar as a luminousintensity.
902      * @return FloatLuminousIntensity; the current scalar as a luminousintensity
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      * Return the current scalar as a luminousintensity, and provide a display unit.
913      * @param displayUnit the unit in which the value will be displayed
914      * @return FloatLuminousIntensity; the current scalar as a luminousintensity
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      * Return the current scalar as a magneticfluxdensity.
927      * @return FloatMagneticFluxDensity; the current scalar as a magneticfluxdensity
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      * Return the current scalar as a magneticfluxdensity, and provide a display unit.
938      * @param displayUnit the unit in which the value will be displayed
939      * @return FloatMagneticFluxDensity; the current scalar as a magneticfluxdensity
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      * Return the current scalar as a magneticflux.
952      * @return FloatMagneticFlux; the current scalar as a magneticflux
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      * Return the current scalar as a magneticflux, and provide a display unit.
963      * @param displayUnit the unit in which the value will be displayed
964      * @return FloatMagneticFlux; the current scalar as a magneticflux
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      * Return the current scalar as a mass.
977      * @return FloatMass; the current scalar as a mass
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      * Return the current scalar as a mass, and provide a display unit.
988      * @param displayUnit the unit in which the value will be displayed
989      * @return FloatMass; the current scalar as a mass
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      * Return the current scalar as a momentum.
1002      * @return FloatMomentum; the current scalar as a momentum
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      * Return the current scalar as a momentum, and provide a display unit.
1013      * @param displayUnit the unit in which the value will be displayed
1014      * @return FloatMomentum; the current scalar as a momentum
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      * Return the current scalar as a power.
1027      * @return FloatPower; the current scalar as a power
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      * Return the current scalar as a power, and provide a display unit.
1038      * @param displayUnit the unit in which the value will be displayed
1039      * @return FloatPower; the current scalar as a power
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      * Return the current scalar as a pressure.
1052      * @return FloatPressure; the current scalar as a pressure
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      * Return the current scalar as a pressure, and provide a display unit.
1063      * @param displayUnit the unit in which the value will be displayed
1064      * @return FloatPressure; the current scalar as a pressure
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      * Return the current scalar as a radioactivity.
1077      * @return FloatRadioActivity; the current scalar as a radioactivity
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      * Return the current scalar as a radioactivity, and provide a display unit.
1088      * @param displayUnit the unit in which the value will be displayed
1089      * @return FloatRadioActivity; the current scalar as a radioactivity
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      * Return the current scalar as a solidangle.
1102      * @return FloatSolidAngle; the current scalar as a solidangle
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      * Return the current scalar as a solidangle, and provide a display unit.
1113      * @param displayUnit the unit in which the value will be displayed
1114      * @return FloatSolidAngle; the current scalar as a solidangle
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      * Return the current scalar as a speed.
1127      * @return FloatSpeed; the current scalar as a speed
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      * Return the current scalar as a speed, and provide a display unit.
1138      * @param displayUnit the unit in which the value will be displayed
1139      * @return FloatSpeed; the current scalar as a speed
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      * Return the current scalar as a torque.
1152      * @return FloatTorque; the current scalar as a torque
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      * Return the current scalar as a torque, and provide a display unit.
1163      * @param displayUnit the unit in which the value will be displayed
1164      * @return FloatTorque; the current scalar as a torque
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      * Return the current scalar as a volume.
1177      * @return FloatVolume; the current scalar as a volume
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      * Return the current scalar as a volume, and provide a display unit.
1188      * @param displayUnit the unit in which the value will be displayed
1189      * @return FloatVolume; the current scalar as a volume
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      * Return the current scalar as a angle.
1202      * @return FloatAngle; the current scalar as a angle
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      * Return the current scalar as a angle, and provide a display unit.
1213      * @param displayUnit the unit in which the value will be displayed
1214      * @return FloatAngle; the current scalar as a angle
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      * Return the current scalar as a length.
1227      * @return FloatLength; the current scalar as a length
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      * Return the current scalar as a length, and provide a display unit.
1238      * @param displayUnit the unit in which the value will be displayed
1239      * @return FloatLength; the current scalar as a length
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      * Return the current scalar as a temperature.
1252      * @return FloatTemperature; the current scalar as a temperature
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      * Return the current scalar as a temperature, and provide a display unit.
1263      * @param displayUnit the unit in which the value will be displayed
1264      * @return FloatTemperature; the current scalar as a temperature
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      * Return the current scalar as a duration.
1277      * @return FloatDuration; the current scalar as a duration
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      * Return the current scalar as a duration, and provide a display unit.
1288      * @param displayUnit the unit in which the value will be displayed
1289      * @return FloatDuration; the current scalar as a duration
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 }