1 package org.djunits.value.vfloat.scalar;
2
3 import java.util.Locale;
4
5 import org.djunits.unit.DimensionlessUnit;
6 import org.djunits.unit.ElectricalChargeUnit;
7 import org.djunits.unit.ElectricalConductanceUnit;
8 import org.djunits.unit.ElectricalCurrentUnit;
9 import org.djunits.unit.ElectricalPotentialUnit;
10 import org.djunits.unit.PowerUnit;
11 import org.djunits.value.vfloat.scalar.base.FloatScalar;
12 import org.djunits.value.vfloat.scalar.base.FloatScalarRel;
13 import org.djutils.base.NumberParser;
14 import org.djutils.exceptions.Throw;
15
16 import jakarta.annotation.Generated;
17
18
19
20
21
22
23
24
25
26
27 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
28 public class FloatElectricalCurrent extends FloatScalarRel<ElectricalCurrentUnit, FloatElectricalCurrent>
29 {
30
31 private static final long serialVersionUID = 20150901L;
32
33
34 public static final FloatElectricalCurrent ZERO = new FloatElectricalCurrent(0.0f, ElectricalCurrentUnit.SI);
35
36
37 public static final FloatElectricalCurrent ONE = new FloatElectricalCurrent(1.0f, ElectricalCurrentUnit.SI);
38
39
40 @SuppressWarnings("checkstyle:constantname")
41 public static final FloatElectricalCurrent NaN = new FloatElectricalCurrent(Float.NaN, ElectricalCurrentUnit.SI);
42
43
44 public static final FloatElectricalCurrent POSITIVE_INFINITY =
45 new FloatElectricalCurrent(Float.POSITIVE_INFINITY, ElectricalCurrentUnit.SI);
46
47
48 public static final FloatElectricalCurrent NEGATIVE_INFINITY =
49 new FloatElectricalCurrent(Float.NEGATIVE_INFINITY, ElectricalCurrentUnit.SI);
50
51
52 public static final FloatElectricalCurrent POS_MAXVALUE =
53 new FloatElectricalCurrent(Float.MAX_VALUE, ElectricalCurrentUnit.SI);
54
55
56 public static final FloatElectricalCurrent NEG_MAXVALUE =
57 new FloatElectricalCurrent(-Float.MAX_VALUE, ElectricalCurrentUnit.SI);
58
59
60
61
62
63
64 public FloatElectricalCurrent(final float value, final ElectricalCurrentUnit unit)
65 {
66 super(value, unit);
67 }
68
69
70
71
72
73 public FloatElectricalCurrent(final FloatElectricalCurrent value)
74 {
75 super(value);
76 }
77
78
79
80
81
82
83 public FloatElectricalCurrent(final double value, final ElectricalCurrentUnit unit)
84 {
85 super((float) value, unit);
86 }
87
88 @Override
89 public final FloatElectricalCurrent instantiateRel(final float value, final ElectricalCurrentUnit unit)
90 {
91 return new FloatElectricalCurrent(value, unit);
92 }
93
94
95
96
97
98
99 public static final FloatElectricalCurrent instantiateSI(final float value)
100 {
101 return new FloatElectricalCurrent(value, ElectricalCurrentUnit.SI);
102 }
103
104
105
106
107
108
109
110
111 public static FloatElectricalCurrent interpolate(final FloatElectricalCurrent zero, final FloatElectricalCurrent one,
112 final float ratio)
113 {
114 return new FloatElectricalCurrent(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
115 zero.getDisplayUnit());
116 }
117
118
119
120
121
122
123
124 public static FloatElectricalCurrent max(final FloatElectricalCurrent r1, final FloatElectricalCurrent r2)
125 {
126 return r1.gt(r2) ? r1 : r2;
127 }
128
129
130
131
132
133
134
135
136 public static FloatElectricalCurrent max(final FloatElectricalCurrent r1, final FloatElectricalCurrent r2,
137 final FloatElectricalCurrent... rn)
138 {
139 FloatElectricalCurrent maxr = r1.gt(r2) ? r1 : r2;
140 for (FloatElectricalCurrent r : rn)
141 {
142 if (r.gt(maxr))
143 {
144 maxr = r;
145 }
146 }
147 return maxr;
148 }
149
150
151
152
153
154
155
156 public static FloatElectricalCurrent min(final FloatElectricalCurrent r1, final FloatElectricalCurrent r2)
157 {
158 return r1.lt(r2) ? r1 : r2;
159 }
160
161
162
163
164
165
166
167
168 public static FloatElectricalCurrent min(final FloatElectricalCurrent r1, final FloatElectricalCurrent r2,
169 final FloatElectricalCurrent... rn)
170 {
171 FloatElectricalCurrent minr = r1.lt(r2) ? r1 : r2;
172 for (FloatElectricalCurrent r : rn)
173 {
174 if (r.lt(minr))
175 {
176 minr = r;
177 }
178 }
179 return minr;
180 }
181
182
183
184
185
186
187
188
189
190
191 public static FloatElectricalCurrent valueOf(final String text)
192 {
193 Throw.whenNull(text, "Error parsing FloatElectricalCurrent: text to parse is null");
194 Throw.when(text.length() == 0, IllegalArgumentException.class,
195 "Error parsing FloatElectricalCurrent: empty text to parse");
196 try
197 {
198 NumberParser numberParser = new NumberParser().lenient().trailing();
199 float f = numberParser.parseFloat(text);
200 String unitString = text.substring(numberParser.getTrailingPosition()).trim();
201 ElectricalCurrentUnit unit = ElectricalCurrentUnit.BASE.getUnitByAbbreviation(unitString);
202 if (unit == null)
203 throw new IllegalArgumentException("Unit " + unitString + " not found");
204 return new FloatElectricalCurrent(f, unit);
205 }
206 catch (Exception exception)
207 {
208 throw new IllegalArgumentException("Error parsing FloatElectricalCurrent from " + text + " using Locale "
209 + Locale.getDefault(Locale.Category.FORMAT), exception);
210 }
211 }
212
213
214
215
216
217
218
219
220
221 public static FloatElectricalCurrent of(final float value, final String unitString)
222 {
223 Throw.whenNull(unitString, "Error parsing FloatElectricalCurrent: unitString is null");
224 Throw.when(unitString.length() == 0, IllegalArgumentException.class,
225 "Error parsing FloatElectricalCurrent: empty unitString");
226 ElectricalCurrentUnit unit = ElectricalCurrentUnit.BASE.getUnitByAbbreviation(unitString);
227 if (unit != null)
228 {
229 return new FloatElectricalCurrent(value, unit);
230 }
231 throw new IllegalArgumentException("Error parsing FloatElectricalCurrent with unit " + unitString);
232 }
233
234
235
236
237
238
239
240 public final FloatDimensionless divide(final FloatElectricalCurrent v)
241 {
242 return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
243 }
244
245
246
247
248
249
250
251 public final FloatPower times(final FloatElectricalPotential v)
252 {
253 return new FloatPower(this.si * v.si, PowerUnit.SI);
254 }
255
256
257
258
259
260
261
262 public final FloatElectricalCharge times(final FloatDuration v)
263 {
264 return new FloatElectricalCharge(this.si * v.si, ElectricalChargeUnit.SI);
265 }
266
267
268
269
270
271
272
273 public final FloatElectricalPotential times(final FloatElectricalResistance v)
274 {
275 return new FloatElectricalPotential(this.si * v.si, ElectricalPotentialUnit.SI);
276 }
277
278
279
280
281
282
283
284 public final FloatElectricalConductance divide(final FloatElectricalPotential v)
285 {
286 return new FloatElectricalConductance(this.si / v.si, ElectricalConductanceUnit.SI);
287 }
288
289
290
291
292
293
294
295 public final FloatElectricalPotential divide(final FloatElectricalConductance v)
296 {
297 return new FloatElectricalPotential(this.si / v.si, ElectricalPotentialUnit.SI);
298 }
299
300 @Override
301 public FloatSIScalar reciprocal()
302 {
303 return FloatScalar.divide(FloatDimensionless.ONE, this);
304 }
305
306 }