View Javadoc
1   package org.djunits.value.vdouble.scalar;
2   
3   import java.util.Locale;
4   
5   import org.djunits.unit.DimensionlessUnit;
6   import org.djunits.unit.ElectricalCapacitanceUnit;
7   import org.djunits.unit.ElectricalConductanceUnit;
8   import org.djunits.unit.ElectricalCurrentUnit;
9   import org.djunits.value.vdouble.scalar.base.DoubleScalarRel;
10  import org.djutils.base.NumberParser;
11  import org.djutils.exceptions.Throw;
12  
13  import jakarta.annotation.Generated;
14  
15  /**
16   * Easy access methods for the ElectricalConductance DoubleScalar, which is relative by definition.
17   * <p>
18   * Copyright (c) 2013-2024 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 = "2023-07-23T14:06:38.224104100Z")
25  public class ElectricalConductance extends DoubleScalarRel<ElectricalConductanceUnit, ElectricalConductance>
26  {
27      /** */
28      private static final long serialVersionUID = 20150905L;
29  
30      /** Constant with value zero. */
31      public static final ElectricalConductance ZERO = new ElectricalConductance(0.0, ElectricalConductanceUnit.SI);
32  
33      /** Constant with value one. */
34      public static final ElectricalConductance ONE = new ElectricalConductance(1.0, ElectricalConductanceUnit.SI);
35  
36      /** Constant with value NaN. */
37      @SuppressWarnings("checkstyle:constantname")
38      public static final ElectricalConductance NaN = new ElectricalConductance(Double.NaN, ElectricalConductanceUnit.SI);
39  
40      /** Constant with value POSITIVE_INFINITY. */
41      public static final ElectricalConductance POSITIVE_INFINITY =
42              new ElectricalConductance(Double.POSITIVE_INFINITY, ElectricalConductanceUnit.SI);
43  
44      /** Constant with value NEGATIVE_INFINITY. */
45      public static final ElectricalConductance NEGATIVE_INFINITY =
46              new ElectricalConductance(Double.NEGATIVE_INFINITY, ElectricalConductanceUnit.SI);
47  
48      /** Constant with value MAX_VALUE. */
49      public static final ElectricalConductance POS_MAXVALUE =
50              new ElectricalConductance(Double.MAX_VALUE, ElectricalConductanceUnit.SI);
51  
52      /** Constant with value -MAX_VALUE. */
53      public static final ElectricalConductance NEG_MAXVALUE =
54              new ElectricalConductance(-Double.MAX_VALUE, ElectricalConductanceUnit.SI);
55  
56      /**
57       * Construct ElectricalConductance scalar.
58       * @param value double; the double value
59       * @param unit ElectricalConductanceUnit; unit for the double value
60       */
61      public ElectricalConductance(final double value, final ElectricalConductanceUnit unit)
62      {
63          super(value, unit);
64      }
65  
66      /**
67       * Construct ElectricalConductance scalar.
68       * @param value ElectricalConductance; Scalar from which to construct this instance
69       */
70      public ElectricalConductance(final ElectricalConductance value)
71      {
72          super(value);
73      }
74  
75      @Override
76      public final ElectricalConductance instantiateRel(final double value, final ElectricalConductanceUnit unit)
77      {
78          return new ElectricalConductance(value, unit);
79      }
80  
81      /**
82       * Construct ElectricalConductance scalar.
83       * @param value double; the double value in SI units
84       * @return ElectricalConductance; the new scalar with the SI value
85       */
86      public static final ElectricalConductance instantiateSI(final double value)
87      {
88          return new ElectricalConductance(value, ElectricalConductanceUnit.SI);
89      }
90  
91      /**
92       * Interpolate between two values.
93       * @param zero ElectricalConductance; the low value
94       * @param one ElectricalConductance; the high value
95       * @param ratio double; the ratio between 0 and 1, inclusive
96       * @return ElectricalConductance; a Scalar at the ratio between
97       */
98      public static ElectricalConductance interpolate(final ElectricalConductance zero, final ElectricalConductance one,
99              final double ratio)
100     {
101         return new ElectricalConductance(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
102                 zero.getDisplayUnit());
103     }
104 
105     /**
106      * Return the maximum value of two relative scalars.
107      * @param r1 ElectricalConductance; the first scalar
108      * @param r2 ElectricalConductance; the second scalar
109      * @return ElectricalConductance; the maximum value of two relative scalars
110      */
111     public static ElectricalConductance max(final ElectricalConductance r1, final ElectricalConductance r2)
112     {
113         return r1.gt(r2) ? r1 : r2;
114     }
115 
116     /**
117      * Return the maximum value of more than two relative scalars.
118      * @param r1 ElectricalConductance; the first scalar
119      * @param r2 ElectricalConductance; the second scalar
120      * @param rn ElectricalConductance...; the other scalars
121      * @return ElectricalConductance; the maximum value of more than two relative scalars
122      */
123     public static ElectricalConductance max(final ElectricalConductance r1, final ElectricalConductance r2,
124             final ElectricalConductance... rn)
125     {
126         ElectricalConductance maxr = r1.gt(r2) ? r1 : r2;
127         for (ElectricalConductance r : rn)
128         {
129             if (r.gt(maxr))
130             {
131                 maxr = r;
132             }
133         }
134         return maxr;
135     }
136 
137     /**
138      * Return the minimum value of two relative scalars.
139      * @param r1 ElectricalConductance; the first scalar
140      * @param r2 ElectricalConductance; the second scalar
141      * @return ElectricalConductance; the minimum value of two relative scalars
142      */
143     public static ElectricalConductance min(final ElectricalConductance r1, final ElectricalConductance r2)
144     {
145         return r1.lt(r2) ? r1 : r2;
146     }
147 
148     /**
149      * Return the minimum value of more than two relative scalars.
150      * @param r1 ElectricalConductance; the first scalar
151      * @param r2 ElectricalConductance; the second scalar
152      * @param rn ElectricalConductance...; the other scalars
153      * @return ElectricalConductance; the minimum value of more than two relative scalars
154      */
155     public static ElectricalConductance min(final ElectricalConductance r1, final ElectricalConductance r2,
156             final ElectricalConductance... rn)
157     {
158         ElectricalConductance minr = r1.lt(r2) ? r1 : r2;
159         for (ElectricalConductance r : rn)
160         {
161             if (r.lt(minr))
162             {
163                 minr = r;
164             }
165         }
166         return minr;
167     }
168 
169     /**
170      * Returns a ElectricalConductance representation of a textual representation of a value with a unit. The String
171      * representation that can be parsed is the double value in the unit, followed by a localized or English abbreviation of the
172      * unit. Spaces are allowed, but not required, between the value and the unit.
173      * @param text String; the textual representation to parse into a ElectricalConductance
174      * @return ElectricalConductance; the Scalar representation of the value in its unit
175      * @throws IllegalArgumentException when the text cannot be parsed
176      * @throws NullPointerException when the text argument is null
177      */
178     public static ElectricalConductance valueOf(final String text)
179     {
180         Throw.whenNull(text, "Error parsing ElectricalConductance: text to parse is null");
181         Throw.when(text.length() == 0, IllegalArgumentException.class,
182                 "Error parsing ElectricalConductance: empty text to parse");
183         try
184         {
185             NumberParser numberParser = new NumberParser().lenient().trailing();
186             double d = numberParser.parseDouble(text);
187             String unitString = text.substring(numberParser.getTrailingPosition()).trim();
188             ElectricalConductanceUnit unit = ElectricalConductanceUnit.BASE.getUnitByAbbreviation(unitString);
189             if (unit == null)
190                 throw new IllegalArgumentException("Unit " + unitString + " not found");
191             return new ElectricalConductance(d, unit);
192         }
193         catch (Exception exception)
194         {
195             throw new IllegalArgumentException("Error parsing ElectricalConductance from " + text + " using Locale "
196                     + Locale.getDefault(Locale.Category.FORMAT), exception);
197         }
198     }
199 
200     /**
201      * Returns a ElectricalConductance based on a value and the textual representation of the unit, which can be localized.
202      * @param value double; the value to use
203      * @param unitString String; the textual representation of the unit
204      * @return ElectricalConductance; the Scalar representation of the value in its unit
205      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
206      * @throws NullPointerException when the unitString argument is null
207      */
208     public static ElectricalConductance of(final double value, final String unitString)
209     {
210         Throw.whenNull(unitString, "Error parsing ElectricalConductance: unitString is null");
211         Throw.when(unitString.length() == 0, IllegalArgumentException.class,
212                 "Error parsing ElectricalConductance: empty unitString");
213         ElectricalConductanceUnit unit = ElectricalConductanceUnit.BASE.getUnitByAbbreviation(unitString);
214         if (unit != null)
215         {
216             return new ElectricalConductance(value, unit);
217         }
218         throw new IllegalArgumentException("Error parsing ElectricalConductance with unit " + unitString);
219     }
220 
221     /**
222      * Calculate the division of ElectricalConductance and ElectricalConductance, which results in a Dimensionless scalar.
223      * @param v ElectricalConductance; scalar
224      * @return Dimensionless; scalar as a division of ElectricalConductance and ElectricalConductance
225      */
226     public final Dimensionless divide(final ElectricalConductance v)
227     {
228         return new Dimensionless(this.si / v.si, DimensionlessUnit.SI);
229     }
230 
231     /**
232      * Calculate the multiplication of ElectricalConductance and ElectricalResistance, which results in a Dimensionless scalar.
233      * @param v ElectricalConductance; scalar
234      * @return Dimensionless; scalar as a multiplication of ElectricalConductance and ElectricalResistance
235      */
236     public final Dimensionless times(final ElectricalResistance v)
237     {
238         return new Dimensionless(this.si * v.si, DimensionlessUnit.SI);
239     }
240 
241     /**
242      * Calculate the multiplication of ElectricalConductance and ElectricalPotential, which results in a ElectricalCurrent
243      * scalar.
244      * @param v ElectricalConductance; scalar
245      * @return ElectricalCurrent; scalar as a multiplication of ElectricalConductance and ElectricalPotential
246      */
247     public final ElectricalCurrent times(final ElectricalPotential v)
248     {
249         return new ElectricalCurrent(this.si * v.si, ElectricalCurrentUnit.SI);
250     }
251 
252     /**
253      * Calculate the multiplication of ElectricalConductance and Duration, which results in a ElectricalCapacitance scalar.
254      * @param v ElectricalConductance; scalar
255      * @return ElectricalCapacitance; scalar as a multiplication of ElectricalConductance and Duration
256      */
257     public final ElectricalCapacitance times(final Duration v)
258     {
259         return new ElectricalCapacitance(this.si * v.si, ElectricalCapacitanceUnit.SI);
260     }
261 
262     @Override
263     public ElectricalResistance reciprocal()
264     {
265         return ElectricalResistance.instantiateSI(1.0 / this.si);
266     }
267 
268 }