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