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