View Javadoc
1   package org.djunits.value.vfloat.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.IlluminanceUnit;
10  import org.djunits.unit.LuminousFluxUnit;
11  import org.djunits.value.util.ValueUtil;
12  import org.djunits.value.vfloat.scalar.base.AbstractFloatScalarRel;
13  
14  /**
15   * Easy access methods for the FloatIlluminance FloatScalar, which is relative by definition.
16   * <p>
17   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
18   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
19   * </p>
20   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
21   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
22   */
23  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2019-10-18T12:12:25.568Z")
24  public class FloatIlluminance extends AbstractFloatScalarRel<IlluminanceUnit, FloatIlluminance>
25  {
26      /** */
27      private static final long serialVersionUID = 20150901L;
28  
29      /** Constant with value zero. */
30      public static final FloatIlluminanceloatIlluminance.html#FloatIlluminance">FloatIlluminance ZERO = new FloatIlluminance(0.0f, IlluminanceUnit.SI);
31  
32      /** Constant with value one. */
33      public static final FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminance ONE = new FloatIlluminance(1.0f, IlluminanceUnit.SI);
34  
35      /** Constant with value NaN. */
36      @SuppressWarnings("checkstyle:constantname")
37      public static final FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminance NaN = new FloatIlluminance(Float.NaN, IlluminanceUnit.SI);
38  
39      /** Constant with value POSITIVE_INFINITY. */
40      public static final FloatIlluminancece.html#FloatIlluminance">FloatIlluminance POSITIVE_INFINITY = new FloatIlluminance(Float.POSITIVE_INFINITY, IlluminanceUnit.SI);
41  
42      /** Constant with value NEGATIVE_INFINITY. */
43      public static final FloatIlluminancece.html#FloatIlluminance">FloatIlluminance NEGATIVE_INFINITY = new FloatIlluminance(Float.NEGATIVE_INFINITY, IlluminanceUnit.SI);
44  
45      /** Constant with value MAX_VALUE. */
46      public static final FloatIlluminanceminance.html#FloatIlluminance">FloatIlluminance POS_MAXVALUE = new FloatIlluminance(Float.MAX_VALUE, IlluminanceUnit.SI);
47  
48      /** Constant with value -MAX_VALUE. */
49      public static final FloatIlluminanceminance.html#FloatIlluminance">FloatIlluminance NEG_MAXVALUE = new FloatIlluminance(-Float.MAX_VALUE, IlluminanceUnit.SI);
50  
51      /**
52       * Construct FloatIlluminance scalar.
53       * @param value float; the float value
54       * @param unit unit for the float value
55       */
56      public FloatIlluminance(final float value, final IlluminanceUnit unit)
57      {
58          super(value, unit);
59      }
60  
61      /**
62       * Construct FloatIlluminance scalar.
63       * @param value Scalar from which to construct this instance
64       */
65      public FloatIlluminancelar/FloatIlluminance.html#FloatIlluminance">FloatIlluminance(final FloatIlluminance value)
66      {
67          super(value);
68      }
69  
70      /**
71       * Construct FloatIlluminance scalar using a double value.
72       * @param value double; the double value
73       * @param unit unit for the resulting float value
74       */
75      public FloatIlluminance(final double value, final IlluminanceUnit unit)
76      {
77          super((float) value, unit);
78      }
79  
80      /** {@inheritDoc} */
81      @Override
82      public final FloatIlluminance instantiateRel(final float value, final IlluminanceUnit unit)
83      {
84          return new FloatIlluminance(value, unit);
85      }
86  
87      /**
88       * Construct FloatIlluminance scalar.
89       * @param value float; the float value in SI units
90       * @return the new scalar with the SI value
91       */
92      public static final FloatIlluminance instantiateSI(final float value)
93      {
94          return new FloatIlluminance(value, IlluminanceUnit.SI);
95      }
96  
97      /**
98       * Interpolate between two values.
99       * @param zero the low value
100      * @param one the high value
101      * @param ratio double; the ratio between 0 and 1, inclusive
102      * @return a Scalar at the ratio between
103      */
104     public static FloatIlluminanceoatIlluminance.html#FloatIlluminance">FloatIlluminanceuminance.html#FloatIlluminance">FloatIlluminance interpolate(final FloatIlluminanceoatIlluminance.html#FloatIlluminance">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      * Return the maximum value of two relative scalars.
112      * @param r1 the first scalar
113      * @param r2 the second scalar
114      * @return the maximum value of two relative scalars
115      */
116     public static FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminance max(final FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminance r1, final FloatIlluminance r2)
117     {
118         return (r1.gt(r2)) ? r1 : r2;
119     }
120 
121     /**
122      * Return the maximum value of more than two relative scalars.
123      * @param r1 the first scalar
124      * @param r2 the second scalar
125      * @param rn the other scalars
126      * @return the maximum value of more than two relative scalars
127      */
128     public static FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminance max(final FloatIlluminanceFloatIlluminance.html#FloatIlluminance">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      * Return the minimum value of two relative scalars.
143      * @param r1 the first scalar
144      * @param r2 the second scalar
145      * @return the minimum value of two relative scalars
146      */
147     public static FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminance min(final FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminance r1, final FloatIlluminance r2)
148     {
149         return (r1.lt(r2)) ? r1 : r2;
150     }
151 
152     /**
153      * Return the minimum value of more than two relative scalars.
154      * @param r1 the first scalar
155      * @param r2 the second scalar
156      * @param rn the other scalars
157      * @return the minimum value of more than two relative scalars
158      */
159     public static FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminanceFloatIlluminance.html#FloatIlluminance">FloatIlluminance min(final FloatIlluminanceFloatIlluminance.html#FloatIlluminance">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      * Returns a FloatIlluminance representation of a textual representation of a value with a unit. The String representation
174      * that can be parsed is the double value in the unit, followed by the official abbreviation of the unit. Spaces are
175      * allowed, but not required, between the value and the unit.
176      * @param text String; the textual representation to parse into a FloatIlluminance
177      * @return FloatIlluminance; the Scalar representation of the value in its unit
178      * @throws IllegalArgumentException when the text cannot be parsed
179      * @throws NullPointerException when the text argument is null
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         Matcher matcher = ValueUtil.NUMBER_PATTERN.matcher(text);
186         if (matcher.find())
187         {
188             int index = matcher.end();
189             String unitString = text.substring(index).trim();
190             String valueString = text.substring(0, index).trim();
191             IlluminanceUnit unit = IlluminanceUnit.BASE.getUnitByAbbreviation(unitString);
192             if (unit != null)
193             {
194                 float f = Float.parseFloat(valueString);
195                 return new FloatIlluminance(f, unit);
196             }
197         }
198         throw new IllegalArgumentException("Error parsing FloatIlluminance from " + text);
199     }
200 
201     /**
202      * Returns a FloatIlluminance based on a value and the textual representation of the unit.
203      * @param value double; the value to use
204      * @param unitString String; the textual representation of the unit
205      * @return FloatIlluminance; the Scalar representation of the value in its unit
206      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
207      * @throws NullPointerException when the unitString argument is null
208      */
209     public static FloatIlluminance of(final float value, final String unitString)
210     {
211         Throw.whenNull(unitString, "Error parsing FloatIlluminance: unitString is null");
212         Throw.when(unitString.length() == 0, IllegalArgumentException.class,
213                 "Error parsing FloatIlluminance: empty unitString");
214         IlluminanceUnit unit = IlluminanceUnit.BASE.getUnitByAbbreviation(unitString);
215         if (unit != null)
216         {
217             return new FloatIlluminance(value, unit);
218         }
219         throw new IllegalArgumentException("Error parsing FloatIlluminance with unit " + unitString);
220     }
221 
222     /**
223      * Calculate the division of FloatIlluminance and FloatIlluminance, which results in a FloatDimensionless scalar.
224      * @param v FloatIlluminance scalar
225      * @return FloatDimensionless scalar as a division of FloatIlluminance and FloatIlluminance
226      */
227     public final FloatDimensionless divide(final FloatIlluminance v)
228     {
229         return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
230     }
231 
232     /**
233      * Calculate the multiplication of FloatIlluminance and FloatArea, which results in a FloatLuminousFlux scalar.
234      * @param v FloatIlluminance scalar
235      * @return FloatLuminousFlux scalar as a multiplication of FloatIlluminance and FloatArea
236      */
237     public final FloatLuminousFlux times(final FloatArea v)
238     {
239         return new FloatLuminousFlux(this.si * v.si, LuminousFluxUnit.SI);
240     }
241 
242 }