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.MagneticFluxDensityUnit;
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 MagneticFluxDensity extends DoubleScalarRel<MagneticFluxDensityUnit, MagneticFluxDensity>
26 {
27
28 private static final long serialVersionUID = 20150905L;
29
30
31 public static final MagneticFluxDensity ZERO = new MagneticFluxDensity(0.0, MagneticFluxDensityUnit.SI);
32
33
34 public static final MagneticFluxDensity ONE = new MagneticFluxDensity(1.0, MagneticFluxDensityUnit.SI);
35
36
37 @SuppressWarnings("checkstyle:constantname")
38 public static final MagneticFluxDensity NaN = new MagneticFluxDensity(Double.NaN, MagneticFluxDensityUnit.SI);
39
40
41 public static final MagneticFluxDensity POSITIVE_INFINITY =
42 new MagneticFluxDensity(Double.POSITIVE_INFINITY, MagneticFluxDensityUnit.SI);
43
44
45 public static final MagneticFluxDensity NEGATIVE_INFINITY =
46 new MagneticFluxDensity(Double.NEGATIVE_INFINITY, MagneticFluxDensityUnit.SI);
47
48
49 public static final MagneticFluxDensity POS_MAXVALUE =
50 new MagneticFluxDensity(Double.MAX_VALUE, MagneticFluxDensityUnit.SI);
51
52
53 public static final MagneticFluxDensity NEG_MAXVALUE =
54 new MagneticFluxDensity(-Double.MAX_VALUE, MagneticFluxDensityUnit.SI);
55
56
57
58
59
60
61 public MagneticFluxDensity(final double value, final MagneticFluxDensityUnit unit)
62 {
63 super(value, unit);
64 }
65
66
67
68
69
70 public MagneticFluxDensity(final MagneticFluxDensity value)
71 {
72 super(value);
73 }
74
75 @Override
76 public final MagneticFluxDensity instantiateRel(final double value, final MagneticFluxDensityUnit unit)
77 {
78 return new MagneticFluxDensity(value, unit);
79 }
80
81
82
83
84
85
86 public static final MagneticFluxDensity instantiateSI(final double value)
87 {
88 return new MagneticFluxDensity(value, MagneticFluxDensityUnit.SI);
89 }
90
91
92
93
94
95
96
97
98 public static MagneticFluxDensity interpolate(final MagneticFluxDensity zero, final MagneticFluxDensity one,
99 final double ratio)
100 {
101 return new MagneticFluxDensity(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
102 zero.getDisplayUnit());
103 }
104
105
106
107
108
109
110
111 public static MagneticFluxDensity max(final MagneticFluxDensity r1, final MagneticFluxDensity r2)
112 {
113 return r1.gt(r2) ? r1 : r2;
114 }
115
116
117
118
119
120
121
122
123 public static MagneticFluxDensity max(final MagneticFluxDensity r1, final MagneticFluxDensity r2,
124 final MagneticFluxDensity... rn)
125 {
126 MagneticFluxDensity maxr = r1.gt(r2) ? r1 : r2;
127 for (MagneticFluxDensity 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 MagneticFluxDensity min(final MagneticFluxDensity r1, final MagneticFluxDensity r2)
144 {
145 return r1.lt(r2) ? r1 : r2;
146 }
147
148
149
150
151
152
153
154
155 public static MagneticFluxDensity min(final MagneticFluxDensity r1, final MagneticFluxDensity r2,
156 final MagneticFluxDensity... rn)
157 {
158 MagneticFluxDensity minr = r1.lt(r2) ? r1 : r2;
159 for (MagneticFluxDensity 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 MagneticFluxDensity valueOf(final String text)
179 {
180 Throw.whenNull(text, "Error parsing MagneticFluxDensity: text to parse is null");
181 Throw.when(text.length() == 0, IllegalArgumentException.class,
182 "Error parsing MagneticFluxDensity: 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 MagneticFluxDensityUnit unit = MagneticFluxDensityUnit.BASE.getUnitByAbbreviation(unitString);
189 if (unit == null)
190 throw new IllegalArgumentException("Unit " + unitString + " not found");
191 return new MagneticFluxDensity(d, unit);
192 }
193 catch (Exception exception)
194 {
195 throw new IllegalArgumentException("Error parsing MagneticFluxDensity 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 MagneticFluxDensity of(final double value, final String unitString)
209 {
210 Throw.whenNull(unitString, "Error parsing MagneticFluxDensity: unitString is null");
211 Throw.when(unitString.length() == 0, IllegalArgumentException.class,
212 "Error parsing MagneticFluxDensity: empty unitString");
213 MagneticFluxDensityUnit unit = MagneticFluxDensityUnit.BASE.getUnitByAbbreviation(unitString);
214 if (unit != null)
215 {
216 return new MagneticFluxDensity(value, unit);
217 }
218 throw new IllegalArgumentException("Error parsing MagneticFluxDensity with unit " + unitString);
219 }
220
221
222
223
224
225
226 public final Dimensionless divide(final MagneticFluxDensity 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 Area 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 }