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.AbsoluteTemperatureUnit;
9 import org.djunits.unit.TemperatureUnit;
10 import org.djunits.value.util.ValueUtil;
11 import org.djunits.value.vdouble.scalar.base.AbstractDoubleScalarAbs;
12
13
14
15
16
17
18
19
20
21
22
23 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2020-01-19T15:21:24.964166400Z")
24 public class AbsoluteTemperature
25 extends AbstractDoubleScalarAbs<AbsoluteTemperatureUnit, AbsoluteTemperature, TemperatureUnit, Temperature>
26 {
27
28 private static final long serialVersionUID = 20150901L;
29
30
31 public static final AbsoluteTemperatureoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperature ZERO = new AbsoluteTemperature(0.0, AbsoluteTemperatureUnit.DEFAULT);
32
33
34
35
36
37
38 public AbsoluteTemperature(final double value, final AbsoluteTemperatureUnit unit)
39 {
40 super(value, unit);
41 }
42
43
44
45
46
47 public AbsoluteTemperaturer/AbsoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperature(final AbsoluteTemperature value)
48 {
49 super(value);
50 }
51
52
53 @Override
54 public final AbsoluteTemperature instantiateAbs(final double value, final AbsoluteTemperatureUnit unit)
55 {
56 return new AbsoluteTemperature(value, unit);
57 }
58
59
60 @Override
61 public final Temperature instantiateRel(final double value, final TemperatureUnit unit)
62 {
63 return new Temperature(value, unit);
64 }
65
66
67
68
69
70
71 public static final AbsoluteTemperature instantiateSI(final double value)
72 {
73 return new AbsoluteTemperature(value, AbsoluteTemperatureUnit.DEFAULT);
74 }
75
76
77
78
79
80
81
82
83 public static AbsoluteTemperatureluteTemperature.html#AbsoluteTemperature">AbsoluteTemperaturemperature.html#AbsoluteTemperature">AbsoluteTemperature interpolate(final AbsoluteTemperatureluteTemperature.html#AbsoluteTemperature">AbsoluteTemperature zero, final AbsoluteTemperature one,
84 final double ratio)
85 {
86 return new AbsoluteTemperature(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
87 zero.getDisplayUnit());
88 }
89
90
91
92
93
94
95
96 public static AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperature max(final AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperature a1, final AbsoluteTemperature a2)
97 {
98 return a1.gt(a2) ? a1 : a2;
99 }
100
101
102
103
104
105
106
107
108 public static AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperature max(final AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperature a1, final AbsoluteTemperature a2,
109 final AbsoluteTemperature... an)
110 {
111 AbsoluteTemperature maxa = a1.gt(a2) ? a1 : a2;
112 for (AbsoluteTemperature a : an)
113 {
114 if (a.gt(maxa))
115 {
116 maxa = a;
117 }
118 }
119 return maxa;
120 }
121
122
123
124
125
126
127
128 public static AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperature min(final AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperature a1, final AbsoluteTemperature a2)
129 {
130 return a1.lt(a2) ? a1 : a2;
131 }
132
133
134
135
136
137
138
139
140 public static AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperature min(final AbsoluteTemperaturesoluteTemperature.html#AbsoluteTemperature">AbsoluteTemperature a1, final AbsoluteTemperature a2,
141 final AbsoluteTemperature... an)
142 {
143 AbsoluteTemperature mina = a1.lt(a2) ? a1 : a2;
144 for (AbsoluteTemperature a : an)
145 {
146 if (a.lt(mina))
147 {
148 mina = a;
149 }
150 }
151 return mina;
152 }
153
154
155
156
157
158
159
160
161
162
163 public static AbsoluteTemperature valueOf(final String text)
164 {
165 Throw.whenNull(text, "Error parsing AbsoluteTemperature: text to parse is null");
166 Throw.when(text.length() == 0, IllegalArgumentException.class,
167 "Error parsing AbsoluteTemperature: empty text to parse");
168 Matcher matcher = ValueUtil.NUMBER_PATTERN.matcher(text);
169 if (matcher.find())
170 {
171 int index = matcher.end();
172 String unitString = text.substring(index).trim();
173 String valueString = text.substring(0, index).trim();
174 AbsoluteTemperatureUnit unit = AbsoluteTemperatureUnit.BASE.getUnitByAbbreviation(unitString);
175 if (unit != null)
176 {
177 double d = Double.parseDouble(valueString);
178 return new AbsoluteTemperature(d, unit);
179 }
180 }
181 throw new IllegalArgumentException("Error parsing AbsoluteTemperature from " + text);
182 }
183
184
185
186
187
188
189
190
191
192 public static AbsoluteTemperature of(final double value, final String unitString)
193 {
194 Throw.whenNull(unitString, "Error parsing AbsoluteTemperature: unitString is null");
195 Throw.when(unitString.length() == 0, IllegalArgumentException.class,
196 "Error parsing AbsoluteTemperature: empty unitString");
197 AbsoluteTemperatureUnit unit = AbsoluteTemperatureUnit.BASE.getUnitByAbbreviation(unitString);
198 if (unit != null)
199 {
200 return new AbsoluteTemperature(value, unit);
201 }
202 throw new IllegalArgumentException("Error parsing AbsoluteTemperature with unit " + unitString);
203 }
204
205 }