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