001/*
002 * Units of Measurement Reference Implementation
003 * Copyright (c) 2005-2020, Units of Measurement project.
004 *
005 * All rights reserved.
006 *
007 * Redistribution and use in source and binary forms, with or without modification,
008 * are permitted provided that the following conditions are met:
009 *
010 * 1. Redistributions of source code must retain the above copyright notice,
011 *    this list of conditions and the following disclaimer.
012 *
013 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
014 *    and the following disclaimer in the documentation and/or other materials provided with the distribution.
015 *
016 * 3. Neither the name of JSR-385, Indriya nor the names of their contributors may be used to endorse or promote products
017 *    derived from this software without specific prior written permission.
018 *
019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
021 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
023 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
026 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029 */
030package tech.units.indriya.unit;
031
032import static tech.units.indriya.AbstractUnit.ONE;
033
034import javax.measure.Quantity;
035import javax.measure.Unit;
036import javax.measure.quantity.Acceleration;
037import javax.measure.quantity.AmountOfSubstance;
038import javax.measure.quantity.Angle;
039import javax.measure.quantity.Area;
040import javax.measure.quantity.CatalyticActivity;
041import javax.measure.quantity.Dimensionless;
042import javax.measure.quantity.ElectricCapacitance;
043import javax.measure.quantity.ElectricCharge;
044import javax.measure.quantity.ElectricConductance;
045import javax.measure.quantity.ElectricCurrent;
046import javax.measure.quantity.ElectricInductance;
047import javax.measure.quantity.ElectricPotential;
048import javax.measure.quantity.ElectricResistance;
049import javax.measure.quantity.Energy;
050import javax.measure.quantity.Force;
051import javax.measure.quantity.Frequency;
052import javax.measure.quantity.Illuminance;
053import javax.measure.quantity.Length;
054import javax.measure.quantity.LuminousFlux;
055import javax.measure.quantity.LuminousIntensity;
056import javax.measure.quantity.MagneticFlux;
057import javax.measure.quantity.MagneticFluxDensity;
058import javax.measure.quantity.Mass;
059import javax.measure.quantity.Power;
060import javax.measure.quantity.Pressure;
061import javax.measure.quantity.RadiationDoseAbsorbed;
062import javax.measure.quantity.RadiationDoseEffective;
063import javax.measure.quantity.Radioactivity;
064import javax.measure.quantity.SolidAngle;
065import javax.measure.quantity.Speed;
066import javax.measure.quantity.Temperature;
067import javax.measure.quantity.Time;
068import javax.measure.quantity.Volume;
069import javax.measure.spi.SystemOfUnits;
070
071import tech.units.indriya.AbstractSystemOfUnits;
072import tech.units.indriya.AbstractUnit;
073import tech.units.indriya.function.AddConverter;
074import tech.units.indriya.function.MultiplyConverter;
075import tech.units.indriya.function.RationalNumber;
076import tech.units.indriya.unit.UnitDimension;
077
078/**
079 * <p>
080 * This class defines commonly used units.
081 *
082 * @author <a href="mailto:werner@units.tech">Werner Keil</a>
083 * @version 1.4, July 05, 2019
084 * @since 1.0
085 */
086public class Units extends AbstractSystemOfUnits {
087
088        protected Units() {
089        }
090
091        private static final Units INSTANCE = new Units();
092
093        public String getName() {
094                return Units.class.getSimpleName();
095        }
096
097        // //////////////
098        // BASE UNITS //
099        // //////////////
100
101        /**
102         * The ampere, symbol A, is the SI unit of electric current. It is defined by taking the
103         * fixed numerical value of the elementary charge e to be 1.602 176 634 × 10⁻¹⁹ when
104         * expressed in the unit C, which is equal to A s, where the second is defined in terms
105         * of ∆νCs.
106         *
107         * This definition implies the exact relation e = 1.602 176 634 × 10⁻¹⁹ A s. Inverting this
108         * relation gives an exact expression for the unit ampere in terms of the defining constants e
109         * and ∆νCs:
110         *
111         * 1 A = (e / 1.602 176 634 × 10⁻¹⁹) s⁻¹
112         *
113         * @implNote SI Base Unit
114         */
115        public static final Unit<ElectricCurrent> AMPERE = addUnit(new BaseUnit<ElectricCurrent>("A", UnitDimension.ELECTRIC_CURRENT),
116                ElectricCurrent.class);
117
118        /**
119         * The candela, symbol cd, is the SI unit of luminous intensity in a given direction. It is
120         * defined by taking the fixed numerical value of the luminous efficacy of
121         * monochromatic radiation of frequency 540 × 10¹² Hz, Kcd, to be 683 when expressed
122         * in the unit lm W−1, which is equal to cd sr W⁻¹, or cd sr kg⁻¹ m⁻² s³, where the kilogram,
123         * metre and second are defined in terms of h, c and ∆νCs.
124         *
125         * This definition implies the exact relation Kcd = 683 cd sr kg⁻¹ m⁻² s³ for monochromatic
126         * radiation of frequency ν = 540 × 10¹² Hz. Inverting this relation gives an exact expression
127         * for the candela in terms of the defining constants Kcd, h and ∆νCs:
128         *
129         * 1 cd = (Kcd / 683) kg m² s⁻³ sr⁻¹
130         *
131         * @see <a href="http://en.wikipedia.org/wiki/Candela"> Wikipedia: Candela</a>
132         *
133         * @implNote SI Base Unit
134         */
135        public static final Unit<LuminousIntensity> CANDELA = addUnit(new BaseUnit<LuminousIntensity>("cd", UnitDimension.LUMINOUS_INTENSITY),
136                LuminousIntensity.class);
137
138        /**
139         * The kelvin, symbol K, is the SI unit of thermodynamic temperature. It is defined by
140         * taking the fixed numerical value of the Boltzmann constant k to be 1.380 649 × 10−²³
141         * when expressed in the unit J K⁻¹, which is equal to kg m² s⁻² K⁻¹, where the
142         * kilogram, metre and second are defined in terms of h, c and ∆νCs.
143         *
144         * This definition implies the exact relation k = 1.380 649 × 10⁻²³ kg m² s⁻² K⁻¹. Inverting this
145         * relation gives an exact expression for the kelvin in terms of the defining constants k, h and
146         * ∆νCs:
147         *
148         * 1 K = (1.380 649 / k) × 10⁻²³ kg m² s⁻²
149         *
150         * @see #JOULE
151         * @implNote SI Base Unit
152         */
153        public static final Unit<Temperature> KELVIN = addUnit(new BaseUnit<Temperature>("K", UnitDimension.TEMPERATURE), Temperature.class);
154
155        /**
156         * The kilogram, symbol kg, is the SI unit of mass. It is defined by taking the fixed
157         * numerical value of the Planck constant h to be 6.626 070 15 × 10⁻³⁴ when expressed
158         * in the unit J s, which is equal to kg m² s−1, where the metre and the second are
159         * defined in terms of c and ∆νCs.
160         *
161         * This definition implies the exact relation h = 6.626 070 15 × 10−34 kg m² s⁻¹. Inverting this
162         * relation gives an exact expression for the kilogram in terms of the three defining constants
163         * h, ∆νCs and c:
164         *
165         * 1 kg = (h / 6.626 070 15 × 10⁻³⁴) m⁻² s
166         *
167         * @see <a href="https://en.wikipedia.org/wiki/Kilogram">Wikipedia: Kilogram</a>
168         * @see #GRAM
169         * @see #METRE
170         * @see #SECOND
171         *
172         * @implNote SI Base Unit
173         */
174        public static final Unit<Mass> KILOGRAM = addUnit(new BaseUnit<Mass>("kg", UnitDimension.MASS), Mass.class);
175
176        /**
177         * The metre, symbol m, is the SI unit of length. It is defined by taking the fixed
178         * numerical value of the speed of light in vacuum c to be 299 792 458 when expressed
179         * in the unit m s⁻¹, where the second is defined in terms of the caesium frequency
180         * ∆νCs.
181         *
182         * This definition implies the exact relation c = 299 792 458 m s⁻¹. Inverting this relation
183         * gives an exact expression for the metre in terms of the defining constants c and ∆νCs:
184         *
185         * 1 m = (c / 299 792 458)s = 9 192 631 770 c / 299 792 458 ∆νCs ≈ 30.663 319 c / ∆νCs
186         *
187         * @implNote SI Base Unit
188         */
189        public static final Unit<Length> METRE = addUnit(new BaseUnit<>("m", UnitDimension.LENGTH), Length.class);
190
191        /**
192         * The mole, symbol mol, is the SI unit of amount of substance. One mole contains
193         * exactly 6.022 140 76 × 10²³ elementary entities. This number is the fixed numerical
194         * value of the Avogadro constant, NA, when expressed in the unit mol⁻¹ and is called
195         * the Avogadro number.
196         *
197         * The amount of substance, symbol n, of a system is a measure of the number of
198         * specified elementary entities. An elementary entity may be an atom, a molecule, an
199         * ion, an electron, any other particle or specified group of particles.
200         * This definition implies the exact relation Nₐ = 6.022 140 76 × 10²³ mol⁻¹.
201         *
202         * Inverting this relation gives an exact expression for the mole in terms of the defining constant NA:
203         *
204         * 1 mol = 6.02214076 × 10²³ / Nₐ
205         *
206         * @implNote SI Base Unit
207         */
208        public static final Unit<AmountOfSubstance> MOLE = addUnit(new BaseUnit<>("mol", UnitDimension.AMOUNT_OF_SUBSTANCE), AmountOfSubstance.class);
209
210        /**
211         * The second, symbol s, is the SI unit of time. It is defined by taking the fixed
212         * numerical value of the caesium frequency ∆νCs, the unperturbed ground-state
213         * hyperfine transition frequency of the caesium 133 atom, to be 9 192 631 770 when
214         * expressed in the unit Hz, which is equal to s⁻¹.
215         *
216         * This definition implies the exact relation ∆νCs = 9 192 631 770 Hz. Inverting this relation
217         * gives an expression for the unit second in terms of the defining constant ∆νCs:
218         *
219         * 1 Hz = ∆νCs / 9 192 631 770  or  1 s = 9 192 631 770 / ∆νCs
220         * @implNote SI Base Unit
221         */
222        public static final Unit<Time> SECOND = addUnit(new BaseUnit<>("s", UnitDimension.TIME), Time.class);
223
224        // //////////////////////////////
225        // SI DERIVED ALTERNATE UNITS //
226        // //////////////////////////////
227
228        /**
229         * The SI derived unit for mass quantities (standard name <code>g</code>). The base unit for mass quantity is {@link #KILOGRAM}.
230         */
231        public static final Unit<Mass> GRAM = addUnit(KILOGRAM.divide(1000));
232        // = new TransformedUnit(KILOGRAM, MetricPrefix.KILO.getConverter());
233
234        /**
235         * The SI unit for plane angle quantities (standard name <code>rad</code>). One radian is the angle between two radii of a circle such that the
236         * length of the arc between them is equal to the radius.
237         */
238        public static final Unit<Angle> RADIAN = addUnit(AlternateUnit.of(ONE, "rad"), Angle.class);
239
240        /**
241         * The SI unit for solid angle quantities (standard name <code>sr</code>). One steradian is the solid angle subtended at the center of a sphere by
242         * an area on the surface of the sphere that is equal to the radius squared. The total solid angle of a sphere is 4*Pi steradians.
243         */
244        public static final Unit<SolidAngle> STERADIAN = addUnit(new AlternateUnit<>(ONE, "sr"), SolidAngle.class);
245
246        /**
247         * The SI unit for frequency (standard name <code>Hz</code>). A unit of frequency equal to one cycle per second. After Heinrich Rudolf Hertz
248         * (1857-1894), German physicist who was the first to produce radio waves artificially.
249         */
250        public static final Unit<Frequency> HERTZ = addUnit(new AlternateUnit<Frequency>(ONE.divide(SECOND), "Hz"), Frequency.class);
251
252        /**
253         * The SI unit for force (standard name <code>N</code>). One newton is the force required to give a mass of 1 kilogram an Force of 1 metre per
254         * second per second. It is named after the English mathematician and physicist Sir Isaac Newton (1642-1727).
255         */
256        public static final Unit<Force> NEWTON = addUnit(new AlternateUnit<Force>(METRE.multiply(KILOGRAM).divide(SECOND.pow(2)), "N"), Force.class);
257
258        /**
259         * The SI unit for pressure, stress (standard name <code>Pa</code>). One pascal is equal to one newton per square meter. It is named after the
260         * French philosopher and mathematician Blaise Pascal (1623-1662).
261         */
262        @SuppressWarnings({ "unchecked", "rawtypes" })
263        public static final Unit<Pressure> PASCAL = addUnit(new AlternateUnit(NEWTON.divide(METRE.pow(2)), "Pa"), Pressure.class);
264
265        /**
266         * The SI unit for energy, work, quantity of heat (<code>J</code>). One joule is the amount of work done when an applied force of 1 newton moves
267         * through a distance of 1 metre in the direction of the force. It is named after the English physicist James Prescott Joule (1818-1889).
268         */
269        public static final Unit<Energy> JOULE = addUnit(new AlternateUnit<Energy>(NEWTON.multiply(METRE), "J"), Energy.class);
270
271        /**
272         * The SI unit for power, radiant, flux (standard name <code>W</code>). One watt is equal to one joule per second. It is named after the British
273         * scientist James Watt (1736-1819).
274         */
275        public static final Unit<Power> WATT = addUnit(new AlternateUnit<Power>(JOULE.divide(SECOND), "W"), Power.class);
276
277        /**
278         * The SI unit for electric charge, quantity of electricity (standard name <code>C</code>). One Coulomb is equal to the quantity of charge
279         * transferred in one second by a steady current of one ampere. It is named after the French physicist Charles Augustin de Coulomb (1736-1806).
280         */
281        public static final Unit<ElectricCharge> COULOMB = addUnit(new AlternateUnit<ElectricCharge>(SECOND.multiply(AMPERE), "C"), ElectricCharge.class);
282
283        /**
284         * The SI unit for electric potential difference, electromotive force (standard name <code>V</code>). One Volt is equal to the difference of
285         * electric potential between two points on a conducting wire carrying a constant current of one ampere when the power dissipated between the points
286         * is one watt. It is named after the Italian physicist Count Alessandro Volta (1745-1827).
287         */
288        public static final Unit<ElectricPotential> VOLT = addUnit(new AlternateUnit<ElectricPotential>(WATT.divide(AMPERE), "V"), ElectricPotential.class);
289
290        /**
291         * The SI unit for capacitance (standard name <code>F</code>). One Farad is equal to the capacitance of a capacitor having an equal and opposite
292         * charge of 1 coulomb on each plate and a potential difference of 1 volt between the plates. It is named after the British physicist and chemist
293         * Michael Faraday (1791-1867).
294         */
295        public static final Unit<ElectricCapacitance> FARAD = addUnit(new AlternateUnit<ElectricCapacitance>(COULOMB.divide(VOLT), "F"),
296                ElectricCapacitance.class);
297
298        /**
299         * The SI unit for electric resistance (standard name <code>Ohm</code>). One Ohm is equal to the resistance of a conductor in which a current of one
300         * ampere is produced by a potential of one volt across its terminals. It is named after the German physicist Georg Simon Ohm (1789-1854).
301         */
302        public static final Unit<ElectricResistance> OHM = addUnit(new AlternateUnit<ElectricResistance>(VOLT.divide(AMPERE), "Ω"),
303                ElectricResistance.class);
304
305        /**
306         * The SI unit for electric conductance (standard name <code>S</code>). One Siemens is equal to one ampere per volt. It is named after the German
307         * engineer Ernst Werner von Siemens (1816-1892).
308         */
309        public static final Unit<ElectricConductance> SIEMENS = addUnit(new AlternateUnit<ElectricConductance>(AMPERE.divide(VOLT), "S"),
310                ElectricConductance.class);
311
312        /**
313         * The SI unit for magnetic flux (standard name <code>Wb</code>). One Weber is equal to the magnetic flux that in linking a circuit of one turn
314         * produces in it an electromotive force of one volt as it is uniformly reduced to zero within one second. It is named after the German physicist
315         * Wilhelm Eduard Weber (1804-1891).
316         */
317        public static final Unit<MagneticFlux> WEBER = addUnit(new AlternateUnit<MagneticFlux>(VOLT.multiply(SECOND), "Wb"), MagneticFlux.class);
318
319        /**
320         * The alternate unit for magnetic flux density (standard name <code>T</code>). One Tesla is equal equal to one weber per square metre. It is named
321         * after the Serbian-born American electrical engineer and physicist Nikola Tesla (1856-1943).
322         */
323        public static final Unit<MagneticFluxDensity> TESLA = addUnit(new AlternateUnit<MagneticFluxDensity>(WEBER.divide(METRE.pow(2)), "T"),
324                MagneticFluxDensity.class);
325
326        /**
327         * The alternate unit for inductance (standard name <code>H</code>). One Henry is equal to the inductance for which an induced electromotive force
328         * of one volt is produced when the current is varied at the rate of one ampere per second. It is named after the American physicist Joseph Henry
329         * (1791-1878).
330         */
331        public static final Unit<ElectricInductance> HENRY = addUnit(new AlternateUnit<ElectricInductance>(WEBER.divide(AMPERE), "H"),
332                ElectricInductance.class);
333
334        /**
335         * The SI unit for Celsius temperature (standard name <code>Cel</code>). This is a unit of temperature such as the freezing point of water (at one
336         * atmosphere of pressure) is 0 Cel, while the boiling point is 100 Cel.
337         */
338        @SuppressWarnings({ "rawtypes", "unchecked" })
339        public static final Unit<Temperature> CELSIUS = addUnit(new TransformedUnit(KELVIN, new AddConverter(273.15)));
340        // Not mapping to Temperature since temperature is mapped to Kelvin.
341
342        /**
343         * The SI unit for luminous flux (standard name <code>lm</code>). One Lumen is equal to the amount of light given out through a solid angle by a
344         * source of one candela intensity radiating equally in all directions.
345         */
346        public static final Unit<LuminousFlux> LUMEN = addUnit(new AlternateUnit<LuminousFlux>(CANDELA.multiply(STERADIAN), "lm"), LuminousFlux.class);
347
348        /**
349         * The SI unit for illuminance (standard name <code>lx</code>). One Lux is equal to one lumen per square metre.
350         */
351        public static final Unit<Illuminance> LUX = addUnit(new AlternateUnit<Illuminance>(LUMEN.divide(METRE.pow(2)), "lx"), Illuminance.class);
352
353        /**
354         * The SI unit for activity of a radionuclide (standard name <code>Bq</code> ). One becquerel is the radiation caused by one disintegration per
355         * second. It is named after the French physicist, Antoine-Henri Becquerel (1852-1908).
356         */
357        public static final Unit<Radioactivity> BECQUEREL = addUnit(new AlternateUnit<Radioactivity>(ONE.divide(SECOND), "Bq"), Radioactivity.class);
358
359        /**
360         * The SI unit for absorbed dose, specific energy (imparted), kerma (standard name <code>Gy</code>). One gray is equal to the dose of one joule of
361         * energy absorbed per one kilogram of matter. It is named after the British physician L. H. Gray (1905-1965).
362         */
363        public static final Unit<RadiationDoseAbsorbed> GRAY = addUnit(new AlternateUnit<RadiationDoseAbsorbed>(JOULE.divide(KILOGRAM), "Gy"),
364                RadiationDoseAbsorbed.class);
365
366        /**
367         * The SI unit for dose equivalent (standard name <code>Sv</code>). One Sievert is equal is equal to the actual dose, in grays, multiplied by a
368         * "quality factor" which is larger for more dangerous forms of radiation. It is named after the Swedish physicist Rolf Sievert (1898-1966).
369         */
370        public static final Unit<RadiationDoseEffective> SIEVERT = addUnit(new AlternateUnit<RadiationDoseEffective>(JOULE.divide(KILOGRAM), "Sv"),
371                RadiationDoseEffective.class);
372
373        /**
374         * The SI unit for catalytic activity (standard name <code>kat</code>).
375         */
376        public static final Unit<CatalyticActivity> KATAL = addUnit(new AlternateUnit<CatalyticActivity>(MOLE.divide(SECOND), "kat"),
377                CatalyticActivity.class);
378
379        // ////////////////////////////
380        // SI DERIVED PRODUCT UNITS //
381        // ////////////////////////////
382
383        /**
384         * The SI unit for velocity quantities (standard name <code>m/s</code>).
385         */
386        public static final Unit<Speed> METRE_PER_SECOND = addUnit(new ProductUnit<>(METRE.divide(SECOND)), Speed.class);
387
388        /**
389         * The SI unit for acceleration quantities (standard name <code>m/s2</code> ).
390         */
391        public static final Unit<Acceleration> METRE_PER_SQUARE_SECOND = addUnit(new ProductUnit<>(METRE_PER_SECOND.divide(SECOND)), Acceleration.class);
392
393        /**
394         * The SI unit for area quantities (standard name <code>m2</code>).
395         */
396        public static final Unit<Area> SQUARE_METRE = addUnit(new ProductUnit<>(METRE.multiply(METRE)), Area.class);
397
398        /**
399         * The SI unit for volume quantities (standard name <code>m3</code>).
400         */
401        public static final Unit<Volume> CUBIC_METRE = addUnit(new ProductUnit<Volume>(SQUARE_METRE.multiply(METRE)), Volume.class);
402
403        /**
404         * A unit of velocity expressing the number of international {@link #KILOMETRE kilometres} per {@link #HOUR hour} (abbreviation <code>km/h</code>).
405         */
406        public static final Unit<Speed> KILOMETRE_PER_HOUR = addUnit(METRE_PER_SECOND.multiply(RationalNumber.of(5, 18))).asType(Speed.class);
407
408        // ///////////////////////////////////////////////////////////////
409        // Common Units outside the SI that are accepted for use with the SI. //
410        // ///////////////////////////////////////////////////////////////
411
412        /**
413         * A dimensionless unit accepted for use with SI units (standard name <code>%</code>).
414         */
415        public static final Unit<Dimensionless> PERCENT = addUnit(new TransformedUnit<>(ONE, MultiplyConverter.ofRational(1, 100)));
416
417        // ////////
418        // Time //
419        // ////////
420        /**
421         * A time unit accepted for use with SI units (standard name <code>min</code>).
422         */
423        public static final Unit<Time> MINUTE = addUnit(new TransformedUnit<>("min", SECOND, SECOND, MultiplyConverter.ofRational(60, 1)));
424
425        /**
426         * A time unit accepted for use with SI units (standard name <code>h</code> ).
427         */
428        public static final Unit<Time> HOUR = addUnit(new TransformedUnit<>("h", SECOND, SECOND, MultiplyConverter.ofRational(60 * 60, 1)));
429
430        /**
431         * A time unit accepted for use with SI units (standard name <code>d</code> ).
432         */
433        public static final Unit<Time> DAY = addUnit(new TransformedUnit<>("d", SECOND, SECOND, MultiplyConverter.ofRational(24 * 60 * 60, 1)));
434
435        /**
436         * A unit of duration equal to 7 {@link #DAY} (standard name <code>week</code>).
437         */
438        public static final Unit<Time> WEEK = addUnit(DAY.multiply(7));
439
440        /**
441         * A time unit accepted for use with SI units (standard name <code>y</code> ).
442         */
443        public static final Unit<Time> YEAR = addUnit(Units.DAY.multiply(365.2425));
444
445        /**
446         * A volume unit accepted for use with SI units (standard name <code>l</code>).
447         *
448         * @see <a href="https://en.wikipedia.org/wiki/Litre"> Wikipedia: Litre</a>
449         */
450        public static final Unit<Volume> LITRE = AbstractSystemOfUnits.Helper.addUnit(INSTANCE.units, new TransformedUnit<Volume>(CUBIC_METRE,
451                MultiplyConverter.ofRational(1, 1000)), "Litre", "l");
452
453        /**
454         * Returns the unique instance of this class.
455         *
456         * @return the Units instance.
457         */
458        public static SystemOfUnits getInstance() {
459                return INSTANCE;
460        }
461
462        static {
463                // have to add AbstractUnit.ONE as Dimensionless, too
464                addUnit(ONE);
465                INSTANCE.quantityToUnit.put(Dimensionless.class, ONE);
466        }
467
468        /**
469         * Adds a new unit not mapped to any specified quantity type.
470         *
471         * @param unit
472         *          the unit being added.
473         * @return <code>unit</code>.
474         */
475        private static <U extends Unit<?>> U addUnit(U unit) {
476                INSTANCE.units.add(unit);
477                return unit;
478        }
479
480        /**
481         * Adds a new unit and maps it to the specified quantity type.
482         *
483         * @param unit
484         *          the unit being added.
485         * @param type
486         *          the quantity type.
487         * @return <code>unit</code>.
488         */
489        private static <U extends AbstractUnit<?>> U addUnit(U unit, Class<? extends Quantity<?>> type) {
490                INSTANCE.units.add(unit);
491                INSTANCE.quantityToUnit.put(type, unit);
492                return unit;
493        }
494}