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.AreaUnit;
9   import org.djunits.unit.DimensionlessUnit;
10  import org.djunits.unit.FlowVolumeUnit;
11  import org.djunits.unit.ForceUnit;
12  import org.djunits.unit.LengthUnit;
13  import org.djunits.unit.LinearDensityUnit;
14  import org.djunits.unit.LuminousFluxUnit;
15  import org.djunits.unit.VolumeUnit;
16  import org.djunits.value.util.ValueUtil;
17  import org.djunits.value.vfloat.scalar.base.AbstractFloatScalarRel;
18  
19  /**
20   * Easy access methods for the FloatArea FloatScalar, which is relative by definition.
21   * <p>
22   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
23   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
24   * </p>
25   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
26   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
27   */
28  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2019-10-18T12:12:25.568Z")
29  public class FloatArea extends AbstractFloatScalarRel<AreaUnit, FloatArea>
30  {
31      /** */
32      private static final long serialVersionUID = 20150901L;
33  
34      /** Constant with value zero. */
35      public static final FloatAreacalar/FloatArea.html#FloatArea">FloatArea ZERO = new FloatArea(0.0f, AreaUnit.SI);
36  
37      /** Constant with value one. */
38      public static final FloatAreascalar/FloatArea.html#FloatArea">FloatArea ONE = new FloatArea(1.0f, AreaUnit.SI);
39  
40      /** Constant with value NaN. */
41      @SuppressWarnings("checkstyle:constantname")
42      public static final FloatAreascalar/FloatArea.html#FloatArea">FloatArea NaN = new FloatArea(Float.NaN, AreaUnit.SI);
43  
44      /** Constant with value POSITIVE_INFINITY. */
45      public static final FloatAreaea.html#FloatArea">FloatArea POSITIVE_INFINITY = new FloatArea(Float.POSITIVE_INFINITY, AreaUnit.SI);
46  
47      /** Constant with value NEGATIVE_INFINITY. */
48      public static final FloatAreaea.html#FloatArea">FloatArea NEGATIVE_INFINITY = new FloatArea(Float.NEGATIVE_INFINITY, AreaUnit.SI);
49  
50      /** Constant with value MAX_VALUE. */
51      public static final FloatAreaoatArea.html#FloatArea">FloatArea POS_MAXVALUE = new FloatArea(Float.MAX_VALUE, AreaUnit.SI);
52  
53      /** Constant with value -MAX_VALUE. */
54      public static final FloatAreaoatArea.html#FloatArea">FloatArea NEG_MAXVALUE = new FloatArea(-Float.MAX_VALUE, AreaUnit.SI);
55  
56      /**
57       * Construct FloatArea scalar.
58       * @param value float; the float value
59       * @param unit unit for the float value
60       */
61      public FloatArea(final float value, final AreaUnit unit)
62      {
63          super(value, unit);
64      }
65  
66      /**
67       * Construct FloatArea scalar.
68       * @param value Scalar from which to construct this instance
69       */
70      public FloatAreaoat/scalar/FloatArea.html#FloatArea">FloatArea(final FloatArea value)
71      {
72          super(value);
73      }
74  
75      /**
76       * Construct FloatArea scalar using a double value.
77       * @param value double; the double value
78       * @param unit unit for the resulting float value
79       */
80      public FloatArea(final double value, final AreaUnit unit)
81      {
82          super((float) value, unit);
83      }
84  
85      /** {@inheritDoc} */
86      @Override
87      public final FloatArea instantiateRel(final float value, final AreaUnit unit)
88      {
89          return new FloatArea(value, unit);
90      }
91  
92      /**
93       * Construct FloatArea scalar.
94       * @param value float; the float value in SI units
95       * @return the new scalar with the SI value
96       */
97      public static final FloatArea instantiateSI(final float value)
98      {
99          return new FloatArea(value, AreaUnit.SI);
100     }
101 
102     /**
103      * Interpolate between two values.
104      * @param zero the low value
105      * @param one the high value
106      * @param ratio double; the ratio between 0 and 1, inclusive
107      * @return a Scalar at the ratio between
108      */
109     public static FloatAreaalar/FloatArea.html#FloatArea">FloatArealoatArea.html#FloatArea">FloatArea interpolate(final FloatAreaalar/FloatArea.html#FloatArea">FloatArea zero, final FloatArea one, final float ratio)
110     {
111         return new FloatArea(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
112                 zero.getDisplayUnit());
113     }
114 
115     /**
116      * Return the maximum value of two relative scalars.
117      * @param r1 the first scalar
118      * @param r2 the second scalar
119      * @return the maximum value of two relative scalars
120      */
121     public static FloatAreascalar/FloatArea.html#FloatArea">FloatAreascalar/FloatArea.html#FloatArea">FloatArea max(final FloatAreascalar/FloatArea.html#FloatArea">FloatArea r1, final FloatArea r2)
122     {
123         return (r1.gt(r2)) ? r1 : r2;
124     }
125 
126     /**
127      * Return the maximum value of more than two relative scalars.
128      * @param r1 the first scalar
129      * @param r2 the second scalar
130      * @param rn the other scalars
131      * @return the maximum value of more than two relative scalars
132      */
133     public static FloatAreascalar/FloatArea.html#FloatArea">FloatAreascalar/FloatArea.html#FloatArea">FloatArea max(final FloatAreascalar/FloatArea.html#FloatArea">FloatArea r1, final FloatArea r2, final FloatArea... rn)
134     {
135         FloatArea maxr = (r1.gt(r2)) ? r1 : r2;
136         for (FloatArea r : rn)
137         {
138             if (r.gt(maxr))
139             {
140                 maxr = r;
141             }
142         }
143         return maxr;
144     }
145 
146     /**
147      * Return the minimum value of two relative scalars.
148      * @param r1 the first scalar
149      * @param r2 the second scalar
150      * @return the minimum value of two relative scalars
151      */
152     public static FloatAreascalar/FloatArea.html#FloatArea">FloatAreascalar/FloatArea.html#FloatArea">FloatArea min(final FloatAreascalar/FloatArea.html#FloatArea">FloatArea r1, final FloatArea r2)
153     {
154         return (r1.lt(r2)) ? r1 : r2;
155     }
156 
157     /**
158      * Return the minimum value of more than two relative scalars.
159      * @param r1 the first scalar
160      * @param r2 the second scalar
161      * @param rn the other scalars
162      * @return the minimum value of more than two relative scalars
163      */
164     public static FloatAreascalar/FloatArea.html#FloatArea">FloatAreascalar/FloatArea.html#FloatArea">FloatArea min(final FloatAreascalar/FloatArea.html#FloatArea">FloatArea r1, final FloatArea r2, final FloatArea... rn)
165     {
166         FloatArea minr = (r1.lt(r2)) ? r1 : r2;
167         for (FloatArea r : rn)
168         {
169             if (r.lt(minr))
170             {
171                 minr = r;
172             }
173         }
174         return minr;
175     }
176 
177     /**
178      * Returns a FloatArea representation of a textual representation of a value with a unit. The String representation that can
179      * be parsed is the double value in the unit, followed by the official abbreviation of the unit. Spaces are allowed, but not
180      * required, between the value and the unit.
181      * @param text String; the textual representation to parse into a FloatArea
182      * @return FloatArea; the Scalar representation of the value in its unit
183      * @throws IllegalArgumentException when the text cannot be parsed
184      * @throws NullPointerException when the text argument is null
185      */
186     public static FloatArea valueOf(final String text)
187     {
188         Throw.whenNull(text, "Error parsing FloatArea: text to parse is null");
189         Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing FloatArea: empty text to parse");
190         Matcher matcher = ValueUtil.NUMBER_PATTERN.matcher(text);
191         if (matcher.find())
192         {
193             int index = matcher.end();
194             String unitString = text.substring(index).trim();
195             String valueString = text.substring(0, index).trim();
196             AreaUnit unit = AreaUnit.BASE.getUnitByAbbreviation(unitString);
197             if (unit != null)
198             {
199                 float f = Float.parseFloat(valueString);
200                 return new FloatArea(f, unit);
201             }
202         }
203         throw new IllegalArgumentException("Error parsing FloatArea from " + text);
204     }
205 
206     /**
207      * Returns a FloatArea based on a value and the textual representation of the unit.
208      * @param value double; the value to use
209      * @param unitString String; the textual representation of the unit
210      * @return FloatArea; the Scalar representation of the value in its unit
211      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
212      * @throws NullPointerException when the unitString argument is null
213      */
214     public static FloatArea of(final float value, final String unitString)
215     {
216         Throw.whenNull(unitString, "Error parsing FloatArea: unitString is null");
217         Throw.when(unitString.length() == 0, IllegalArgumentException.class, "Error parsing FloatArea: empty unitString");
218         AreaUnit unit = AreaUnit.BASE.getUnitByAbbreviation(unitString);
219         if (unit != null)
220         {
221             return new FloatArea(value, unit);
222         }
223         throw new IllegalArgumentException("Error parsing FloatArea with unit " + unitString);
224     }
225 
226     /**
227      * Calculate the division of FloatArea and FloatArea, which results in a FloatDimensionless scalar.
228      * @param v FloatArea scalar
229      * @return FloatDimensionless scalar as a division of FloatArea and FloatArea
230      */
231     public final FloatDimensionless divide(final FloatArea v)
232     {
233         return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
234     }
235 
236     /**
237      * Calculate the multiplication of FloatArea and FloatLength, which results in a FloatVolume scalar.
238      * @param v FloatArea scalar
239      * @return FloatVolume scalar as a multiplication of FloatArea and FloatLength
240      */
241     public final FloatVolume times(final FloatLength v)
242     {
243         return new FloatVolume(this.si * v.si, VolumeUnit.SI);
244     }
245 
246     /**
247      * Calculate the division of FloatArea and FloatLinearDensity, which results in a FloatVolume scalar.
248      * @param v FloatArea scalar
249      * @return FloatVolume scalar as a division of FloatArea and FloatLinearDensity
250      */
251     public final FloatVolume divide(final FloatLinearDensity v)
252     {
253         return new FloatVolume(this.si / v.si, VolumeUnit.SI);
254     }
255 
256     /**
257      * Calculate the division of FloatArea and FloatVolume, which results in a FloatLinearDensity scalar.
258      * @param v FloatArea scalar
259      * @return FloatLinearDensity scalar as a division of FloatArea and FloatVolume
260      */
261     public final FloatLinearDensity divide(final FloatVolume v)
262     {
263         return new FloatLinearDensity(this.si / v.si, LinearDensityUnit.SI);
264     }
265 
266     /**
267      * Calculate the division of FloatArea and FloatLength, which results in a FloatLength scalar.
268      * @param v FloatArea scalar
269      * @return FloatLength scalar as a division of FloatArea and FloatLength
270      */
271     public final FloatLengthr/FloatLength.html#FloatLength">FloatLength divide(final FloatLength v)
272     {
273         return new FloatLength(this.si / v.si, LengthUnit.SI);
274     }
275 
276     /**
277      * Calculate the multiplication of FloatArea and FloatLinearDensity, which results in a FloatLength scalar.
278      * @param v FloatArea scalar
279      * @return FloatLength scalar as a multiplication of FloatArea and FloatLinearDensity
280      */
281     public final FloatLength times(final FloatLinearDensity v)
282     {
283         return new FloatLength(this.si * v.si, LengthUnit.SI);
284     }
285 
286     /**
287      * Calculate the multiplication of FloatArea and FloatSpeed, which results in a FloatFlowVolume scalar.
288      * @param v FloatArea scalar
289      * @return FloatFlowVolume scalar as a multiplication of FloatArea and FloatSpeed
290      */
291     public final FloatFlowVolume times(final FloatSpeed v)
292     {
293         return new FloatFlowVolume(this.si * v.si, FlowVolumeUnit.SI);
294     }
295 
296     /**
297      * Calculate the multiplication of FloatArea and FloatPressure, which results in a FloatForce scalar.
298      * @param v FloatArea scalar
299      * @return FloatForce scalar as a multiplication of FloatArea and FloatPressure
300      */
301     public final FloatForce times(final FloatPressure v)
302     {
303         return new FloatForce(this.si * v.si, ForceUnit.SI);
304     }
305 
306     /**
307      * Calculate the multiplication of FloatArea and FloatIlluminance, which results in a FloatLuminousFlux scalar.
308      * @param v FloatArea scalar
309      * @return FloatLuminousFlux scalar as a multiplication of FloatArea and FloatIlluminance
310      */
311     public final FloatLuminousFlux times(final FloatIlluminance v)
312     {
313         return new FloatLuminousFlux(this.si * v.si, LuminousFluxUnit.SI);
314     }
315 
316 }