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