1 package org.djunits.value.vdouble.scalar;
2
3 import java.util.Locale;
4
5 import org.djunits.unit.AbsoluteTemperatureUnit;
6 import org.djunits.unit.TemperatureUnit;
7 import org.djunits.value.vdouble.scalar.base.DoubleScalarAbs;
8 import org.djutils.base.NumberParser;
9 import org.djutils.exceptions.Throw;
10
11 import jakarta.annotation.Generated;
12
13
14
15
16
17
18
19
20
21
22
23 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
24 public class AbsoluteTemperature
25 extends DoubleScalarAbs<AbsoluteTemperatureUnit, AbsoluteTemperature, TemperatureUnit, Temperature>
26 {
27
28 private static final long serialVersionUID = 20150901L;
29
30
31 public static final 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 AbsoluteTemperature(final AbsoluteTemperature value)
48 {
49 super(value);
50 }
51
52 @Override
53 public final AbsoluteTemperature instantiateAbs(final double value, final AbsoluteTemperatureUnit unit)
54 {
55 return new AbsoluteTemperature(value, unit);
56 }
57
58 @Override
59 public final Temperature instantiateRel(final double value, final TemperatureUnit unit)
60 {
61 return new Temperature(value, unit);
62 }
63
64
65
66
67
68
69 public static final AbsoluteTemperature instantiateSI(final double value)
70 {
71 return new AbsoluteTemperature(value, AbsoluteTemperatureUnit.DEFAULT);
72 }
73
74
75
76
77
78
79
80
81 public static AbsoluteTemperature interpolate(final AbsoluteTemperature zero, final AbsoluteTemperature one,
82 final double ratio)
83 {
84 return new AbsoluteTemperature(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
85 zero.getDisplayUnit());
86 }
87
88
89
90
91
92
93
94 public static AbsoluteTemperature max(final AbsoluteTemperature a1, final AbsoluteTemperature a2)
95 {
96 return a1.gt(a2) ? a1 : a2;
97 }
98
99
100
101
102
103
104
105
106 public static AbsoluteTemperature max(final AbsoluteTemperature a1, final AbsoluteTemperature a2,
107 final AbsoluteTemperature... an)
108 {
109 AbsoluteTemperature maxa = a1.gt(a2) ? a1 : a2;
110 for (AbsoluteTemperature a : an)
111 {
112 if (a.gt(maxa))
113 {
114 maxa = a;
115 }
116 }
117 return maxa;
118 }
119
120
121
122
123
124
125
126 public static AbsoluteTemperature min(final AbsoluteTemperature a1, final AbsoluteTemperature a2)
127 {
128 return a1.lt(a2) ? a1 : a2;
129 }
130
131
132
133
134
135
136
137
138 public static AbsoluteTemperature min(final AbsoluteTemperature a1, final AbsoluteTemperature a2,
139 final AbsoluteTemperature... an)
140 {
141 AbsoluteTemperature mina = a1.lt(a2) ? a1 : a2;
142 for (AbsoluteTemperature a : an)
143 {
144 if (a.lt(mina))
145 {
146 mina = a;
147 }
148 }
149 return mina;
150 }
151
152
153
154
155
156
157
158
159
160
161 public static AbsoluteTemperature valueOf(final String text)
162 {
163 Throw.whenNull(text, "Error parsing AbsoluteTemperature: text to parse is null");
164 Throw.when(text.length() == 0, IllegalArgumentException.class,
165 "Error parsing AbsoluteTemperature: empty text to parse");
166 try
167 {
168 NumberParser numberParser = new NumberParser().lenient().trailing();
169 double d = numberParser.parseDouble(text);
170 String unitString = text.substring(numberParser.getTrailingPosition()).trim();
171 AbsoluteTemperatureUnit unit = AbsoluteTemperatureUnit.BASE.getUnitByAbbreviation(unitString);
172 if (unit == null)
173 throw new IllegalArgumentException("Unit " + unitString + " not found");
174 return new AbsoluteTemperature(d, unit);
175 }
176 catch (Exception exception)
177 {
178 throw new IllegalArgumentException("Error parsing AbsoluteTemperature from " + text + " using Locale "
179 + Locale.getDefault(Locale.Category.FORMAT), exception);
180 }
181 }
182
183
184
185
186
187
188
189
190
191 public static AbsoluteTemperature of(final double value, final String unitString)
192 {
193 Throw.whenNull(unitString, "Error parsing AbsoluteTemperature: unitString is null");
194 Throw.when(unitString.length() == 0, IllegalArgumentException.class,
195 "Error parsing AbsoluteTemperature: empty unitString");
196 AbsoluteTemperatureUnit unit = AbsoluteTemperatureUnit.BASE.getUnitByAbbreviation(unitString);
197 if (unit != null)
198 {
199 return new AbsoluteTemperature(value, unit);
200 }
201 throw new IllegalArgumentException("Error parsing AbsoluteTemperature with unit " + unitString);
202 }
203
204 }