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.ElectricalCurrentUnit;
7   import org.djunits.unit.scale.IdentityScale;
8   import org.djunits.value.storage.StorageType;
9   import org.djunits.value.vdouble.scalar.ElectricalCurrent;
10  import org.djunits.value.vdouble.vector.base.DoubleVectorRel;
11  import org.djunits.value.vdouble.vector.data.DoubleVectorData;
12  
13  import jakarta.annotation.Generated;
14  
15  /**
16   * Double ElectricalCurrentVector, a vector of values with a ElectricalCurrentUnit.
17   * <p>
18   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
19   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
20   * </p>
21   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
22   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
23   */
24  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
25  public class ElectricalCurrentVector extends DoubleVectorRel<ElectricalCurrentUnit, ElectricalCurrent, ElectricalCurrentVector>
26  
27  {
28      /** */
29      private static final long serialVersionUID = 20190905L;
30  
31      /**
32       * Construct an ElectricalCurrentVector from an internal data object.
33       * @param data DoubleVectorData; the internal data object for the vector
34       * @param displayUnit ElectricalCurrentUnit; the display unit of the vector data
35       */
36      public ElectricalCurrentVector(final DoubleVectorData data, final ElectricalCurrentUnit displayUnit)
37      {
38          super(data, displayUnit);
39      }
40  
41      /* CONSTRUCTORS WITH double[] */
42  
43      /**
44       * Construct an ElectricalCurrentVector from a double[] object. The double values are expressed in the displayUnit, and will
45       * be printed using the displayUnit.
46       * @param data double[]; the data for the vector, expressed in the displayUnit
47       * @param displayUnit ElectricalCurrentUnit; the unit of the values in the data array, and display unit when printing
48       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
49       */
50      public ElectricalCurrentVector(final double[] data, final ElectricalCurrentUnit displayUnit, final StorageType storageType)
51      {
52          this(DoubleVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
53      }
54  
55      /**
56       * Construct an ElectricalCurrentVector from a double[] object. The double values are expressed in the displayUnit. Assume
57       * that the StorageType is DENSE since we offer the data as an array.
58       * @param data double[]; the data for the vector
59       * @param displayUnit ElectricalCurrentUnit; the unit of the values in the data array, and display unit when printing
60       */
61      public ElectricalCurrentVector(final double[] data, final ElectricalCurrentUnit displayUnit)
62      {
63          this(data, displayUnit, StorageType.DENSE);
64      }
65  
66      /**
67       * Construct an ElectricalCurrentVector from a double[] object with SI-unit values.
68       * @param data double[]; the data for the vector, in SI units
69       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
70       */
71      public ElectricalCurrentVector(final double[] data, final StorageType storageType)
72      {
73          this(data, ElectricalCurrentUnit.SI, storageType);
74      }
75  
76      /**
77       * Construct an ElectricalCurrentVector from a double[] object with SI-unit values. Assume that the StorageType is DENSE
78       * since we offer the data as an array.
79       * @param data double[]; the data for the vector, in SI units
80       */
81      public ElectricalCurrentVector(final double[] data)
82      {
83          this(data, StorageType.DENSE);
84      }
85  
86      /* CONSTRUCTORS WITH ElectricalCurrent[] */
87  
88      /**
89       * Construct an ElectricalCurrentVector from an array of ElectricalCurrent objects. The ElectricalCurrent values are each
90       * expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing.
91       * @param data ElectricalCurrent[]; the data for the vector
92       * @param displayUnit ElectricalCurrentUnit; the display unit of the values when printing
93       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
94       */
95      public ElectricalCurrentVector(final ElectricalCurrent[] data, final ElectricalCurrentUnit displayUnit,
96              final StorageType storageType)
97      {
98          this(DoubleVectorData.instantiate(data, storageType), displayUnit);
99      }
100 
101     /**
102      * Construct an ElectricalCurrentVector from an array of ElectricalCurrent objects. The ElectricalCurrent values are each
103      * expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing.
104      * Assume that the StorageType is DENSE since we offer the data as an array.
105      * @param data ElectricalCurrent[]; the data for the vector
106      * @param displayUnit ElectricalCurrentUnit; the display unit of the values when printing
107      */
108     public ElectricalCurrentVector(final ElectricalCurrent[] data, final ElectricalCurrentUnit displayUnit)
109     {
110         this(data, displayUnit, StorageType.DENSE);
111     }
112 
113     /**
114      * Construct an ElectricalCurrentVector from an array of ElectricalCurrent objects. The ElectricalCurrent values are each
115      * expressed in their own unit, but will be internally stored as SI values, and expressed using SI units when printing.
116      * since we offer the data as an array.
117      * @param data ElectricalCurrent[]; the data for the vector
118      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
119      */
120     public ElectricalCurrentVector(final ElectricalCurrent[] data, final StorageType storageType)
121     {
122         this(data, ElectricalCurrentUnit.SI, storageType);
123     }
124 
125     /**
126      * Construct an ElectricalCurrentVector from an array of ElectricalCurrent objects. The ElectricalCurrent values are each
127      * expressed in their own unit, but will be internally stored as SI values, and expressed using SI units when printing.
128      * Assume that the StorageType is DENSE since we offer the data as an array.
129      * @param data ElectricalCurrent[]; the data for the vector
130      */
131     public ElectricalCurrentVector(final ElectricalCurrent[] data)
132     {
133         this(data, StorageType.DENSE);
134     }
135 
136     /* CONSTRUCTORS WITH List<Double> or List<ElectricalCurrent> */
137 
138     /**
139      * Construct an ElectricalCurrentVector from a list of Number objects or a list of ElectricalCurrent objects. Note that the
140      * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Double objects) or
141      * ElectricalCurrent objects. In case the list contains Number objects, the displayUnit indicates the unit in which the
142      * values in the list are expressed, as well as the unit in which they will be printed. In case the list contains
143      * ElectricalCurrent objects, each ElectricalCurrent has its own unit, and the displayUnit is just used for printing. The
144      * values but will always be internally stored as SI values or base values, and expressed using the display unit or base
145      * unit when printing.
146      * @param data List&lt;Double&gt; or List&lt;ElectricalCurrent&gt;; the data for the vector
147      * @param displayUnit ElectricalCurrentUnit; the display unit of the vector data, and the unit of the data points when the
148      *            data is 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 ElectricalCurrentVector(final List<? extends Number> data, final ElectricalCurrentUnit displayUnit,
152             final StorageType storageType)
153     {
154         this(data.size() == 0 ? DoubleVectorData.instantiate(new double[] {}, IdentityScale.SCALE, storageType)
155                 : data.get(0) instanceof ElectricalCurrent
156                         ? DoubleVectorData.instantiate(data, IdentityScale.SCALE, storageType)
157                         : DoubleVectorData.instantiate(data, displayUnit.getScale(), storageType),
158                 displayUnit);
159     }
160 
161     /**
162      * Construct an ElectricalCurrentVector from a list of Number objects or a list of ElectricalCurrent objects. Note that the
163      * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Double objects) or
164      * ElectricalCurrent objects. In case the list contains Number objects, the displayUnit indicates the unit in which the
165      * values in the list are expressed, as well as the unit in which they will be printed. In case the list contains
166      * ElectricalCurrent objects, each ElectricalCurrent has its own unit, and the displayUnit is just used for printing. The
167      * values but will always be internally stored as SI values or base values, and expressed using the display unit or base
168      * unit when printing. Assume the storage type is DENSE since we offer the data as a List.
169      * @param data List&lt;Double&gt; or List&lt;ElectricalCurrent&gt;; the data for the vector
170      * @param displayUnit ElectricalCurrentUnit; the display unit of the vector data, and the unit of the data points when the
171      *            data is expressed as List&lt;Double&gt; or List&lt;Number&gt; in general
172      */
173     public ElectricalCurrentVector(final List<? extends Number> data, final ElectricalCurrentUnit displayUnit)
174     {
175         this(data, displayUnit, StorageType.DENSE);
176     }
177 
178     /**
179      * Construct an ElectricalCurrentVector from a list of Number objects or a list of ElectricalCurrent objects. When data
180      * contains numbers such as Double, assume that they are expressed using SI units. When the data consists of
181      * ElectricalCurrent objects, they each have their own unit, but will be printed using SI units or base units. The values
182      * but will always be internally stored as SI values or base values, and expressed using the display unit or base unit when
183      * printing.
184      * @param data List&lt;Double&gt; or List&lt;ElectricalCurrent&gt;; the data for the vector
185      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
186      */
187     public ElectricalCurrentVector(final List<? extends Number> data, final StorageType storageType)
188     {
189         this(data, ElectricalCurrentUnit.SI, storageType);
190     }
191 
192     /**
193      * Construct an ElectricalCurrentVector from a list of Number objects or a list of ElectricalCurrent objects. When data
194      * contains numbers such as Double, assume that they are expressed using SI units. When the data consists of
195      * ElectricalCurrent objects, they each have their own unit, but will be printed using SI units or base units. The values
196      * but will always be internally stored as SI values or base values, and expressed using the display unit or base unit when
197      * printing. Assume the storage type is DENSE since we offer the data as a List.
198      * @param data List&lt;Double&gt; or List&lt;ElectricalCurrent&gt;; the data for the vector
199      */
200     public ElectricalCurrentVector(final List<? extends Number> data)
201     {
202         this(data, StorageType.DENSE);
203     }
204 
205     /* CONSTRUCTORS WITH Map<Integer, Double> or Map<Integer, ElectricalCurrent> */
206 
207     /**
208      * Construct an ElectricalCurrentVector from a (sparse) map of index values to Number objects or a (sparse) map of index
209      * values to of ElectricalCurrent objects. Using index values is particularly useful for sparse vectors. The size parameter
210      * indicates the size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit
211      * has a different meaning depending on whether the map contains Number objects (e.g., Double objects) or ElectricalCurrent
212      * objects. In case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are
213      * expressed, as well as the unit in which they will be printed. In case the map contains ElectricalCurrent objects, each
214      * ElectricalCurrent has its own unit, and the displayUnit is just used for printing. The values but will always be
215      * internally stored as SI values or base values, and expressed using the display unit or base unit when printing.
216      * @param data Map&lt;Integer, Double&gt; or Map&lt;Integer, ElectricalCurrent&gt;; the data for the vector
217      * @param size int; the size off the vector, i.e., the highest index
218      * @param displayUnit ElectricalCurrentUnit; the display unit of the vector data, and the unit of the data points when the
219      *            data is expressed as List&lt;Double&gt; or List&lt;Number&gt; in general
220      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
221      */
222     public ElectricalCurrentVector(final Map<Integer, ? extends Number> data, final int size,
223             final ElectricalCurrentUnit displayUnit, final StorageType storageType)
224     {
225         this(data.size() == 0 ? DoubleVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
226                 : data.values().iterator().next() instanceof ElectricalCurrent
227                         ? DoubleVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
228                         : DoubleVectorData.instantiate(data, size, displayUnit.getScale(), storageType),
229                 displayUnit);
230     }
231 
232     /**
233      * Construct an ElectricalCurrentVector from a (sparse) map of index values to Number objects or a (sparse) map of index
234      * values to of ElectricalCurrent objects. Using index values is particularly useful for sparse vectors. The size parameter
235      * indicates the size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit
236      * has a different meaning depending on whether the map contains Number objects (e.g., Double objects) or ElectricalCurrent
237      * objects. In case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are
238      * expressed, as well as the unit in which they will be printed. In case the map contains ElectricalCurrent objects, each
239      * ElectricalCurrent has its own unit, and the displayUnit is just used for printing. The values but will always be
240      * internally stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume
241      * the storage type is SPARSE since we offer the data as a Map.
242      * @param data Map&lt;Integer, Double&gt; or Map&lt;Integer, ElectricalCurrent&gt;; the data for the vector
243      * @param size int; the size off the vector, i.e., the highest index
244      * @param displayUnit ElectricalCurrentUnit; the display unit of the vector data, and the unit of the data points when the
245      *            data is expressed as List&lt;Double&gt; or List&lt;Number&gt; in general
246      */
247     public ElectricalCurrentVector(final Map<Integer, ? extends Number> data, final int size,
248             final ElectricalCurrentUnit displayUnit)
249     {
250         this(data, size, displayUnit, StorageType.SPARSE);
251     }
252 
253     /**
254      * Construct an ElectricalCurrentVector from a (sparse) map of index values to Number objects or a (sparse) map of index
255      * values to of ElectricalCurrent objects. Using index values is particularly useful for sparse vectors. The size parameter
256      * indicates the size of the vector, since the largest index does not have to be part of the map. When data contains numbers
257      * such as Double, assume that they are expressed using SI units. When the data consists of ElectricalCurrent objects, they
258      * each have their own unit, but will be printed using SI units or base units. The values but will always be internally
259      * stored as SI values or base values, and expressed using the display unit or base unit when printing.
260      * @param data Map&lt;Integer, Double&gt; or Map&lt;Integer, ElectricalCurrent&gt;; the data for the vector
261      * @param size int; the size off the vector, i.e., the highest index
262      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
263      */
264     public ElectricalCurrentVector(final Map<Integer, ? extends Number> data, final int size, final StorageType storageType)
265     {
266         this(data, size, ElectricalCurrentUnit.SI, storageType);
267     }
268 
269     /**
270      * Construct an ElectricalCurrentVector from a (sparse) map of index values to Number objects or a (sparse) map of index
271      * values to of ElectricalCurrent objects. Using index values is particularly useful for sparse vectors. The size parameter
272      * indicates the size of the vector, since the largest index does not have to be part of the map. When data contains numbers
273      * such as Double, assume that they are expressed using SI units. When the data consists of ElectricalCurrent objects, they
274      * each have their own unit, but will be printed using SI units or base units. The values but will always be internally
275      * stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume the storage
276      * type is SPARSE since we offer the data as a Map.
277      * @param data Map&lt;Integer, Double&gt; or Map&lt;Integer, ElectricalCurrent&gt;; the data for the vector
278      * @param size int; the size off the vector, i.e., the highest index
279      */
280     public ElectricalCurrentVector(final Map<Integer, ? extends Number> data, final int size)
281     {
282         this(data, size, StorageType.SPARSE);
283     }
284 
285     /* ****************************** Other methods ****************************** */
286 
287     @Override
288     public Class<ElectricalCurrent> getScalarClass()
289     {
290         return ElectricalCurrent.class;
291     }
292 
293     @Override
294     public ElectricalCurrentVector instantiateVector(final DoubleVectorData dvd, final ElectricalCurrentUnit displayUnit)
295     {
296         return new ElectricalCurrentVector(dvd, displayUnit);
297     }
298 
299     @Override
300     public ElectricalCurrent instantiateScalarSI(final double valueSI, final ElectricalCurrentUnit displayUnit)
301     {
302         ElectricalCurrent result = ElectricalCurrent.instantiateSI(valueSI);
303         result.setDisplayUnit(displayUnit);
304         return result;
305     }
306 
307 }