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