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