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