View Javadoc
1   package org.djunits.value.vdouble.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.AmountOfSubstanceUnit;
9   import org.djunits.unit.CatalyticActivityUnit;
10  import org.djunits.unit.DimensionlessUnit;
11  import org.djunits.unit.FrequencyUnit;
12  import org.djunits.value.util.ValueUtil;
13  import org.djunits.value.vdouble.scalar.base.AbstractDoubleScalarRel;
14  
15  /**
16   * Easy access methods for the CatalyticActivity DoubleScalar, which is relative by definition.
17   * <p>
18   * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
19   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
20   * </p>
21   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
22   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
23   */
24  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2020-01-19T15:21:24.964166400Z")
25  public class CatalyticActivity extends AbstractDoubleScalarRel<CatalyticActivityUnit, CatalyticActivity>
26  {
27      /** */
28      private static final long serialVersionUID = 20150905L;
29  
30      /** Constant with value zero. */
31      public static final CatalyticActivityatalyticActivity.html#CatalyticActivity">CatalyticActivity ZERO = new CatalyticActivity(0.0, CatalyticActivityUnit.SI);
32  
33      /** Constant with value one. */
34      public static final CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivity ONE = new CatalyticActivity(1.0, CatalyticActivityUnit.SI);
35  
36      /** Constant with value NaN. */
37      @SuppressWarnings("checkstyle:constantname")
38      public static final CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivity NaN = new CatalyticActivity(Double.NaN, CatalyticActivityUnit.SI);
39  
40      /** Constant with value POSITIVE_INFINITY. */
41      public static final CatalyticActivity POSITIVE_INFINITY =
42              new CatalyticActivity(Double.POSITIVE_INFINITY, CatalyticActivityUnit.SI);
43  
44      /** Constant with value NEGATIVE_INFINITY. */
45      public static final CatalyticActivity NEGATIVE_INFINITY =
46              new CatalyticActivity(Double.NEGATIVE_INFINITY, CatalyticActivityUnit.SI);
47  
48      /** Constant with value MAX_VALUE. */
49      public static final CatalyticActivityActivity.html#CatalyticActivity">CatalyticActivity POS_MAXVALUE = new CatalyticActivity(Double.MAX_VALUE, CatalyticActivityUnit.SI);
50  
51      /** Constant with value -MAX_VALUE. */
52      public static final CatalyticActivityActivity.html#CatalyticActivity">CatalyticActivity NEG_MAXVALUE = new CatalyticActivity(-Double.MAX_VALUE, CatalyticActivityUnit.SI);
53  
54      /**
55       * Construct CatalyticActivity scalar.
56       * @param value double; the double value
57       * @param unit CatalyticActivityUnit; unit for the double value
58       */
59      public CatalyticActivity(final double value, final CatalyticActivityUnit unit)
60      {
61          super(value, unit);
62      }
63  
64      /**
65       * Construct CatalyticActivity scalar.
66       * @param value CatalyticActivity; Scalar from which to construct this instance
67       */
68      public CatalyticActivitylar/CatalyticActivity.html#CatalyticActivity">CatalyticActivity(final CatalyticActivity value)
69      {
70          super(value);
71      }
72  
73      /** {@inheritDoc} */
74      @Override
75      public final CatalyticActivity instantiateRel(final double value, final CatalyticActivityUnit unit)
76      {
77          return new CatalyticActivity(value, unit);
78      }
79  
80      /**
81       * Construct CatalyticActivity scalar.
82       * @param value double; the double value in SI units
83       * @return CatalyticActivity; the new scalar with the SI value
84       */
85      public static final CatalyticActivity instantiateSI(final double value)
86      {
87          return new CatalyticActivity(value, CatalyticActivityUnit.SI);
88      }
89  
90      /**
91       * Interpolate between two values.
92       * @param zero CatalyticActivity; the low value
93       * @param one CatalyticActivity; the high value
94       * @param ratio double; the ratio between 0 and 1, inclusive
95       * @return CatalyticActivity; a Scalar at the ratio between
96       */
97      public static CatalyticActivitytalyticActivity.html#CatalyticActivity">CatalyticActivitycActivity.html#CatalyticActivity">CatalyticActivity interpolate(final CatalyticActivitytalyticActivity.html#CatalyticActivity">CatalyticActivity zero, final CatalyticActivity one, final double ratio)
98      {
99          return new CatalyticActivity(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
100                 zero.getDisplayUnit());
101     }
102 
103     /**
104      * Return the maximum value of two relative scalars.
105      * @param r1 CatalyticActivity; the first scalar
106      * @param r2 CatalyticActivity; the second scalar
107      * @return CatalyticActivity; the maximum value of two relative scalars
108      */
109     public static CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivity max(final CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivity r1, final CatalyticActivity r2)
110     {
111         return r1.gt(r2) ? r1 : r2;
112     }
113 
114     /**
115      * Return the maximum value of more than two relative scalars.
116      * @param r1 CatalyticActivity; the first scalar
117      * @param r2 CatalyticActivity; the second scalar
118      * @param rn CatalyticActivity...; the other scalars
119      * @return CatalyticActivity; the maximum value of more than two relative scalars
120      */
121     public static CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivity max(final CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivity r1, final CatalyticActivity r2, final CatalyticActivity... rn)
122     {
123         CatalyticActivity maxr = r1.gt(r2) ? r1 : r2;
124         for (CatalyticActivity r : rn)
125         {
126             if (r.gt(maxr))
127             {
128                 maxr = r;
129             }
130         }
131         return maxr;
132     }
133 
134     /**
135      * Return the minimum value of two relative scalars.
136      * @param r1 CatalyticActivity; the first scalar
137      * @param r2 CatalyticActivity; the second scalar
138      * @return CatalyticActivity; the minimum value of two relative scalars
139      */
140     public static CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivity min(final CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivity r1, final CatalyticActivity r2)
141     {
142         return r1.lt(r2) ? r1 : r2;
143     }
144 
145     /**
146      * Return the minimum value of more than two relative scalars.
147      * @param r1 CatalyticActivity; the first scalar
148      * @param r2 CatalyticActivity; the second scalar
149      * @param rn CatalyticActivity...; the other scalars
150      * @return CatalyticActivity; the minimum value of more than two relative scalars
151      */
152     public static CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivity min(final CatalyticActivityCatalyticActivity.html#CatalyticActivity">CatalyticActivity r1, final CatalyticActivity r2, final CatalyticActivity... rn)
153     {
154         CatalyticActivity minr = r1.lt(r2) ? r1 : r2;
155         for (CatalyticActivity r : rn)
156         {
157             if (r.lt(minr))
158             {
159                 minr = r;
160             }
161         }
162         return minr;
163     }
164 
165     /**
166      * Returns a CatalyticActivity representation of a textual representation of a value with a unit. The String representation
167      * that can be parsed is the double value in the unit, followed by the official abbreviation of the unit. Spaces are
168      * allowed, but not required, between the value and the unit.
169      * @param text String; the textual representation to parse into a CatalyticActivity
170      * @return CatalyticActivity; the Scalar representation of the value in its unit
171      * @throws IllegalArgumentException when the text cannot be parsed
172      * @throws NullPointerException when the text argument is null
173      */
174     public static CatalyticActivity valueOf(final String text)
175     {
176         Throw.whenNull(text, "Error parsing CatalyticActivity: text to parse is null");
177         Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing CatalyticActivity: empty text to parse");
178         Matcher matcher = ValueUtil.NUMBER_PATTERN.matcher(text);
179         if (matcher.find())
180         {
181             int index = matcher.end();
182             String unitString = text.substring(index).trim();
183             String valueString = text.substring(0, index).trim();
184             CatalyticActivityUnit unit = CatalyticActivityUnit.BASE.getUnitByAbbreviation(unitString);
185             if (unit != null)
186             {
187                 double d = Double.parseDouble(valueString);
188                 return new CatalyticActivity(d, unit);
189             }
190         }
191         throw new IllegalArgumentException("Error parsing CatalyticActivity from " + text);
192     }
193 
194     /**
195      * Returns a CatalyticActivity based on a value and the textual representation of the unit.
196      * @param value double; the value to use
197      * @param unitString String; the textual representation of the unit
198      * @return CatalyticActivity; the Scalar representation of the value in its unit
199      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
200      * @throws NullPointerException when the unitString argument is null
201      */
202     public static CatalyticActivity of(final double value, final String unitString)
203     {
204         Throw.whenNull(unitString, "Error parsing CatalyticActivity: unitString is null");
205         Throw.when(unitString.length() == 0, IllegalArgumentException.class,
206                 "Error parsing CatalyticActivity: empty unitString");
207         CatalyticActivityUnit unit = CatalyticActivityUnit.BASE.getUnitByAbbreviation(unitString);
208         if (unit != null)
209         {
210             return new CatalyticActivity(value, unit);
211         }
212         throw new IllegalArgumentException("Error parsing CatalyticActivity with unit " + unitString);
213     }
214 
215     /**
216      * Calculate the division of CatalyticActivity and CatalyticActivity, which results in a Dimensionless scalar.
217      * @param v CatalyticActivity scalar
218      * @return Dimensionless scalar as a division of CatalyticActivity and CatalyticActivity
219      */
220     public final Dimensionless divide(final CatalyticActivity v)
221     {
222         return new Dimensionless(this.si / v.si, DimensionlessUnit.SI);
223     }
224 
225     /**
226      * Calculate the multiplication of CatalyticActivity and Duration, which results in a AmountOfSubstance scalar.
227      * @param v CatalyticActivity scalar
228      * @return AmountOfSubstance scalar as a multiplication of CatalyticActivity and Duration
229      */
230     public final AmountOfSubstance times(final Duration v)
231     {
232         return new AmountOfSubstance(this.si * v.si, AmountOfSubstanceUnit.SI);
233     }
234 
235     /**
236      * Calculate the division of CatalyticActivity and AmountOfSubstance, which results in a Frequency scalar.
237      * @param v CatalyticActivity scalar
238      * @return Frequency scalar as a division of CatalyticActivity and AmountOfSubstance
239      */
240     public final Frequency divide(final AmountOfSubstance v)
241     {
242         return new Frequency(this.si / v.si, FrequencyUnit.SI);
243     }
244 
245     /**
246      * Calculate the division of CatalyticActivity and Frequency, which results in a AmountOfSubstance scalar.
247      * @param v CatalyticActivity scalar
248      * @return AmountOfSubstance scalar as a division of CatalyticActivity and Frequency
249      */
250     public final AmountOfSubstance divide(final Frequency v)
251     {
252         return new AmountOfSubstance(this.si / v.si, AmountOfSubstanceUnit.SI);
253     }
254 
255 }