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