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.ForceUnit;
10 import org.djunits.unit.FrequencyUnit;
11 import org.djunits.unit.LengthUnit;
12 import org.djunits.unit.LinearDensityUnit;
13 import org.djunits.value.util.ValueUtil;
14 import org.djunits.value.vdouble.scalar.base.AbstractDoubleScalarRel;
15
16
17
18
19
20
21
22
23
24
25 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2020-01-19T15:21:24.964166400Z")
26 public class LinearDensity extends AbstractDoubleScalarRel<LinearDensityUnit, LinearDensity>
27 {
28
29 private static final long serialVersionUID = 20150905L;
30
31
32 public static final LinearDensityar/LinearDensity.html#LinearDensity">LinearDensity ZERO = new LinearDensity(0.0, LinearDensityUnit.SI);
33
34
35 public static final LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensity ONE = new LinearDensity(1.0, LinearDensityUnit.SI);
36
37
38 @SuppressWarnings("checkstyle:constantname")
39 public static final LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensity NaN = new LinearDensity(Double.NaN, LinearDensityUnit.SI);
40
41
42 public static final LinearDensityity.html#LinearDensity">LinearDensity POSITIVE_INFINITY = new LinearDensity(Double.POSITIVE_INFINITY, LinearDensityUnit.SI);
43
44
45 public static final LinearDensityity.html#LinearDensity">LinearDensity NEGATIVE_INFINITY = new LinearDensity(Double.NEGATIVE_INFINITY, LinearDensityUnit.SI);
46
47
48 public static final LinearDensityrDensity.html#LinearDensity">LinearDensity POS_MAXVALUE = new LinearDensity(Double.MAX_VALUE, LinearDensityUnit.SI);
49
50
51 public static final LinearDensityrDensity.html#LinearDensity">LinearDensity NEG_MAXVALUE = new LinearDensity(-Double.MAX_VALUE, LinearDensityUnit.SI);
52
53
54
55
56
57
58 public LinearDensity(final double value, final LinearDensityUnit unit)
59 {
60 super(value, unit);
61 }
62
63
64
65
66
67 public LinearDensity/scalar/LinearDensity.html#LinearDensity">LinearDensity(final LinearDensity value)
68 {
69 super(value);
70 }
71
72
73 @Override
74 public final LinearDensity instantiateRel(final double value, final LinearDensityUnit unit)
75 {
76 return new LinearDensity(value, unit);
77 }
78
79
80
81
82
83
84 public static final LinearDensity instantiateSI(final double value)
85 {
86 return new LinearDensity(value, LinearDensityUnit.SI);
87 }
88
89
90
91
92
93
94
95
96 public static LinearDensityr/LinearDensity.html#LinearDensity">LinearDensityarDensity.html#LinearDensity">LinearDensity interpolate(final LinearDensityr/LinearDensity.html#LinearDensity">LinearDensity zero, final LinearDensity one, final double ratio)
97 {
98 return new LinearDensity(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
99 zero.getDisplayUnit());
100 }
101
102
103
104
105
106
107
108 public static LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensity max(final LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensity r1, final LinearDensity r2)
109 {
110 return r1.gt(r2) ? r1 : r2;
111 }
112
113
114
115
116
117
118
119
120 public static LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensity max(final LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensity r1, final LinearDensity r2, final LinearDensity... rn)
121 {
122 LinearDensity maxr = r1.gt(r2) ? r1 : r2;
123 for (LinearDensity r : rn)
124 {
125 if (r.gt(maxr))
126 {
127 maxr = r;
128 }
129 }
130 return maxr;
131 }
132
133
134
135
136
137
138
139 public static LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensity min(final LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensity r1, final LinearDensity r2)
140 {
141 return r1.lt(r2) ? r1 : r2;
142 }
143
144
145
146
147
148
149
150
151 public static LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensity min(final LinearDensitylar/LinearDensity.html#LinearDensity">LinearDensity r1, final LinearDensity r2, final LinearDensity... rn)
152 {
153 LinearDensity minr = r1.lt(r2) ? r1 : r2;
154 for (LinearDensity r : rn)
155 {
156 if (r.lt(minr))
157 {
158 minr = r;
159 }
160 }
161 return minr;
162 }
163
164
165
166
167
168
169
170
171
172
173 public static LinearDensity valueOf(final String text)
174 {
175 Throw.whenNull(text, "Error parsing LinearDensity: text to parse is null");
176 Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing LinearDensity: empty text to parse");
177 Matcher matcher = ValueUtil.NUMBER_PATTERN.matcher(text);
178 if (matcher.find())
179 {
180 int index = matcher.end();
181 String unitString = text.substring(index).trim();
182 String valueString = text.substring(0, index).trim();
183 LinearDensityUnit unit = LinearDensityUnit.BASE.getUnitByAbbreviation(unitString);
184 if (unit != null)
185 {
186 double d = Double.parseDouble(valueString);
187 return new LinearDensity(d, unit);
188 }
189 }
190 throw new IllegalArgumentException("Error parsing LinearDensity from " + text);
191 }
192
193
194
195
196
197
198
199
200
201 public static LinearDensity of(final double value, final String unitString)
202 {
203 Throw.whenNull(unitString, "Error parsing LinearDensity: unitString is null");
204 Throw.when(unitString.length() == 0, IllegalArgumentException.class, "Error parsing LinearDensity: empty unitString");
205 LinearDensityUnit unit = LinearDensityUnit.BASE.getUnitByAbbreviation(unitString);
206 if (unit != null)
207 {
208 return new LinearDensity(value, unit);
209 }
210 throw new IllegalArgumentException("Error parsing LinearDensity with unit " + unitString);
211 }
212
213
214
215
216
217
218 public final Dimensionless divide(final LinearDensity v)
219 {
220 return new Dimensionless(this.si / v.si, DimensionlessUnit.SI);
221 }
222
223
224
225
226
227
228 public final Length times(final Area v)
229 {
230 return new Length(this.si * v.si, LengthUnit.SI);
231 }
232
233
234
235
236
237
238 public final Force times(final Energy v)
239 {
240 return new Force(this.si * v.si, ForceUnit.SI);
241 }
242
243
244
245
246
247
248 public final Frequency times(final Speed v)
249 {
250 return new Frequency(this.si * v.si, FrequencyUnit.SI);
251 }
252
253 }