1 package org.djunits.value.vfloat.scalar;
2
3 import java.util.Locale;
4
5 import org.djunits.unit.AbsorbedDoseUnit;
6 import org.djunits.unit.DimensionlessUnit;
7 import org.djunits.value.vfloat.scalar.base.FloatScalar;
8 import org.djunits.value.vfloat.scalar.base.FloatScalarRel;
9 import org.djutils.base.NumberParser;
10 import org.djutils.exceptions.Throw;
11
12 import jakarta.annotation.Generated;
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 FloatAbsorbedDose extends FloatScalarRel<AbsorbedDoseUnit, FloatAbsorbedDose>
25 {
26
27 private static final long serialVersionUID = 20150901L;
28
29
30 public static final FloatAbsorbedDose ZERO = new FloatAbsorbedDose(0.0f, AbsorbedDoseUnit.SI);
31
32
33 public static final FloatAbsorbedDose ONE = new FloatAbsorbedDose(1.0f, AbsorbedDoseUnit.SI);
34
35
36 @SuppressWarnings("checkstyle:constantname")
37 public static final FloatAbsorbedDose NaN = new FloatAbsorbedDose(Float.NaN, AbsorbedDoseUnit.SI);
38
39
40 public static final FloatAbsorbedDose POSITIVE_INFINITY =
41 new FloatAbsorbedDose(Float.POSITIVE_INFINITY, AbsorbedDoseUnit.SI);
42
43
44 public static final FloatAbsorbedDose NEGATIVE_INFINITY =
45 new FloatAbsorbedDose(Float.NEGATIVE_INFINITY, AbsorbedDoseUnit.SI);
46
47
48 public static final FloatAbsorbedDose POS_MAXVALUE = new FloatAbsorbedDose(Float.MAX_VALUE, AbsorbedDoseUnit.SI);
49
50
51 public static final FloatAbsorbedDose NEG_MAXVALUE = new FloatAbsorbedDose(-Float.MAX_VALUE, AbsorbedDoseUnit.SI);
52
53
54
55
56
57
58 public FloatAbsorbedDose(final float value, final AbsorbedDoseUnit unit)
59 {
60 super(value, unit);
61 }
62
63
64
65
66
67 public FloatAbsorbedDose(final FloatAbsorbedDose value)
68 {
69 super(value);
70 }
71
72
73
74
75
76
77 public FloatAbsorbedDose(final double value, final AbsorbedDoseUnit unit)
78 {
79 super((float) value, unit);
80 }
81
82 @Override
83 public final FloatAbsorbedDose instantiateRel(final float value, final AbsorbedDoseUnit unit)
84 {
85 return new FloatAbsorbedDose(value, unit);
86 }
87
88
89
90
91
92
93 public static final FloatAbsorbedDose instantiateSI(final float value)
94 {
95 return new FloatAbsorbedDose(value, AbsorbedDoseUnit.SI);
96 }
97
98
99
100
101
102
103
104
105 public static FloatAbsorbedDose interpolate(final FloatAbsorbedDose zero, final FloatAbsorbedDose one, final float ratio)
106 {
107 return new FloatAbsorbedDose(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
108 zero.getDisplayUnit());
109 }
110
111
112
113
114
115
116
117 public static FloatAbsorbedDose max(final FloatAbsorbedDose r1, final FloatAbsorbedDose r2)
118 {
119 return r1.gt(r2) ? r1 : r2;
120 }
121
122
123
124
125
126
127
128
129 public static FloatAbsorbedDose max(final FloatAbsorbedDose r1, final FloatAbsorbedDose r2, final FloatAbsorbedDose... rn)
130 {
131 FloatAbsorbedDose maxr = r1.gt(r2) ? r1 : r2;
132 for (FloatAbsorbedDose r : rn)
133 {
134 if (r.gt(maxr))
135 {
136 maxr = r;
137 }
138 }
139 return maxr;
140 }
141
142
143
144
145
146
147
148 public static FloatAbsorbedDose min(final FloatAbsorbedDose r1, final FloatAbsorbedDose r2)
149 {
150 return r1.lt(r2) ? r1 : r2;
151 }
152
153
154
155
156
157
158
159
160 public static FloatAbsorbedDose min(final FloatAbsorbedDose r1, final FloatAbsorbedDose r2, final FloatAbsorbedDose... rn)
161 {
162 FloatAbsorbedDose minr = r1.lt(r2) ? r1 : r2;
163 for (FloatAbsorbedDose r : rn)
164 {
165 if (r.lt(minr))
166 {
167 minr = r;
168 }
169 }
170 return minr;
171 }
172
173
174
175
176
177
178
179
180
181
182 public static FloatAbsorbedDose valueOf(final String text)
183 {
184 Throw.whenNull(text, "Error parsing FloatAbsorbedDose: text to parse is null");
185 Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing FloatAbsorbedDose: empty text to parse");
186 try
187 {
188 NumberParser numberParser = new NumberParser().lenient().trailing();
189 float f = numberParser.parseFloat(text);
190 String unitString = text.substring(numberParser.getTrailingPosition()).trim();
191 AbsorbedDoseUnit unit = AbsorbedDoseUnit.BASE.getUnitByAbbreviation(unitString);
192 if (unit == null)
193 throw new IllegalArgumentException("Unit " + unitString + " not found");
194 return new FloatAbsorbedDose(f, unit);
195 }
196 catch (Exception exception)
197 {
198 throw new IllegalArgumentException("Error parsing FloatAbsorbedDose from " + text + " using Locale "
199 + Locale.getDefault(Locale.Category.FORMAT), exception);
200 }
201 }
202
203
204
205
206
207
208
209
210
211 public static FloatAbsorbedDose of(final float value, final String unitString)
212 {
213 Throw.whenNull(unitString, "Error parsing FloatAbsorbedDose: unitString is null");
214 Throw.when(unitString.length() == 0, IllegalArgumentException.class,
215 "Error parsing FloatAbsorbedDose: empty unitString");
216 AbsorbedDoseUnit unit = AbsorbedDoseUnit.BASE.getUnitByAbbreviation(unitString);
217 if (unit != null)
218 {
219 return new FloatAbsorbedDose(value, unit);
220 }
221 throw new IllegalArgumentException("Error parsing FloatAbsorbedDose with unit " + unitString);
222 }
223
224
225
226
227
228
229 public final FloatDimensionless divide(final FloatAbsorbedDose v)
230 {
231 return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
232 }
233
234 @Override
235 public FloatSIScalar reciprocal()
236 {
237 return FloatScalar.divide(FloatDimensionless.ONE, this);
238 }
239
240 }