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