View Javadoc
1   package org.djunits.value.vdouble.vector;
2   
3   import java.util.List;
4   import java.util.Map;
5   
6   import org.djunits.unit.AbsorbedDoseUnit;
7   import org.djunits.unit.AccelerationUnit;
8   import org.djunits.unit.AmountOfSubstanceUnit;
9   import org.djunits.unit.AngleUnit;
10  import org.djunits.unit.AngularAccelerationUnit;
11  import org.djunits.unit.AngularVelocityUnit;
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.MomentumUnit;
39  import org.djunits.unit.PowerUnit;
40  import org.djunits.unit.PressureUnit;
41  import org.djunits.unit.RadioActivityUnit;
42  import org.djunits.unit.SIUnit;
43  import org.djunits.unit.SolidAngleUnit;
44  import org.djunits.unit.SpeedUnit;
45  import org.djunits.unit.TemperatureUnit;
46  import org.djunits.unit.TorqueUnit;
47  import org.djunits.unit.Unit;
48  import org.djunits.unit.VolumeUnit;
49  import org.djunits.unit.scale.IdentityScale;
50  import org.djunits.unit.si.SIDimensions;
51  import org.djunits.unit.util.UnitRuntimeException;
52  import org.djunits.value.storage.StorageType;
53  import org.djunits.value.vdouble.scalar.SIScalar;
54  import org.djunits.value.vdouble.vector.base.DoubleVectorRel;
55  import org.djunits.value.vdouble.vector.data.DoubleVectorData;
56  import org.djutils.exceptions.Throw;
57  
58  import jakarta.annotation.Generated;
59  
60  /**
61   * Easy access methods for the generic Relative SI DoubleVector.
62   * <p>
63   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. <br>
64   * All rights reserved. <br>
65   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
66   * </p>
67   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
68   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
69   */
70  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
71  public class SIVector extends DoubleVectorRel<SIUnit, SIScalar, SIVector>
72  {
73      /** */
74      private static final long serialVersionUID = 20150901L;
75  
76      /**
77       * Construct an SIVector from an internal data object.
78       * @param data DoubleVectorData; the internal data object for the vector
79       * @param displayUnit SIUnit; the display unit of the vector data
80       */
81      public SIVector(final DoubleVectorData data, final SIUnit displayUnit)
82      {
83          super(data, displayUnit);
84      }
85  
86      /* ****************************** CONSTRUCTORS WITH double[] ****************************** */
87  
88      /**
89       * Construct an SIVector from a double[] object. The double values are expressed in the displayUnit, and will be printed
90       * using the displayUnit.
91       * @param data double[]; the data for the vector, expressed in the displayUnit
92       * @param displayUnit SIUnit; the unit of the values in the data array, and display unit when printing
93       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
94       */
95      public SIVector(final double[] data, final SIUnit displayUnit, final StorageType storageType)
96      {
97          this(DoubleVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
98      }
99  
100     /**
101      * Construct an SIVector from a double[] object. The double values are expressed in the displayUnit. Assume that the
102      * StorageType is DENSE since we offer the data as an array.
103      * @param data double[]; the data for the vector
104      * @param displayUnit SIUnit; the unit of the values in the data array, and display unit when printing
105      */
106     public SIVector(final double[] data, final SIUnit displayUnit)
107     {
108         this(data, displayUnit, StorageType.DENSE);
109     }
110 
111     /* ****************************** CONSTRUCTORS WITH SIScalar[] ****************************** */
112 
113     /**
114      * Construct an SIVector from an array of SIScalar objects. The SIScalar values are each expressed in their own unit, but
115      * will be internally stored as SI values, all expressed in the displayUnit when printing.
116      * @param data SIScalar[]; the data for the vector
117      * @param displayUnit SIUnit; the display unit of the values when printing
118      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
119      */
120     public SIVector(final SIScalar[] data, final SIUnit displayUnit, final StorageType storageType)
121     {
122         this(DoubleVectorData.instantiate(data, storageType), displayUnit);
123     }
124 
125     /**
126      * Construct an SIVector from an array of SIScalar objects. The SIScalar values are each expressed in their own unit, but
127      * will be internally stored as SI values, all expressed in the displayUnit when printing. Assume that the StorageType is
128      * DENSE since we offer the data as an array.
129      * @param data SIScalar[]; the data for the vector
130      * @param displayUnit SIUnit; the display unit of the values when printing
131      */
132     public SIVector(final SIScalar[] data, final SIUnit displayUnit)
133     {
134         this(data, displayUnit, StorageType.DENSE);
135     }
136 
137     /* ****************************** CONSTRUCTORS WITH List<Double> or List<SIScalar> ****************************** */
138 
139     /**
140      * Construct an SIVector from a list of Number objects or a list of SIScalar objects. Note that the displayUnit has a
141      * different meaning depending on whether the list contains Number objects (e.g., Double objects) or SIScalar objects. In
142      * case the list contains Number objects, the displayUnit indicates the unit in which the values in the list are expressed,
143      * as well as the unit in which they will be printed. In case the list contains SIScalar objects, each SIScalar has its own
144      * unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI values or base
145      * values, and expressed using the display unit or base unit when printing.
146      * @param data List&lt;Double&gt; or List&lt;SIScalar&gt;; the data for the vector
147      * @param displayUnit SIUnit; the display unit of the vector data, and the unit of the data points when the data is
148      *            expressed as List&lt;Double&gt; or List&lt;Number&gt; in general
149      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
150      */
151     public SIVector(final List<? extends Number> data, final SIUnit displayUnit, final StorageType storageType)
152     {
153         this(data.size() == 0 ? DoubleVectorData.instantiate(new double[] {}, IdentityScale.SCALE, storageType)
154                 : data.get(0) instanceof SIScalar ? DoubleVectorData.instantiate(data, IdentityScale.SCALE, storageType)
155                         : DoubleVectorData.instantiate(data, displayUnit.getScale(), storageType),
156                 displayUnit);
157     }
158 
159     /**
160      * Construct an SIVector from a list of Number objects or a list of SIScalar objects. Note that the displayUnit has a
161      * different meaning depending on whether the list contains Number objects (e.g., Double objects) or SIScalar objects. In
162      * case the list contains Number objects, the displayUnit indicates the unit in which the values in the list are expressed,
163      * as well as the unit in which they will be printed. In case the list contains SIScalar objects, each SIScalar has its own
164      * unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI values or base
165      * values, and expressed using the display unit or base unit when printing. Assume the storage type is DENSE since we offer
166      * the data as a List.
167      * @param data List&lt;Double&gt; or List&lt;SIScalar&gt;; the data for the vector
168      * @param displayUnit SIUnit; the display unit of the vector data, and the unit of the data points when the data is
169      *            expressed as List&lt;Double&gt; or List&lt;Number&gt; in general
170      */
171     public SIVector(final List<? extends Number> data, final SIUnit displayUnit)
172     {
173         this(data, displayUnit, StorageType.DENSE);
174     }
175 
176     /* ******************** CONSTRUCTORS WITH Map<Integer, Double> or Map<Integer, SIScalar> ******************** */
177 
178     /**
179      * Construct an SIVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to of
180      * SIScalar objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the size of
181      * the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a different
182      * meaning depending on whether the map contains Number objects (e.g., Double objects) or SIScalar objects. In case the map
183      * contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed, as well as the
184      * unit in which they will be printed. In case the map contains SIScalar objects, each SIScalar has its own unit, and the
185      * displayUnit is just used for printing. The values but will always be internally stored as SI values or base values, and
186      * expressed using the display unit or base unit when printing.
187      * @param data Map&lt;Integer, Double&gt; or Map&lt;Integer, SIScalar&gt;; the data for the vector
188      * @param size int; the size off the vector, i.e., the highest index
189      * @param displayUnit SIUnit; the display unit of the vector data, and the unit of the data points when the data is
190      *            expressed as List&lt;Double&gt; or List&lt;Number&gt; in general
191      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
192      */
193     public SIVector(final Map<Integer, ? extends Number> data, final int size, final SIUnit displayUnit,
194             final StorageType storageType)
195     {
196         this(data.size() == 0 ? DoubleVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
197                 : data.values().iterator().next() instanceof SIScalar
198                         ? DoubleVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
199                         : DoubleVectorData.instantiate(data, size, displayUnit.getScale(), storageType),
200                 displayUnit);
201     }
202 
203     /**
204      * Construct an SIVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to of
205      * SIScalar objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the size of
206      * the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a different
207      * meaning depending on whether the map contains Number objects (e.g., Double objects) or SIScalar objects. In case the map
208      * contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed, as well as the
209      * unit in which they will be printed. In case the map contains SIScalar objects, each SIScalar has its own unit, and the
210      * displayUnit is just used for printing. The values but will always be internally stored as SI values or base values, and
211      * expressed using the display unit or base unit when printing. Assume the storage type is SPARSE since we offer the data as
212      * a Map.
213      * @param data Map&lt;Integer, Double&gt; or Map&lt;Integer, SIScalar&gt;; the data for the vector
214      * @param size int; the size off the vector, i.e., the highest index
215      * @param displayUnit SIUnit; the display unit of the vector data, and the unit of the data points when the data is
216      *            expressed as List&lt;Double&gt; or List&lt;Number&gt; in general
217      */
218     public SIVector(final Map<Integer, ? extends Number> data, final int size, final SIUnit displayUnit)
219     {
220         this(data, size, displayUnit, StorageType.SPARSE);
221     }
222 
223     /* ****************************** Other methods ****************************** */
224 
225     /** {@inheritDoc} */
226     @Override
227     public Class<SIScalar> getScalarClass()
228     {
229         return SIScalar.class;
230     }
231 
232     /**
233      * Returns an SIVector based on an array of values and the textual representation of the unit.
234      * @param value double[]; the values to use
235      * @param unitString String; the textual representation of the unit
236      * @param storageType StorageType; the storage type to use
237      * @return SIVector; the vector representation of the values in their unit
238      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
239      * @throws NullPointerException when the unitString argument is null
240      */
241     public static SIVector of(final double[] value, final String unitString, final StorageType storageType)
242     {
243         Throw.whenNull(value, "Error parsing SIVector: value is null");
244         Throw.whenNull(unitString, "Error parsing SIVector: unitString is null");
245         Throw.whenNull(storageType, "Error parsing SIVector: storageType is null");
246         try
247         {
248             SIUnit unit = Unit.lookupOrCreateUnitWithSIDimensions(SIDimensions.of(unitString));
249             if (unit != null)
250             {
251                 return new SIVector(value, unit, storageType);
252             }
253         }
254         catch (Exception exception)
255         {
256             throw new IllegalArgumentException("Error parsing SIUnit from " + unitString, exception);
257         }
258         throw new IllegalArgumentException("Error parsing SIVector with unit " + unitString);
259     }
260 
261     /**
262      * Returns an SIVector based on an array of values and the textual representation of the unit.
263      * @param valueList List&lt;Double&gt;; the values to use
264      * @param unitString String; the textual representation of the unit
265      * @param storageType StorageType; the storage type to use
266      * @return SIVector; the vector representation of the values in their unit
267      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
268      * @throws NullPointerException when the unitString argument is null
269      */
270     public static SIVector of(final List<Double> valueList, final String unitString, final StorageType storageType)
271     {
272         Throw.whenNull(valueList, "Error parsing SIVector: valueList is null");
273         Throw.whenNull(unitString, "Error parsing SIVector: unitString is null");
274         Throw.whenNull(storageType, "Error parsing SIVector: storageType is null");
275         try
276         {
277             SIUnit unit = Unit.lookupOrCreateUnitWithSIDimensions(SIDimensions.of(unitString));
278             if (unit != null)
279             {
280                 return new SIVector(valueList, unit, storageType);
281             }
282         }
283         catch (Exception exception)
284         {
285             throw new IllegalArgumentException("Error parsing SIUnit from " + unitString, exception);
286         }
287         throw new IllegalArgumentException("Error parsing SIVector with unit " + unitString);
288     }
289 
290     /**
291      * Returns an SIVector based on a (sparse) map of values and the textual representation of the unit.
292      * @param valueMap Map&lt;Integer, Double&gt;; the values to use
293      * @param unitString String; the textual representation of the unit
294      * @param length int; the size of the vector
295      * @param storageType StorageType; the storage type to use
296      * @return SIVector; the vector representation of the values in their unit
297      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
298      * @throws NullPointerException when the unitString argument is null
299      */
300     public static SIVector of(final Map<Integer, Double> valueMap, final String unitString, final int length,
301             final StorageType storageType)
302     {
303         Throw.whenNull(valueMap, "Error parsing SIVector: valueMap is null");
304         Throw.whenNull(unitString, "Error parsing SIVector: unitString is null");
305         Throw.whenNull(storageType, "Error parsing SIVector: storageType is null");
306         try
307         {
308             SIUnit unit = Unit.lookupOrCreateUnitWithSIDimensions(SIDimensions.of(unitString));
309             if (unit != null)
310             {
311                 return new SIVector(valueMap, length, unit, storageType);
312             }
313         }
314         catch (Exception exception)
315         {
316             throw new IllegalArgumentException("Error parsing SIUnit from " + unitString, exception);
317         }
318         throw new IllegalArgumentException("Error parsing SIVector with unit " + unitString);
319     }
320 
321     /** {@inheritDoc} */
322     @Override
323     public SIVector instantiateVector(final DoubleVectorData dvd, final SIUnit unit)
324     {
325         return new SIVector(dvd, unit);
326     }
327 
328     /** {@inheritDoc} */
329     @Override
330     public SIScalar instantiateScalarSI(final double valueSI, final SIUnit unit)
331     {
332         return new SIScalar(valueSI, unit);
333     }
334 
335     /** {@inheritDoc} */
336     @Override
337     public String toString(final SIUnit displayUnit, final boolean verbose, final boolean withUnit)
338     {
339         return super.toString(displayUnit, verbose, withUnit).replaceAll("!", "");
340     }
341 
342     /**********************************************************************************/
343     /******************************** 'CAST AS' METHODS *******************************/
344     /**********************************************************************************/
345 
346     /**
347      * Return the current vector as a absorbeddose vector.
348      * @return AbsorbedDoseVector; the current vector as a absorbeddose vector
349      */
350     public final AbsorbedDoseVector asAbsorbedDose()
351     {
352         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AbsorbedDoseUnit.BASE.getSiDimensions())),
353                 UnitRuntimeException.class, "cannot cast %s to AbsorbedDoseVector", this.toString());
354         return new AbsorbedDoseVector(this.data, AbsorbedDoseUnit.SI);
355     }
356 
357     /**
358      * Return the current vector as a absorbeddose vector, and provide a display unit.
359      * @param displayUnit the unit in which the value will be displayed
360      * @return AbsorbedDoseVector; the current vector as a absorbeddose vector
361      */
362     public final AbsorbedDoseVector asAbsorbedDose(final AbsorbedDoseUnit displayUnit)
363     {
364         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AbsorbedDoseUnit.BASE.getSiDimensions())),
365                 UnitRuntimeException.class, "cannot cast %s to AbsorbedDoseVector", this.toString());
366         AbsorbedDoseVector result = new AbsorbedDoseVector(this.data, displayUnit.getStandardUnit());
367         result.setDisplayUnit(displayUnit);
368         return result;
369     }
370 
371     /**
372      * Return the current vector as a acceleration vector.
373      * @return AccelerationVector; the current vector as a acceleration vector
374      */
375     public final AccelerationVector asAcceleration()
376     {
377         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AccelerationUnit.BASE.getSiDimensions())),
378                 UnitRuntimeException.class, "cannot cast %s to AccelerationVector", this.toString());
379         return new AccelerationVector(this.data, AccelerationUnit.SI);
380     }
381 
382     /**
383      * Return the current vector as a acceleration vector, and provide a display unit.
384      * @param displayUnit the unit in which the value will be displayed
385      * @return AccelerationVector; the current vector as a acceleration vector
386      */
387     public final AccelerationVector asAcceleration(final AccelerationUnit displayUnit)
388     {
389         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AccelerationUnit.BASE.getSiDimensions())),
390                 UnitRuntimeException.class, "cannot cast %s to AccelerationVector", this.toString());
391         AccelerationVector result = new AccelerationVector(this.data, displayUnit.getStandardUnit());
392         result.setDisplayUnit(displayUnit);
393         return result;
394     }
395 
396     /**
397      * Return the current vector as a amountofsubstance vector.
398      * @return AmountOfSubstanceVector; the current vector as a amountofsubstance vector
399      */
400     public final AmountOfSubstanceVector asAmountOfSubstance()
401     {
402         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AmountOfSubstanceUnit.BASE.getSiDimensions())),
403                 UnitRuntimeException.class, "cannot cast %s to AmountOfSubstanceVector", this.toString());
404         return new AmountOfSubstanceVector(this.data, AmountOfSubstanceUnit.SI);
405     }
406 
407     /**
408      * Return the current vector as a amountofsubstance vector, and provide a display unit.
409      * @param displayUnit the unit in which the value will be displayed
410      * @return AmountOfSubstanceVector; the current vector as a amountofsubstance vector
411      */
412     public final AmountOfSubstanceVector asAmountOfSubstance(final AmountOfSubstanceUnit displayUnit)
413     {
414         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AmountOfSubstanceUnit.BASE.getSiDimensions())),
415                 UnitRuntimeException.class, "cannot cast %s to AmountOfSubstanceVector", this.toString());
416         AmountOfSubstanceVector result = new AmountOfSubstanceVector(this.data, displayUnit.getStandardUnit());
417         result.setDisplayUnit(displayUnit);
418         return result;
419     }
420 
421     /**
422      * Return the current vector as a angularacceleration vector.
423      * @return AngularAccelerationVector; the current vector as a angularacceleration vector
424      */
425     public final AngularAccelerationVector asAngularAcceleration()
426     {
427         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularAccelerationUnit.BASE.getSiDimensions())),
428                 UnitRuntimeException.class, "cannot cast %s to AngularAccelerationVector", this.toString());
429         return new AngularAccelerationVector(this.data, AngularAccelerationUnit.SI);
430     }
431 
432     /**
433      * Return the current vector as a angularacceleration vector, and provide a display unit.
434      * @param displayUnit the unit in which the value will be displayed
435      * @return AngularAccelerationVector; the current vector as a angularacceleration vector
436      */
437     public final AngularAccelerationVector asAngularAcceleration(final AngularAccelerationUnit displayUnit)
438     {
439         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularAccelerationUnit.BASE.getSiDimensions())),
440                 UnitRuntimeException.class, "cannot cast %s to AngularAccelerationVector", this.toString());
441         AngularAccelerationVector result = new AngularAccelerationVector(this.data, displayUnit.getStandardUnit());
442         result.setDisplayUnit(displayUnit);
443         return result;
444     }
445 
446     /**
447      * Return the current vector as a angularvelocity vector.
448      * @return AngularVelocityVector; the current vector as a angularvelocity vector
449      */
450     public final AngularVelocityVector asAngularVelocity()
451     {
452         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularVelocityUnit.BASE.getSiDimensions())),
453                 UnitRuntimeException.class, "cannot cast %s to AngularVelocityVector", this.toString());
454         return new AngularVelocityVector(this.data, AngularVelocityUnit.SI);
455     }
456 
457     /**
458      * Return the current vector as a angularvelocity vector, and provide a display unit.
459      * @param displayUnit the unit in which the value will be displayed
460      * @return AngularVelocityVector; the current vector as a angularvelocity vector
461      */
462     public final AngularVelocityVector asAngularVelocity(final AngularVelocityUnit displayUnit)
463     {
464         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularVelocityUnit.BASE.getSiDimensions())),
465                 UnitRuntimeException.class, "cannot cast %s to AngularVelocityVector", this.toString());
466         AngularVelocityVector result = new AngularVelocityVector(this.data, displayUnit.getStandardUnit());
467         result.setDisplayUnit(displayUnit);
468         return result;
469     }
470 
471     /**
472      * Return the current vector as a area vector.
473      * @return AreaVector; the current vector as a area vector
474      */
475     public final AreaVector asArea()
476     {
477         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AreaUnit.BASE.getSiDimensions())),
478                 UnitRuntimeException.class, "cannot cast %s to AreaVector", this.toString());
479         return new AreaVector(this.data, AreaUnit.SI);
480     }
481 
482     /**
483      * Return the current vector as a area vector, and provide a display unit.
484      * @param displayUnit the unit in which the value will be displayed
485      * @return AreaVector; the current vector as a area vector
486      */
487     public final AreaVector asArea(final AreaUnit displayUnit)
488     {
489         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AreaUnit.BASE.getSiDimensions())),
490                 UnitRuntimeException.class, "cannot cast %s to AreaVector", this.toString());
491         AreaVector result = new AreaVector(this.data, displayUnit.getStandardUnit());
492         result.setDisplayUnit(displayUnit);
493         return result;
494     }
495 
496     /**
497      * Return the current vector as a catalyticactivity vector.
498      * @return CatalyticActivityVector; the current vector as a catalyticactivity vector
499      */
500     public final CatalyticActivityVector asCatalyticActivity()
501     {
502         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(CatalyticActivityUnit.BASE.getSiDimensions())),
503                 UnitRuntimeException.class, "cannot cast %s to CatalyticActivityVector", this.toString());
504         return new CatalyticActivityVector(this.data, CatalyticActivityUnit.SI);
505     }
506 
507     /**
508      * Return the current vector as a catalyticactivity vector, and provide a display unit.
509      * @param displayUnit the unit in which the value will be displayed
510      * @return CatalyticActivityVector; the current vector as a catalyticactivity vector
511      */
512     public final CatalyticActivityVector asCatalyticActivity(final CatalyticActivityUnit displayUnit)
513     {
514         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(CatalyticActivityUnit.BASE.getSiDimensions())),
515                 UnitRuntimeException.class, "cannot cast %s to CatalyticActivityVector", this.toString());
516         CatalyticActivityVector result = new CatalyticActivityVector(this.data, displayUnit.getStandardUnit());
517         result.setDisplayUnit(displayUnit);
518         return result;
519     }
520 
521     /**
522      * Return the current vector as a density vector.
523      * @return DensityVector; the current vector as a density vector
524      */
525     public final DensityVector asDensity()
526     {
527         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DensityUnit.BASE.getSiDimensions())),
528                 UnitRuntimeException.class, "cannot cast %s to DensityVector", this.toString());
529         return new DensityVector(this.data, DensityUnit.SI);
530     }
531 
532     /**
533      * Return the current vector as a density vector, and provide a display unit.
534      * @param displayUnit the unit in which the value will be displayed
535      * @return DensityVector; the current vector as a density vector
536      */
537     public final DensityVector asDensity(final DensityUnit displayUnit)
538     {
539         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DensityUnit.BASE.getSiDimensions())),
540                 UnitRuntimeException.class, "cannot cast %s to DensityVector", this.toString());
541         DensityVector result = new DensityVector(this.data, displayUnit.getStandardUnit());
542         result.setDisplayUnit(displayUnit);
543         return result;
544     }
545 
546     /**
547      * Return the current vector as a dimensionless vector.
548      * @return DimensionlessVector; the current vector as a dimensionless vector
549      */
550     public final DimensionlessVector asDimensionless()
551     {
552         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DimensionlessUnit.BASE.getSiDimensions())),
553                 UnitRuntimeException.class, "cannot cast %s to DimensionlessVector", this.toString());
554         return new DimensionlessVector(this.data, DimensionlessUnit.SI);
555     }
556 
557     /**
558      * Return the current vector as a dimensionless vector, and provide a display unit.
559      * @param displayUnit the unit in which the value will be displayed
560      * @return DimensionlessVector; the current vector as a dimensionless vector
561      */
562     public final DimensionlessVector asDimensionless(final DimensionlessUnit displayUnit)
563     {
564         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DimensionlessUnit.BASE.getSiDimensions())),
565                 UnitRuntimeException.class, "cannot cast %s to DimensionlessVector", this.toString());
566         DimensionlessVector result = new DimensionlessVector(this.data, displayUnit.getStandardUnit());
567         result.setDisplayUnit(displayUnit);
568         return result;
569     }
570 
571     /**
572      * Return the current vector as a electricalcapacitance vector.
573      * @return ElectricalCapacitanceVector; the current vector as a electricalcapacitance vector
574      */
575     public final ElectricalCapacitanceVector asElectricalCapacitance()
576     {
577         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCapacitanceUnit.BASE.getSiDimensions())),
578                 UnitRuntimeException.class, "cannot cast %s to ElectricalCapacitanceVector", this.toString());
579         return new ElectricalCapacitanceVector(this.data, ElectricalCapacitanceUnit.SI);
580     }
581 
582     /**
583      * Return the current vector as a electricalcapacitance vector, and provide a display unit.
584      * @param displayUnit the unit in which the value will be displayed
585      * @return ElectricalCapacitanceVector; the current vector as a electricalcapacitance vector
586      */
587     public final ElectricalCapacitanceVector asElectricalCapacitance(final ElectricalCapacitanceUnit displayUnit)
588     {
589         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCapacitanceUnit.BASE.getSiDimensions())),
590                 UnitRuntimeException.class, "cannot cast %s to ElectricalCapacitanceVector", this.toString());
591         ElectricalCapacitanceVector result = new ElectricalCapacitanceVector(this.data, displayUnit.getStandardUnit());
592         result.setDisplayUnit(displayUnit);
593         return result;
594     }
595 
596     /**
597      * Return the current vector as a electricalcharge vector.
598      * @return ElectricalChargeVector; the current vector as a electricalcharge vector
599      */
600     public final ElectricalChargeVector asElectricalCharge()
601     {
602         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalChargeUnit.BASE.getSiDimensions())),
603                 UnitRuntimeException.class, "cannot cast %s to ElectricalChargeVector", this.toString());
604         return new ElectricalChargeVector(this.data, ElectricalChargeUnit.SI);
605     }
606 
607     /**
608      * Return the current vector as a electricalcharge vector, and provide a display unit.
609      * @param displayUnit the unit in which the value will be displayed
610      * @return ElectricalChargeVector; the current vector as a electricalcharge vector
611      */
612     public final ElectricalChargeVector asElectricalCharge(final ElectricalChargeUnit displayUnit)
613     {
614         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalChargeUnit.BASE.getSiDimensions())),
615                 UnitRuntimeException.class, "cannot cast %s to ElectricalChargeVector", this.toString());
616         ElectricalChargeVector result = new ElectricalChargeVector(this.data, displayUnit.getStandardUnit());
617         result.setDisplayUnit(displayUnit);
618         return result;
619     }
620 
621     /**
622      * Return the current vector as a electricalconductance vector.
623      * @return ElectricalConductanceVector; the current vector as a electricalconductance vector
624      */
625     public final ElectricalConductanceVector asElectricalConductance()
626     {
627         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalConductanceUnit.BASE.getSiDimensions())),
628                 UnitRuntimeException.class, "cannot cast %s to ElectricalConductanceVector", this.toString());
629         return new ElectricalConductanceVector(this.data, ElectricalConductanceUnit.SI);
630     }
631 
632     /**
633      * Return the current vector as a electricalconductance vector, and provide a display unit.
634      * @param displayUnit the unit in which the value will be displayed
635      * @return ElectricalConductanceVector; the current vector as a electricalconductance vector
636      */
637     public final ElectricalConductanceVector asElectricalConductance(final ElectricalConductanceUnit displayUnit)
638     {
639         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalConductanceUnit.BASE.getSiDimensions())),
640                 UnitRuntimeException.class, "cannot cast %s to ElectricalConductanceVector", this.toString());
641         ElectricalConductanceVector result = new ElectricalConductanceVector(this.data, displayUnit.getStandardUnit());
642         result.setDisplayUnit(displayUnit);
643         return result;
644     }
645 
646     /**
647      * Return the current vector as a electricalcurrent vector.
648      * @return ElectricalCurrentVector; the current vector as a electricalcurrent vector
649      */
650     public final ElectricalCurrentVector asElectricalCurrent()
651     {
652         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCurrentUnit.BASE.getSiDimensions())),
653                 UnitRuntimeException.class, "cannot cast %s to ElectricalCurrentVector", this.toString());
654         return new ElectricalCurrentVector(this.data, ElectricalCurrentUnit.SI);
655     }
656 
657     /**
658      * Return the current vector as a electricalcurrent vector, and provide a display unit.
659      * @param displayUnit the unit in which the value will be displayed
660      * @return ElectricalCurrentVector; the current vector as a electricalcurrent vector
661      */
662     public final ElectricalCurrentVector asElectricalCurrent(final ElectricalCurrentUnit displayUnit)
663     {
664         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCurrentUnit.BASE.getSiDimensions())),
665                 UnitRuntimeException.class, "cannot cast %s to ElectricalCurrentVector", this.toString());
666         ElectricalCurrentVector result = new ElectricalCurrentVector(this.data, displayUnit.getStandardUnit());
667         result.setDisplayUnit(displayUnit);
668         return result;
669     }
670 
671     /**
672      * Return the current vector as a electricalinductance vector.
673      * @return ElectricalInductanceVector; the current vector as a electricalinductance vector
674      */
675     public final ElectricalInductanceVector asElectricalInductance()
676     {
677         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalInductanceUnit.BASE.getSiDimensions())),
678                 UnitRuntimeException.class, "cannot cast %s to ElectricalInductanceVector", this.toString());
679         return new ElectricalInductanceVector(this.data, ElectricalInductanceUnit.SI);
680     }
681 
682     /**
683      * Return the current vector as a electricalinductance vector, and provide a display unit.
684      * @param displayUnit the unit in which the value will be displayed
685      * @return ElectricalInductanceVector; the current vector as a electricalinductance vector
686      */
687     public final ElectricalInductanceVector asElectricalInductance(final ElectricalInductanceUnit displayUnit)
688     {
689         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalInductanceUnit.BASE.getSiDimensions())),
690                 UnitRuntimeException.class, "cannot cast %s to ElectricalInductanceVector", this.toString());
691         ElectricalInductanceVector result = new ElectricalInductanceVector(this.data, displayUnit.getStandardUnit());
692         result.setDisplayUnit(displayUnit);
693         return result;
694     }
695 
696     /**
697      * Return the current vector as a electricalpotential vector.
698      * @return ElectricalPotentialVector; the current vector as a electricalpotential vector
699      */
700     public final ElectricalPotentialVector asElectricalPotential()
701     {
702         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalPotentialUnit.BASE.getSiDimensions())),
703                 UnitRuntimeException.class, "cannot cast %s to ElectricalPotentialVector", this.toString());
704         return new ElectricalPotentialVector(this.data, ElectricalPotentialUnit.SI);
705     }
706 
707     /**
708      * Return the current vector as a electricalpotential vector, and provide a display unit.
709      * @param displayUnit the unit in which the value will be displayed
710      * @return ElectricalPotentialVector; the current vector as a electricalpotential vector
711      */
712     public final ElectricalPotentialVector asElectricalPotential(final ElectricalPotentialUnit displayUnit)
713     {
714         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalPotentialUnit.BASE.getSiDimensions())),
715                 UnitRuntimeException.class, "cannot cast %s to ElectricalPotentialVector", this.toString());
716         ElectricalPotentialVector result = new ElectricalPotentialVector(this.data, displayUnit.getStandardUnit());
717         result.setDisplayUnit(displayUnit);
718         return result;
719     }
720 
721     /**
722      * Return the current vector as a electricalresistance vector.
723      * @return ElectricalResistanceVector; the current vector as a electricalresistance vector
724      */
725     public final ElectricalResistanceVector asElectricalResistance()
726     {
727         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalResistanceUnit.BASE.getSiDimensions())),
728                 UnitRuntimeException.class, "cannot cast %s to ElectricalResistanceVector", this.toString());
729         return new ElectricalResistanceVector(this.data, ElectricalResistanceUnit.SI);
730     }
731 
732     /**
733      * Return the current vector as a electricalresistance vector, and provide a display unit.
734      * @param displayUnit the unit in which the value will be displayed
735      * @return ElectricalResistanceVector; the current vector as a electricalresistance vector
736      */
737     public final ElectricalResistanceVector asElectricalResistance(final ElectricalResistanceUnit displayUnit)
738     {
739         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalResistanceUnit.BASE.getSiDimensions())),
740                 UnitRuntimeException.class, "cannot cast %s to ElectricalResistanceVector", this.toString());
741         ElectricalResistanceVector result = new ElectricalResistanceVector(this.data, displayUnit.getStandardUnit());
742         result.setDisplayUnit(displayUnit);
743         return result;
744     }
745 
746     /**
747      * Return the current vector as a energy vector.
748      * @return EnergyVector; the current vector as a energy vector
749      */
750     public final EnergyVector asEnergy()
751     {
752         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EnergyUnit.BASE.getSiDimensions())),
753                 UnitRuntimeException.class, "cannot cast %s to EnergyVector", this.toString());
754         return new EnergyVector(this.data, EnergyUnit.SI);
755     }
756 
757     /**
758      * Return the current vector as a energy vector, and provide a display unit.
759      * @param displayUnit the unit in which the value will be displayed
760      * @return EnergyVector; the current vector as a energy vector
761      */
762     public final EnergyVector asEnergy(final EnergyUnit displayUnit)
763     {
764         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EnergyUnit.BASE.getSiDimensions())),
765                 UnitRuntimeException.class, "cannot cast %s to EnergyVector", this.toString());
766         EnergyVector result = new EnergyVector(this.data, displayUnit.getStandardUnit());
767         result.setDisplayUnit(displayUnit);
768         return result;
769     }
770 
771     /**
772      * Return the current vector as a equivalentdose vector.
773      * @return EquivalentDoseVector; the current vector as a equivalentdose vector
774      */
775     public final EquivalentDoseVector asEquivalentDose()
776     {
777         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EquivalentDoseUnit.BASE.getSiDimensions())),
778                 UnitRuntimeException.class, "cannot cast %s to EquivalentDoseVector", this.toString());
779         return new EquivalentDoseVector(this.data, EquivalentDoseUnit.SI);
780     }
781 
782     /**
783      * Return the current vector as a equivalentdose vector, and provide a display unit.
784      * @param displayUnit the unit in which the value will be displayed
785      * @return EquivalentDoseVector; the current vector as a equivalentdose vector
786      */
787     public final EquivalentDoseVector asEquivalentDose(final EquivalentDoseUnit displayUnit)
788     {
789         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EquivalentDoseUnit.BASE.getSiDimensions())),
790                 UnitRuntimeException.class, "cannot cast %s to EquivalentDoseVector", this.toString());
791         EquivalentDoseVector result = new EquivalentDoseVector(this.data, displayUnit.getStandardUnit());
792         result.setDisplayUnit(displayUnit);
793         return result;
794     }
795 
796     /**
797      * Return the current vector as a flowmass vector.
798      * @return FlowMassVector; the current vector as a flowmass vector
799      */
800     public final FlowMassVector asFlowMass()
801     {
802         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowMassUnit.BASE.getSiDimensions())),
803                 UnitRuntimeException.class, "cannot cast %s to FlowMassVector", this.toString());
804         return new FlowMassVector(this.data, FlowMassUnit.SI);
805     }
806 
807     /**
808      * Return the current vector as a flowmass vector, and provide a display unit.
809      * @param displayUnit the unit in which the value will be displayed
810      * @return FlowMassVector; the current vector as a flowmass vector
811      */
812     public final FlowMassVector asFlowMass(final FlowMassUnit displayUnit)
813     {
814         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowMassUnit.BASE.getSiDimensions())),
815                 UnitRuntimeException.class, "cannot cast %s to FlowMassVector", this.toString());
816         FlowMassVector result = new FlowMassVector(this.data, displayUnit.getStandardUnit());
817         result.setDisplayUnit(displayUnit);
818         return result;
819     }
820 
821     /**
822      * Return the current vector as a flowvolume vector.
823      * @return FlowVolumeVector; the current vector as a flowvolume vector
824      */
825     public final FlowVolumeVector asFlowVolume()
826     {
827         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowVolumeUnit.BASE.getSiDimensions())),
828                 UnitRuntimeException.class, "cannot cast %s to FlowVolumeVector", this.toString());
829         return new FlowVolumeVector(this.data, FlowVolumeUnit.SI);
830     }
831 
832     /**
833      * Return the current vector as a flowvolume vector, and provide a display unit.
834      * @param displayUnit the unit in which the value will be displayed
835      * @return FlowVolumeVector; the current vector as a flowvolume vector
836      */
837     public final FlowVolumeVector asFlowVolume(final FlowVolumeUnit displayUnit)
838     {
839         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowVolumeUnit.BASE.getSiDimensions())),
840                 UnitRuntimeException.class, "cannot cast %s to FlowVolumeVector", this.toString());
841         FlowVolumeVector result = new FlowVolumeVector(this.data, displayUnit.getStandardUnit());
842         result.setDisplayUnit(displayUnit);
843         return result;
844     }
845 
846     /**
847      * Return the current vector as a force vector.
848      * @return ForceVector; the current vector as a force vector
849      */
850     public final ForceVector asForce()
851     {
852         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ForceUnit.BASE.getSiDimensions())),
853                 UnitRuntimeException.class, "cannot cast %s to ForceVector", this.toString());
854         return new ForceVector(this.data, ForceUnit.SI);
855     }
856 
857     /**
858      * Return the current vector as a force vector, and provide a display unit.
859      * @param displayUnit the unit in which the value will be displayed
860      * @return ForceVector; the current vector as a force vector
861      */
862     public final ForceVector asForce(final ForceUnit displayUnit)
863     {
864         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ForceUnit.BASE.getSiDimensions())),
865                 UnitRuntimeException.class, "cannot cast %s to ForceVector", this.toString());
866         ForceVector result = new ForceVector(this.data, displayUnit.getStandardUnit());
867         result.setDisplayUnit(displayUnit);
868         return result;
869     }
870 
871     /**
872      * Return the current vector as a frequency vector.
873      * @return FrequencyVector; the current vector as a frequency vector
874      */
875     public final FrequencyVector asFrequency()
876     {
877         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FrequencyUnit.BASE.getSiDimensions())),
878                 UnitRuntimeException.class, "cannot cast %s to FrequencyVector", this.toString());
879         return new FrequencyVector(this.data, FrequencyUnit.SI);
880     }
881 
882     /**
883      * Return the current vector as a frequency vector, and provide a display unit.
884      * @param displayUnit the unit in which the value will be displayed
885      * @return FrequencyVector; the current vector as a frequency vector
886      */
887     public final FrequencyVector asFrequency(final FrequencyUnit displayUnit)
888     {
889         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FrequencyUnit.BASE.getSiDimensions())),
890                 UnitRuntimeException.class, "cannot cast %s to FrequencyVector", this.toString());
891         FrequencyVector result = new FrequencyVector(this.data, displayUnit.getStandardUnit());
892         result.setDisplayUnit(displayUnit);
893         return result;
894     }
895 
896     /**
897      * Return the current vector as a illuminance vector.
898      * @return IlluminanceVector; the current vector as a illuminance vector
899      */
900     public final IlluminanceVector asIlluminance()
901     {
902         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(IlluminanceUnit.BASE.getSiDimensions())),
903                 UnitRuntimeException.class, "cannot cast %s to IlluminanceVector", this.toString());
904         return new IlluminanceVector(this.data, IlluminanceUnit.SI);
905     }
906 
907     /**
908      * Return the current vector as a illuminance vector, and provide a display unit.
909      * @param displayUnit the unit in which the value will be displayed
910      * @return IlluminanceVector; the current vector as a illuminance vector
911      */
912     public final IlluminanceVector asIlluminance(final IlluminanceUnit displayUnit)
913     {
914         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(IlluminanceUnit.BASE.getSiDimensions())),
915                 UnitRuntimeException.class, "cannot cast %s to IlluminanceVector", this.toString());
916         IlluminanceVector result = new IlluminanceVector(this.data, displayUnit.getStandardUnit());
917         result.setDisplayUnit(displayUnit);
918         return result;
919     }
920 
921     /**
922      * Return the current vector as a lineardensity vector.
923      * @return LinearDensityVector; the current vector as a lineardensity vector
924      */
925     public final LinearDensityVector asLinearDensity()
926     {
927         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LinearDensityUnit.BASE.getSiDimensions())),
928                 UnitRuntimeException.class, "cannot cast %s to LinearDensityVector", this.toString());
929         return new LinearDensityVector(this.data, LinearDensityUnit.SI);
930     }
931 
932     /**
933      * Return the current vector as a lineardensity vector, and provide a display unit.
934      * @param displayUnit the unit in which the value will be displayed
935      * @return LinearDensityVector; the current vector as a lineardensity vector
936      */
937     public final LinearDensityVector asLinearDensity(final LinearDensityUnit displayUnit)
938     {
939         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LinearDensityUnit.BASE.getSiDimensions())),
940                 UnitRuntimeException.class, "cannot cast %s to LinearDensityVector", this.toString());
941         LinearDensityVector result = new LinearDensityVector(this.data, displayUnit.getStandardUnit());
942         result.setDisplayUnit(displayUnit);
943         return result;
944     }
945 
946     /**
947      * Return the current vector as a luminousflux vector.
948      * @return LuminousFluxVector; the current vector as a luminousflux vector
949      */
950     public final LuminousFluxVector asLuminousFlux()
951     {
952         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousFluxUnit.BASE.getSiDimensions())),
953                 UnitRuntimeException.class, "cannot cast %s to LuminousFluxVector", this.toString());
954         return new LuminousFluxVector(this.data, LuminousFluxUnit.SI);
955     }
956 
957     /**
958      * Return the current vector as a luminousflux vector, and provide a display unit.
959      * @param displayUnit the unit in which the value will be displayed
960      * @return LuminousFluxVector; the current vector as a luminousflux vector
961      */
962     public final LuminousFluxVector asLuminousFlux(final LuminousFluxUnit displayUnit)
963     {
964         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousFluxUnit.BASE.getSiDimensions())),
965                 UnitRuntimeException.class, "cannot cast %s to LuminousFluxVector", this.toString());
966         LuminousFluxVector result = new LuminousFluxVector(this.data, displayUnit.getStandardUnit());
967         result.setDisplayUnit(displayUnit);
968         return result;
969     }
970 
971     /**
972      * Return the current vector as a luminousintensity vector.
973      * @return LuminousIntensityVector; the current vector as a luminousintensity vector
974      */
975     public final LuminousIntensityVector asLuminousIntensity()
976     {
977         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousIntensityUnit.BASE.getSiDimensions())),
978                 UnitRuntimeException.class, "cannot cast %s to LuminousIntensityVector", this.toString());
979         return new LuminousIntensityVector(this.data, LuminousIntensityUnit.SI);
980     }
981 
982     /**
983      * Return the current vector as a luminousintensity vector, and provide a display unit.
984      * @param displayUnit the unit in which the value will be displayed
985      * @return LuminousIntensityVector; the current vector as a luminousintensity vector
986      */
987     public final LuminousIntensityVector asLuminousIntensity(final LuminousIntensityUnit displayUnit)
988     {
989         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousIntensityUnit.BASE.getSiDimensions())),
990                 UnitRuntimeException.class, "cannot cast %s to LuminousIntensityVector", this.toString());
991         LuminousIntensityVector result = new LuminousIntensityVector(this.data, displayUnit.getStandardUnit());
992         result.setDisplayUnit(displayUnit);
993         return result;
994     }
995 
996     /**
997      * Return the current vector as a magneticfluxdensity vector.
998      * @return MagneticFluxDensityVector; the current vector as a magneticfluxdensity vector
999      */
1000     public final MagneticFluxDensityVector asMagneticFluxDensity()
1001     {
1002         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxDensityUnit.BASE.getSiDimensions())),
1003                 UnitRuntimeException.class, "cannot cast %s to MagneticFluxDensityVector", this.toString());
1004         return new MagneticFluxDensityVector(this.data, MagneticFluxDensityUnit.SI);
1005     }
1006 
1007     /**
1008      * Return the current vector as a magneticfluxdensity vector, and provide a display unit.
1009      * @param displayUnit the unit in which the value will be displayed
1010      * @return MagneticFluxDensityVector; the current vector as a magneticfluxdensity vector
1011      */
1012     public final MagneticFluxDensityVector asMagneticFluxDensity(final MagneticFluxDensityUnit displayUnit)
1013     {
1014         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxDensityUnit.BASE.getSiDimensions())),
1015                 UnitRuntimeException.class, "cannot cast %s to MagneticFluxDensityVector", this.toString());
1016         MagneticFluxDensityVector result = new MagneticFluxDensityVector(this.data, displayUnit.getStandardUnit());
1017         result.setDisplayUnit(displayUnit);
1018         return result;
1019     }
1020 
1021     /**
1022      * Return the current vector as a magneticflux vector.
1023      * @return MagneticFluxVector; the current vector as a magneticflux vector
1024      */
1025     public final MagneticFluxVector asMagneticFlux()
1026     {
1027         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxUnit.BASE.getSiDimensions())),
1028                 UnitRuntimeException.class, "cannot cast %s to MagneticFluxVector", this.toString());
1029         return new MagneticFluxVector(this.data, MagneticFluxUnit.SI);
1030     }
1031 
1032     /**
1033      * Return the current vector as a magneticflux vector, and provide a display unit.
1034      * @param displayUnit the unit in which the value will be displayed
1035      * @return MagneticFluxVector; the current vector as a magneticflux vector
1036      */
1037     public final MagneticFluxVector asMagneticFlux(final MagneticFluxUnit displayUnit)
1038     {
1039         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxUnit.BASE.getSiDimensions())),
1040                 UnitRuntimeException.class, "cannot cast %s to MagneticFluxVector", this.toString());
1041         MagneticFluxVector result = new MagneticFluxVector(this.data, displayUnit.getStandardUnit());
1042         result.setDisplayUnit(displayUnit);
1043         return result;
1044     }
1045 
1046     /**
1047      * Return the current vector as a mass vector.
1048      * @return MassVector; the current vector as a mass vector
1049      */
1050     public final MassVector asMass()
1051     {
1052         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MassUnit.BASE.getSiDimensions())),
1053                 UnitRuntimeException.class, "cannot cast %s to MassVector", this.toString());
1054         return new MassVector(this.data, MassUnit.SI);
1055     }
1056 
1057     /**
1058      * Return the current vector as a mass vector, and provide a display unit.
1059      * @param displayUnit the unit in which the value will be displayed
1060      * @return MassVector; the current vector as a mass vector
1061      */
1062     public final MassVector asMass(final MassUnit displayUnit)
1063     {
1064         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MassUnit.BASE.getSiDimensions())),
1065                 UnitRuntimeException.class, "cannot cast %s to MassVector", this.toString());
1066         MassVector result = new MassVector(this.data, displayUnit.getStandardUnit());
1067         result.setDisplayUnit(displayUnit);
1068         return result;
1069     }
1070 
1071     /**
1072      * Return the current vector as a momentum vector.
1073      * @return MomentumVector; the current vector as a momentum vector
1074      */
1075     public final MomentumVector asMomentum()
1076     {
1077         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MomentumUnit.BASE.getSiDimensions())),
1078                 UnitRuntimeException.class, "cannot cast %s to MomentumVector", this.toString());
1079         return new MomentumVector(this.data, MomentumUnit.SI);
1080     }
1081 
1082     /**
1083      * Return the current vector as a momentum vector, and provide a display unit.
1084      * @param displayUnit the unit in which the value will be displayed
1085      * @return MomentumVector; the current vector as a momentum vector
1086      */
1087     public final MomentumVector asMomentum(final MomentumUnit displayUnit)
1088     {
1089         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MomentumUnit.BASE.getSiDimensions())),
1090                 UnitRuntimeException.class, "cannot cast %s to MomentumVector", this.toString());
1091         MomentumVector result = new MomentumVector(this.data, displayUnit.getStandardUnit());
1092         result.setDisplayUnit(displayUnit);
1093         return result;
1094     }
1095 
1096     /**
1097      * Return the current vector as a power vector.
1098      * @return PowerVector; the current vector as a power vector
1099      */
1100     public final PowerVector asPower()
1101     {
1102         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PowerUnit.BASE.getSiDimensions())),
1103                 UnitRuntimeException.class, "cannot cast %s to PowerVector", this.toString());
1104         return new PowerVector(this.data, PowerUnit.SI);
1105     }
1106 
1107     /**
1108      * Return the current vector as a power vector, and provide a display unit.
1109      * @param displayUnit the unit in which the value will be displayed
1110      * @return PowerVector; the current vector as a power vector
1111      */
1112     public final PowerVector asPower(final PowerUnit displayUnit)
1113     {
1114         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PowerUnit.BASE.getSiDimensions())),
1115                 UnitRuntimeException.class, "cannot cast %s to PowerVector", this.toString());
1116         PowerVector result = new PowerVector(this.data, displayUnit.getStandardUnit());
1117         result.setDisplayUnit(displayUnit);
1118         return result;
1119     }
1120 
1121     /**
1122      * Return the current vector as a pressure vector.
1123      * @return PressureVector; the current vector as a pressure vector
1124      */
1125     public final PressureVector asPressure()
1126     {
1127         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PressureUnit.BASE.getSiDimensions())),
1128                 UnitRuntimeException.class, "cannot cast %s to PressureVector", this.toString());
1129         return new PressureVector(this.data, PressureUnit.SI);
1130     }
1131 
1132     /**
1133      * Return the current vector as a pressure vector, and provide a display unit.
1134      * @param displayUnit the unit in which the value will be displayed
1135      * @return PressureVector; the current vector as a pressure vector
1136      */
1137     public final PressureVector asPressure(final PressureUnit displayUnit)
1138     {
1139         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PressureUnit.BASE.getSiDimensions())),
1140                 UnitRuntimeException.class, "cannot cast %s to PressureVector", this.toString());
1141         PressureVector result = new PressureVector(this.data, displayUnit.getStandardUnit());
1142         result.setDisplayUnit(displayUnit);
1143         return result;
1144     }
1145 
1146     /**
1147      * Return the current vector as a radioactivity vector.
1148      * @return RadioActivityVector; the current vector as a radioactivity vector
1149      */
1150     public final RadioActivityVector asRadioActivity()
1151     {
1152         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(RadioActivityUnit.BASE.getSiDimensions())),
1153                 UnitRuntimeException.class, "cannot cast %s to RadioActivityVector", this.toString());
1154         return new RadioActivityVector(this.data, RadioActivityUnit.SI);
1155     }
1156 
1157     /**
1158      * Return the current vector as a radioactivity vector, and provide a display unit.
1159      * @param displayUnit the unit in which the value will be displayed
1160      * @return RadioActivityVector; the current vector as a radioactivity vector
1161      */
1162     public final RadioActivityVector asRadioActivity(final RadioActivityUnit displayUnit)
1163     {
1164         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(RadioActivityUnit.BASE.getSiDimensions())),
1165                 UnitRuntimeException.class, "cannot cast %s to RadioActivityVector", this.toString());
1166         RadioActivityVector result = new RadioActivityVector(this.data, displayUnit.getStandardUnit());
1167         result.setDisplayUnit(displayUnit);
1168         return result;
1169     }
1170 
1171     /**
1172      * Return the current vector as a solidangle vector.
1173      * @return SolidAngleVector; the current vector as a solidangle vector
1174      */
1175     public final SolidAngleVector asSolidAngle()
1176     {
1177         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SolidAngleUnit.BASE.getSiDimensions())),
1178                 UnitRuntimeException.class, "cannot cast %s to SolidAngleVector", this.toString());
1179         return new SolidAngleVector(this.data, SolidAngleUnit.SI);
1180     }
1181 
1182     /**
1183      * Return the current vector as a solidangle vector, and provide a display unit.
1184      * @param displayUnit the unit in which the value will be displayed
1185      * @return SolidAngleVector; the current vector as a solidangle vector
1186      */
1187     public final SolidAngleVector asSolidAngle(final SolidAngleUnit displayUnit)
1188     {
1189         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SolidAngleUnit.BASE.getSiDimensions())),
1190                 UnitRuntimeException.class, "cannot cast %s to SolidAngleVector", this.toString());
1191         SolidAngleVector result = new SolidAngleVector(this.data, displayUnit.getStandardUnit());
1192         result.setDisplayUnit(displayUnit);
1193         return result;
1194     }
1195 
1196     /**
1197      * Return the current vector as a speed vector.
1198      * @return SpeedVector; the current vector as a speed vector
1199      */
1200     public final SpeedVector asSpeed()
1201     {
1202         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SpeedUnit.BASE.getSiDimensions())),
1203                 UnitRuntimeException.class, "cannot cast %s to SpeedVector", this.toString());
1204         return new SpeedVector(this.data, SpeedUnit.SI);
1205     }
1206 
1207     /**
1208      * Return the current vector as a speed vector, and provide a display unit.
1209      * @param displayUnit the unit in which the value will be displayed
1210      * @return SpeedVector; the current vector as a speed vector
1211      */
1212     public final SpeedVector asSpeed(final SpeedUnit displayUnit)
1213     {
1214         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SpeedUnit.BASE.getSiDimensions())),
1215                 UnitRuntimeException.class, "cannot cast %s to SpeedVector", this.toString());
1216         SpeedVector result = new SpeedVector(this.data, displayUnit.getStandardUnit());
1217         result.setDisplayUnit(displayUnit);
1218         return result;
1219     }
1220 
1221     /**
1222      * Return the current vector as a torque vector.
1223      * @return TorqueVector; the current vector as a torque vector
1224      */
1225     public final TorqueVector asTorque()
1226     {
1227         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TorqueUnit.BASE.getSiDimensions())),
1228                 UnitRuntimeException.class, "cannot cast %s to TorqueVector", this.toString());
1229         return new TorqueVector(this.data, TorqueUnit.SI);
1230     }
1231 
1232     /**
1233      * Return the current vector as a torque vector, and provide a display unit.
1234      * @param displayUnit the unit in which the value will be displayed
1235      * @return TorqueVector; the current vector as a torque vector
1236      */
1237     public final TorqueVector asTorque(final TorqueUnit displayUnit)
1238     {
1239         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TorqueUnit.BASE.getSiDimensions())),
1240                 UnitRuntimeException.class, "cannot cast %s to TorqueVector", this.toString());
1241         TorqueVector result = new TorqueVector(this.data, displayUnit.getStandardUnit());
1242         result.setDisplayUnit(displayUnit);
1243         return result;
1244     }
1245 
1246     /**
1247      * Return the current vector as a volume vector.
1248      * @return VolumeVector; the current vector as a volume vector
1249      */
1250     public final VolumeVector asVolume()
1251     {
1252         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(VolumeUnit.BASE.getSiDimensions())),
1253                 UnitRuntimeException.class, "cannot cast %s to VolumeVector", this.toString());
1254         return new VolumeVector(this.data, VolumeUnit.SI);
1255     }
1256 
1257     /**
1258      * Return the current vector as a volume vector, and provide a display unit.
1259      * @param displayUnit the unit in which the value will be displayed
1260      * @return VolumeVector; the current vector as a volume vector
1261      */
1262     public final VolumeVector asVolume(final VolumeUnit displayUnit)
1263     {
1264         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(VolumeUnit.BASE.getSiDimensions())),
1265                 UnitRuntimeException.class, "cannot cast %s to VolumeVector", this.toString());
1266         VolumeVector result = new VolumeVector(this.data, displayUnit.getStandardUnit());
1267         result.setDisplayUnit(displayUnit);
1268         return result;
1269     }
1270 
1271     /**
1272      * Return the current vector as a angle vector.
1273      * @return AngleVector; the current vector as a angle vector
1274      */
1275     public final AngleVector asAngle()
1276     {
1277         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngleUnit.BASE.getSiDimensions())),
1278                 UnitRuntimeException.class, "cannot cast %s to AngleVector", this.toString());
1279         return new AngleVector(this.data, AngleUnit.SI);
1280     }
1281 
1282     /**
1283      * Return the current vector as a angle vector, and provide a display unit.
1284      * @param displayUnit the unit in which the value will be displayed
1285      * @return AngleVector; the current vector as a angle vector
1286      */
1287     public final AngleVector asAngle(final AngleUnit displayUnit)
1288     {
1289         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngleUnit.BASE.getSiDimensions())),
1290                 UnitRuntimeException.class, "cannot cast %s to AngleVector", this.toString());
1291         AngleVector result = new AngleVector(this.data, displayUnit.getStandardUnit());
1292         result.setDisplayUnit(displayUnit);
1293         return result;
1294     }
1295 
1296     /**
1297      * Return the current vector as a length vector.
1298      * @return LengthVector; the current vector as a length vector
1299      */
1300     public final LengthVector asLength()
1301     {
1302         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LengthUnit.BASE.getSiDimensions())),
1303                 UnitRuntimeException.class, "cannot cast %s to LengthVector", this.toString());
1304         return new LengthVector(this.data, LengthUnit.SI);
1305     }
1306 
1307     /**
1308      * Return the current vector as a length vector, and provide a display unit.
1309      * @param displayUnit the unit in which the value will be displayed
1310      * @return LengthVector; the current vector as a length vector
1311      */
1312     public final LengthVector asLength(final LengthUnit displayUnit)
1313     {
1314         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LengthUnit.BASE.getSiDimensions())),
1315                 UnitRuntimeException.class, "cannot cast %s to LengthVector", this.toString());
1316         LengthVector result = new LengthVector(this.data, displayUnit.getStandardUnit());
1317         result.setDisplayUnit(displayUnit);
1318         return result;
1319     }
1320 
1321     /**
1322      * Return the current vector as a temperature vector.
1323      * @return TemperatureVector; the current vector as a temperature vector
1324      */
1325     public final TemperatureVector asTemperature()
1326     {
1327         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TemperatureUnit.BASE.getSiDimensions())),
1328                 UnitRuntimeException.class, "cannot cast %s to TemperatureVector", this.toString());
1329         return new TemperatureVector(this.data, TemperatureUnit.SI);
1330     }
1331 
1332     /**
1333      * Return the current vector as a temperature vector, and provide a display unit.
1334      * @param displayUnit the unit in which the value will be displayed
1335      * @return TemperatureVector; the current vector as a temperature vector
1336      */
1337     public final TemperatureVector asTemperature(final TemperatureUnit displayUnit)
1338     {
1339         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TemperatureUnit.BASE.getSiDimensions())),
1340                 UnitRuntimeException.class, "cannot cast %s to TemperatureVector", this.toString());
1341         TemperatureVector result = new TemperatureVector(this.data, displayUnit.getStandardUnit());
1342         result.setDisplayUnit(displayUnit);
1343         return result;
1344     }
1345 
1346     /**
1347      * Return the current vector as a duration vector.
1348      * @return DurationVector; the current vector as a duration vector
1349      */
1350     public final DurationVector asDuration()
1351     {
1352         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DurationUnit.BASE.getSiDimensions())),
1353                 UnitRuntimeException.class, "cannot cast %s to DurationVector", this.toString());
1354         return new DurationVector(this.data, DurationUnit.SI);
1355     }
1356 
1357     /**
1358      * Return the current vector as a duration vector, and provide a display unit.
1359      * @param displayUnit the unit in which the value will be displayed
1360      * @return DurationVector; the current vector as a duration vector
1361      */
1362     public final DurationVector asDuration(final DurationUnit displayUnit)
1363     {
1364         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DurationUnit.BASE.getSiDimensions())),
1365                 UnitRuntimeException.class, "cannot cast %s to DurationVector", this.toString());
1366         DurationVector result = new DurationVector(this.data, displayUnit.getStandardUnit());
1367         result.setDisplayUnit(displayUnit);
1368         return result;
1369     }
1370 
1371 }