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