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.ElectricalInductanceUnit;
10  import org.djunits.unit.MagneticFluxUnit;
11  import org.djunits.value.util.ValueUtil;
12  import org.djunits.value.vdouble.scalar.base.AbstractDoubleScalarRel;
13  
14  /**
15   * Easy access methods for the ElectricalInductance DoubleScalar, which is relative by definition.
16   * <p>
17   * Copyright (c) 2013-2020 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 = "2020-01-19T15:21:24.964166400Z")
24  public class ElectricalInductance extends AbstractDoubleScalarRel<ElectricalInductanceUnit, ElectricalInductance>
25  {
26      /** */
27      private static final long serialVersionUID = 20150905L;
28  
29      /** Constant with value zero. */
30      public static final ElectricalInductancetricalInductance.html#ElectricalInductance">ElectricalInductance ZERO = new ElectricalInductance(0.0, ElectricalInductanceUnit.SI);
31  
32      /** Constant with value one. */
33      public static final ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductance ONE = new ElectricalInductance(1.0, ElectricalInductanceUnit.SI);
34  
35      /** Constant with value NaN. */
36      @SuppressWarnings("checkstyle:constantname")
37      public static final ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductance NaN = new ElectricalInductance(Double.NaN, ElectricalInductanceUnit.SI);
38  
39      /** Constant with value POSITIVE_INFINITY. */
40      public static final ElectricalInductance POSITIVE_INFINITY =
41              new ElectricalInductance(Double.POSITIVE_INFINITY, ElectricalInductanceUnit.SI);
42  
43      /** Constant with value NEGATIVE_INFINITY. */
44      public static final ElectricalInductance NEGATIVE_INFINITY =
45              new ElectricalInductance(Double.NEGATIVE_INFINITY, ElectricalInductanceUnit.SI);
46  
47      /** Constant with value MAX_VALUE. */
48      public static final ElectricalInductance POS_MAXVALUE =
49              new ElectricalInductance(Double.MAX_VALUE, ElectricalInductanceUnit.SI);
50  
51      /** Constant with value -MAX_VALUE. */
52      public static final ElectricalInductance NEG_MAXVALUE =
53              new ElectricalInductance(-Double.MAX_VALUE, ElectricalInductanceUnit.SI);
54  
55      /**
56       * Construct ElectricalInductance scalar.
57       * @param value double; the double value
58       * @param unit ElectricalInductanceUnit; unit for the double value
59       */
60      public ElectricalInductance(final double value, final ElectricalInductanceUnit unit)
61      {
62          super(value, unit);
63      }
64  
65      /**
66       * Construct ElectricalInductance scalar.
67       * @param value ElectricalInductance; Scalar from which to construct this instance
68       */
69      public ElectricalInductance/ElectricalInductance.html#ElectricalInductance">ElectricalInductance(final ElectricalInductance value)
70      {
71          super(value);
72      }
73  
74      /** {@inheritDoc} */
75      @Override
76      public final ElectricalInductance instantiateRel(final double value, final ElectricalInductanceUnit unit)
77      {
78          return new ElectricalInductance(value, unit);
79      }
80  
81      /**
82       * Construct ElectricalInductance scalar.
83       * @param value double; the double value in SI units
84       * @return ElectricalInductance; the new scalar with the SI value
85       */
86      public static final ElectricalInductance instantiateSI(final double value)
87      {
88          return new ElectricalInductance(value, ElectricalInductanceUnit.SI);
89      }
90  
91      /**
92       * Interpolate between two values.
93       * @param zero ElectricalInductance; the low value
94       * @param one ElectricalInductance; the high value
95       * @param ratio double; the ratio between 0 and 1, inclusive
96       * @return ElectricalInductance; a Scalar at the ratio between
97       */
98      public static ElectricalInductancericalInductance.html#ElectricalInductance">ElectricalInductancenductance.html#ElectricalInductance">ElectricalInductance interpolate(final ElectricalInductancericalInductance.html#ElectricalInductance">ElectricalInductance zero, final ElectricalInductance one,
99              final double ratio)
100     {
101         return new ElectricalInductance(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 ElectricalInductance; the first scalar
108      * @param r2 ElectricalInductance; the second scalar
109      * @return ElectricalInductance; the maximum value of two relative scalars
110      */
111     public static ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductance max(final ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductance r1, final ElectricalInductance 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 ElectricalInductance; the first scalar
119      * @param r2 ElectricalInductance; the second scalar
120      * @param rn ElectricalInductance...; the other scalars
121      * @return ElectricalInductance; the maximum value of more than two relative scalars
122      */
123     public static ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductance max(final ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductance r1, final ElectricalInductance r2,
124             final ElectricalInductance... rn)
125     {
126         ElectricalInductance maxr = r1.gt(r2) ? r1 : r2;
127         for (ElectricalInductance 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 ElectricalInductance; the first scalar
140      * @param r2 ElectricalInductance; the second scalar
141      * @return ElectricalInductance; the minimum value of two relative scalars
142      */
143     public static ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductance min(final ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductance r1, final ElectricalInductance 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 ElectricalInductance; the first scalar
151      * @param r2 ElectricalInductance; the second scalar
152      * @param rn ElectricalInductance...; the other scalars
153      * @return ElectricalInductance; the minimum value of more than two relative scalars
154      */
155     public static ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductance min(final ElectricalInductancectricalInductance.html#ElectricalInductance">ElectricalInductance r1, final ElectricalInductance r2,
156             final ElectricalInductance... rn)
157     {
158         ElectricalInductance minr = r1.lt(r2) ? r1 : r2;
159         for (ElectricalInductance r : rn)
160         {
161             if (r.lt(minr))
162             {
163                 minr = r;
164             }
165         }
166         return minr;
167     }
168 
169     /**
170      * Returns a ElectricalInductance 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 the official abbreviation of the unit.
172      * Spaces are allowed, but not required, between the value and the unit.
173      * @param text String; the textual representation to parse into a ElectricalInductance
174      * @return ElectricalInductance; 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 ElectricalInductance valueOf(final String text)
179     {
180         Throw.whenNull(text, "Error parsing ElectricalInductance: text to parse is null");
181         Throw.when(text.length() == 0, IllegalArgumentException.class,
182                 "Error parsing ElectricalInductance: empty text to parse");
183         Matcher matcher = ValueUtil.NUMBER_PATTERN.matcher(text);
184         if (matcher.find())
185         {
186             int index = matcher.end();
187             String unitString = text.substring(index).trim();
188             String valueString = text.substring(0, index).trim();
189             ElectricalInductanceUnit unit = ElectricalInductanceUnit.BASE.getUnitByAbbreviation(unitString);
190             if (unit != null)
191             {
192                 double d = Double.parseDouble(valueString);
193                 return new ElectricalInductance(d, unit);
194             }
195         }
196         throw new IllegalArgumentException("Error parsing ElectricalInductance from " + text);
197     }
198 
199     /**
200      * Returns a ElectricalInductance based on a value and the textual representation of the unit.
201      * @param value double; the value to use
202      * @param unitString String; the textual representation of the unit
203      * @return ElectricalInductance; the Scalar representation of the value in its unit
204      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
205      * @throws NullPointerException when the unitString argument is null
206      */
207     public static ElectricalInductance of(final double value, final String unitString)
208     {
209         Throw.whenNull(unitString, "Error parsing ElectricalInductance: unitString is null");
210         Throw.when(unitString.length() == 0, IllegalArgumentException.class,
211                 "Error parsing ElectricalInductance: empty unitString");
212         ElectricalInductanceUnit unit = ElectricalInductanceUnit.BASE.getUnitByAbbreviation(unitString);
213         if (unit != null)
214         {
215             return new ElectricalInductance(value, unit);
216         }
217         throw new IllegalArgumentException("Error parsing ElectricalInductance with unit " + unitString);
218     }
219 
220     /**
221      * Calculate the division of ElectricalInductance and ElectricalInductance, which results in a Dimensionless scalar.
222      * @param v ElectricalInductance scalar
223      * @return Dimensionless scalar as a division of ElectricalInductance and ElectricalInductance
224      */
225     public final Dimensionless divide(final ElectricalInductance v)
226     {
227         return new Dimensionless(this.si / v.si, DimensionlessUnit.SI);
228     }
229 
230     /**
231      * Calculate the multiplication of ElectricalInductance and ElectricalCurrent, which results in a MagneticFlux scalar.
232      * @param v ElectricalInductance scalar
233      * @return MagneticFlux scalar as a multiplication of ElectricalInductance and ElectricalCurrent
234      */
235     public final MagneticFlux times(final ElectricalCurrent v)
236     {
237         return new MagneticFlux(this.si * v.si, MagneticFluxUnit.SI);
238     }
239 
240 }