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