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