001/*
002 * Units of Measurement Systems
003 * Copyright (c) 2005-2017, Jean-Marie Dautelle, Werner Keil and others.
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-363, Units of Measurement nor the names of their contributors may be used to
017 *    endorse or promote products 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 systems.uom.ucum;
031
032import static tec.uom.se.unit.MetricPrefix.*;
033import static tec.uom.se.AbstractUnit.ONE;
034import si.uom.quantity.*;
035import systems.uom.quantity.*;
036import si.uom.SI;
037import tec.uom.se.*;
038import tec.uom.se.format.SimpleUnitFormat;
039import tec.uom.se.function.LogConverter;
040import tec.uom.se.function.MultiplyConverter;
041import tec.uom.se.function.PiMultiplierConverter;
042import tec.uom.se.unit.AlternateUnit;
043import tec.uom.se.unit.ProductUnit;
044import tec.uom.se.unit.TransformedUnit;
045import tec.uom.se.unit.Units;
046
047import javax.measure.Quantity;
048import javax.measure.Unit;
049import javax.measure.quantity.*;
050
051/**
052 * <p>
053 * This class contains {@link SI} and Non-SI units as defined in the
054 * <a href="http://unitsofmeasure.org/"> Unified Code for Units of Measure</a>.
055 * </p>
056 *
057 * <p>
058 * Compatibility with {@link SI} units has been given priority over strict
059 * adherence to the standard. We have attempted to note every place where the
060 * definitions in this class deviate from the UCUM standard, but such notes are
061 * likely to be incomplete.
062 * </p>
063 *
064 * @author <a href="mailto:eric-r@northwestern.edu">Eric Russell</a>
065 * @author <a href="mailto:units@catmedia.us">Werner Keil</a>
066 * @see <a href="http://www.unitsofmeasure.org">UCUM</a>
067 * @version 0.8.2, $Date: 2017-09-02 $
068 */
069public final class UCUM extends AbstractSystemOfUnits {
070
071    /**
072     * The singleton instance.
073     */
074    private static final UCUM INSTANCE = new UCUM();
075
076    /**
077     * Default constructor (prevents this class from being instantiated).
078     */
079    private UCUM() {
080    }
081
082    /**
083     * Returns the singleton instance of this class.
084     *
085     * @return the UCUM system instance.
086     */
087    public static UCUM getInstance() {
088        return INSTANCE;
089    }
090
091    //////////////////////////////
092    // BASE UNITS: UCUM 4.2 §28 //
093    //////////////////////////////
094    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
095    public static final Unit<Length> METER = addUnit(Units.METRE);
096    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
097    public static final Unit<Time> SECOND = addUnit(Units.SECOND);
098    /**
099     * We deviate slightly from the standard here, to maintain compatibility
100     * with the existing SI units. In UCUM, the gram is the base unit of mass,
101     * rather than the kilogram. This doesn't have much effect on the units
102     * themselves, but it does make formatting the units a challenge.
103     */
104    public static final Unit<Mass> GRAM = addUnit(Units.GRAM);
105    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
106    public static final Unit<Angle> RADIAN = addUnit(Units.RADIAN);
107    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
108    public static final Unit<Temperature> KELVIN = addUnit(Units.KELVIN);
109    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
110    public static final Unit<ElectricCharge> COULOMB = addUnit(Units.COULOMB);
111    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
112    public static final Unit<LuminousIntensity> CANDELA = addUnit(Units.CANDELA);
113
114    ///////////////////////////////////////////////
115    // DIMENSIONLESS DERIVED UNITS: UCUM 4.3 §29 //
116    ///////////////////////////////////////////////
117    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
118    public static final Unit<Dimensionless> TRILLIONS = addUnit(ONE.multiply(1000000000000L));
119    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
120    public static final Unit<Dimensionless> BILLIONS = addUnit(ONE.multiply(1000000000));
121    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
122    public static final Unit<Dimensionless> MILLIONS = addUnit(ONE.multiply(1000000));
123    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
124    public static final Unit<Dimensionless> THOUSANDS = addUnit(ONE.multiply(1000));
125    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
126    public static final Unit<Dimensionless> HUNDREDS = addUnit(ONE.multiply(100));
127    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
128    public static final Unit<Dimensionless> PI = addUnit(ONE.transform(new PiMultiplierConverter()));
129    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
130    public static final Unit<Dimensionless> PERCENT = addUnit(ONE.divide(100));
131    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
132    public static final Unit<Dimensionless> PER_THOUSAND = addUnit(ONE.divide(1000));
133    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
134    public static final Unit<Dimensionless> PER_MILLION = addUnit(ONE.divide(1000000));
135    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
136    public static final Unit<Dimensionless> PER_BILLION = addUnit(ONE.divide(1000000000));
137    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
138    public static final Unit<Dimensionless> PER_TRILLION = addUnit(ONE.divide(1000000000000L));
139    ////////////////////////////
140    // SI UNITS: UCUM 4.3 §30 //
141    ////////////////////////////
142    /**
143     * We deviate slightly from the standard here, to maintain compatibility
144     * with the existing SI units. In UCUM, the mole is no longer a base unit,
145     * but is defined as <code>Unit.ONE.multiply(6.0221367E23)</code>.
146     */
147    public static final Unit<AmountOfSubstance> MOLE = addUnit(Units.MOLE);
148    /**
149     * We deviate slightly from the standard here, to maintain compatibility
150     * with the existing SI units. In UCUM, the steradian is defined as
151     * <code>RADIAN.pow(2)</code>.
152     */
153    public static final Unit<SolidAngle> STERADIAN = addUnit(Units.STERADIAN);
154    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
155    public static final Unit<Frequency> HERTZ = addUnit(Units.HERTZ);
156    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
157    public static final Unit<Force> NEWTON = addUnit(Units.NEWTON);
158    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
159    public static final Unit<Pressure> PASCAL = addUnit(Units.PASCAL);
160    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
161    public static final Unit<Energy> JOULE = addUnit(Units.JOULE);
162    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
163    public static final Unit<Power> WATT = addUnit(Units.WATT);
164    /**
165     * We deviate slightly from the standard here, to maintain compatibility
166     * with the existing SI units. In UCUM, the ampere is defined as
167     * <code>COULOMB.divide(SECOND)</code>.
168     */
169    public static final Unit<ElectricCurrent> AMPERE = addUnit(Units.AMPERE);
170    // public static final Unit<MagnetomotiveForce> AMPERE_TURN =
171    // addUnit(Units.AMPERE_TURN);
172    /**
173     * We deviate slightly from the standard here, to maintain compatibility
174     * with the existing SI units. In UCUM, the volt is defined as
175     * <code>JOULE.divide(COULOMB)</code>.
176     */
177    public static final Unit<ElectricPotential> VOLT = addUnit(Units.VOLT);
178    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
179    public static final Unit<ElectricCapacitance> FARAD = addUnit(Units.FARAD);
180    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
181    public static final Unit<ElectricResistance> OHM = addUnit(Units.OHM);
182    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
183    public static final Unit<ElectricConductance> SIEMENS = addUnit(Units.SIEMENS);
184    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
185    public static final Unit<MagneticFlux> WEBER = addUnit(Units.WEBER);
186    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
187    public static final Unit<Temperature> CELSIUS = addUnit(Units.CELSIUS);
188    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
189    public static final Unit<MagneticFluxDensity> TESLA = addUnit(Units.TESLA);
190    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
191    public static final Unit<ElectricInductance> HENRY = addUnit(Units.HENRY);
192    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
193    public static final Unit<LuminousFlux> LUMEN = addUnit(Units.LUMEN);
194    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
195    public static final Unit<Illuminance> LUX = addUnit(Units.LUX);
196    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
197    public static final Unit<Radioactivity> BECQUEREL = addUnit(Units.BECQUEREL);
198    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
199    public static final Unit<RadiationDoseAbsorbed> GRAY = addUnit(Units.GRAY);
200    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
201    public static final Unit<RadiationDoseEffective> SIEVERT = addUnit(Units.SIEVERT);
202
203    ///////////////////////////////////////////////////////////////////////
204    // OTHER UNITS FROM ISO 1000, ISO 2955, AND ANSI X3.50: UCUM 4.3 §31 //
205    ///////////////////////////////////////////////////////////////////////
206    // The order of GON and DEGREE has been inverted because GON is defined in
207    // terms of DEGREE
208    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
209    public static final Unit<Angle> DEGREE = addUnit(new ProductUnit<Angle>(PI.multiply(RADIAN.divide(180))));
210    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
211    public static final Unit<Angle> GRADE = addUnit(DEGREE.multiply(0.9));
212    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
213    public static final Unit<Angle> GON = GRADE;
214    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
215    public static final Unit<Angle> MINUTE_ANGLE = addUnit(DEGREE.divide(60));
216    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
217    public static final Unit<Angle> SECOND_ANGLE = addUnit(MINUTE_ANGLE.divide(60));
218    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
219    public static final Unit<Volume> LITER = addUnit(Units.LITRE,  "liter", "L", true);
220    /**
221     * As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. Liter has
222     * <b>two</b> definitions.
223     * 
224     * @see <a href="http://unitsofmeasure.org/ucum.html#iso1000">UCUM Table
225     *      5</a>
226     */
227    public static final Unit<Volume> LITER_DM3 = addUnit(DECI(Units.METRE).pow(3).asType(Volume.class), "liter", "l", true);
228    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
229    public static final Unit<Area> ARE = addUnit(Units.SQUARE_METRE.multiply(100));
230    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
231    public static final Unit<Time> MINUTE = addUnit(Units.MINUTE);
232    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
233    public static final Unit<Time> HOUR = addUnit(Units.HOUR);
234    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
235    public static final Unit<Time> DAY = addUnit(Units.DAY);
236    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
237    public static final Unit<Time> YEAR_TROPICAL = addUnit(Units.DAY.multiply(365.24219));
238    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
239    public static final Unit<Time> YEAR_JULIAN = addUnit(Units.DAY.multiply(365.25));
240    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
241    public static final Unit<Time> YEAR_GREGORIAN = addUnit(Units.DAY.multiply(365.2425));
242    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
243    public static final Unit<Time> YEAR = addUnit(Units.DAY.multiply(365.25));
244    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
245    public static final Unit<Time> WEEK = addUnit(Units.DAY.multiply(7));
246    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
247    public static final Unit<Time> MONTH_SYNODAL = addUnit(Units.DAY.multiply(29.53059));
248    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
249    public static final Unit<Time> MONTH_JULIAN = addUnit(YEAR_JULIAN.divide(12));
250    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
251    public static final Unit<Time> MONTH_GREGORIAN = addUnit(YEAR_GREGORIAN.divide(12));
252    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
253    public static final Unit<Time> MONTH = addUnit(YEAR_JULIAN.divide(12));
254    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
255    public static final Unit<Mass> TONNE = addUnit(Units.KILOGRAM.multiply(1000));
256    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
257    public static final Unit<Pressure> BAR = addUnit(Units.PASCAL.multiply(100000));
258    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
259    public static final Unit<Mass> ATOMIC_MASS_UNIT = addUnit(SI.UNIFIED_ATOMIC_MASS);
260    // public static final Unit<Mass> ATOMIC_MASS_UNIT = addUnit(
261    // new AlternateUnit<Mass>(Units.UNIFIED_ATOMIC_MASS,
262    // Units.UNIFIED_ATOMIC_MASS.getSymbol()), Mass.class);
263    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
264    public static final Unit<Energy> ELECTRON_VOLT = addUnit(SI.ELECTRON_VOLT);
265    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
266    public static final Unit<Length> ASTRONOMIC_UNIT = addUnit(SI.ASTRONOMICAL_UNIT);
267    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
268    public static final Unit<Length> PARSEC = addUnit(Units.METRE.multiply(3.085678E16));
269
270    /////////////////////////////////
271    // NATURAL UNITS: UCUM 4.3 §32 //
272    /////////////////////////////////
273    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
274    public static final Unit<Speed> VELOCITY_OF_LIGHT = addUnit(Units.METRE_PER_SECOND.multiply(299792458));
275    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
276    public static final Unit<Action> PLANCK = addUnit(SI.JOULE_SECOND.multiply(6.6260755E-34));
277    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
278    public static final Unit<?> BOLTZMAN = addUnit(JOULE.divide(KELVIN).multiply(1.380658E-23));
279    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
280    public static final Unit<ElectricPermittivity> PERMITTIVITY_OF_VACUUM = addUnit(
281            SI.FARAD_PER_METRE.multiply(8.854187817E-12));
282    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
283    public static final Unit<MagneticPermeability> PERMEABILITY_OF_VACUUM = addUnit(
284            new ProductUnit<MagneticPermeability>(SI.NEWTON_PER_SQUARE_AMPERE.multiply(PI.multiply(4).divide(1E7))),
285            MagneticPermeability.class);
286    // public static final Unit<MagneticPermeability> PERMEABILITY_OF_VACUUM =
287    // addUnit(
288    // new ProductUnit<MagneticPermeability>(Units.NEWTONS_PER_SQUARE_AMPERE
289    // .multiply(PI).multiply(4).divide(1E7)),
290    // MagneticPermeability.class);
291    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
292    public static final Unit<ElectricCharge> ELEMENTARY_CHARGE = addUnit(
293            Units.COULOMB.transform(((AbstractUnit<Energy>) SI.ELECTRON_VOLT).getSystemConverter()));
294    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
295    public static final Unit<Mass> ELECTRON_MASS = addUnit(GRAM.multiply(9.1093897E-28));
296    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
297    public static final Unit<Mass> PROTON_MASS = addUnit(GRAM.multiply(1.6726231E-24));
298    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
299    public static final Unit<?> NEWTON_CONSTANT_OF_GRAVITY = addUnit(
300            METER.pow(3).multiply(Units.KILOGRAM.pow(-1)).multiply(SECOND.pow(-2)).multiply(6.67259E-11));
301    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
302    public static final Unit<Acceleration> ACCELERATION_OF_FREEFALL = addUnit(
303            Units.METRE_PER_SQUARE_SECOND.multiply(9.80665));
304    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
305    public static final Unit<Pressure> ATMOSPHERE = addUnit(Units.PASCAL.multiply(101325));
306    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
307    public static final Unit<Length> LIGHT_YEAR = addUnit(
308            new ProductUnit<Length>(VELOCITY_OF_LIGHT.multiply(YEAR_JULIAN)));
309    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
310    public static final Unit<Force> GRAM_FORCE = addUnit(
311            new ProductUnit<Force>(GRAM.multiply(ACCELERATION_OF_FREEFALL)));
312    // POUND_FORCE contains a forward reference to avoirdupois pound weight, so
313    // it has been moved after section §39 below
314
315    /////////////////////////////
316    // CGS UNITS: UCUM 4.3 §33 //
317    /////////////////////////////
318    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
319    public static final Unit<WaveNumber> KAYSER = addUnit(SI.RECIPROCAL_METRE.divide(100));
320    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
321    public static final Unit<Acceleration> GAL = addUnit(
322            new ProductUnit<Acceleration>(CENTI(METER).divide(SECOND.pow(2))));
323    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
324    public static final Unit<Force> DYNE = addUnit(
325            new ProductUnit<Force>(Units.GRAM.multiply(CENTI(Units.METRE).divide(Units.SECOND.pow(2)))));
326    // public static final Unit<Force> DYNE = addUnit(new ProductUnit<Force>(
327    // Units.GRAM.multiply(new
328    // ProductUnit(CENTI(Units.METRE)).divide(Units.SECOND
329    // .pow(2)))));
330    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
331    public static final Unit<Energy> ERG = addUnit(new ProductUnit<Energy>(DYNE.multiply(CENTI(Units.METRE))));
332    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
333    public static final Unit<DynamicViscosity> POISE = addUnit(
334            new ProductUnit<DynamicViscosity>(DYNE.multiply(SECOND).divide(CENTI(Units.METRE).pow(2))));
335    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
336    public static final Unit<ElectricCurrent> BIOT = addUnit(AMPERE.multiply(10));
337    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
338    public static final Unit<KinematicViscosity> STOKES = addUnit(
339            new ProductUnit<KinematicViscosity>(CENTI(Units.METRE).pow(2).divide(Units.SECOND)));
340    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
341    public static final Unit<MagneticFlux> MAXWELL = addUnit(Units.WEBER.divide(1E8));
342    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
343    public static final Unit<MagneticFluxDensity> GAUSS = addUnit(Units.TESLA.divide(1E4));
344    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
345    public static final Unit<MagneticFieldStrength> OERSTED = addUnit(
346            new ProductUnit<MagneticFieldStrength>(SI.AMPERE_PER_METRE.multiply(250).divide(PI)));
347    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
348    public static final Unit<MagnetomotiveForce> GILBERT = addUnit(
349            new ProductUnit<MagnetomotiveForce>(OERSTED.multiply(CENTI(Units.METRE))));
350    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
351    public static final Unit<Luminance> STILB = addUnit(
352            new ProductUnit<Luminance>(CANDELA.divide(CENTI(METER).pow(2))));
353    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
354    public static final Unit<Luminance> LAMBERT = addUnit(new ProductUnit<Luminance>(STILB.divide(PI)));
355    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
356    public static final Unit<Illuminance> PHOT = addUnit(LUX.divide(1E4));
357    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
358    public static final Unit<Radioactivity> CURIE = addUnit(Units.BECQUEREL.multiply(3.7E10));
359    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
360    public static final Unit<IonizingRadiation> ROENTGEN = addUnit(SI.COULOMB_PER_KILOGRAM.multiply(2.58E-4));
361    // add later when JMQ issue fixed
362    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
363    public static final Unit<RadiationDoseAbsorbed> RAD = addUnit(
364            new ProductUnit<RadiationDoseAbsorbed>(ERG.divide(Units.GRAM.multiply(100))));
365    // public static final Unit<RadiationDoseAbsorbed> RAD = addUnit(new
366    // ProductUnit<RadiationDoseAbsorbed>(
367    // ERG.divide(Units.GRAM).multiply(100)));
368    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
369    public static final Unit<RadiationDoseEffective> REM = addUnit(
370            new ProductUnit<RadiationDoseEffective>(ERG.divide(Units.GRAM.multiply(100))));
371    // public static final Unit<RadiationDoseEffective> REM = addUnit(new
372    // AlternateUnit<RadiationDoseEffective>(
373    // RAD, RAD.getSymbol())); // TODO are symbols for RAD and REM same?
374    /////////////////////////////////////////////////
375    // INTERNATIONAL CUSTOMARY UNITS: UCUM 4.4 §34 //
376    /////////////////////////////////////////////////
377    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
378    public static final Unit<Length> INCH_INTERNATIONAL = addUnit(CENTI(METER).multiply(254).divide(100));
379    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
380    public static final Unit<Length> FOOT_INTERNATIONAL = addUnit(INCH_INTERNATIONAL.multiply(12));
381    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
382    public static final Unit<Length> YARD_INTERNATIONAL = addUnit(FOOT_INTERNATIONAL.multiply(3));
383    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
384    public static final Unit<Length> MILE_INTERNATIONAL = addUnit(FOOT_INTERNATIONAL.multiply(5280));
385    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
386    public static final Unit<Length> FATHOM_INTERNATIONAL = addUnit(FOOT_INTERNATIONAL.multiply(6));
387    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
388    public static final Unit<Length> NAUTICAL_MILE_INTERNATIONAL = addUnit(METER.multiply(1852));
389    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
390    public static final Unit<Speed> KNOT_INTERNATIONAL = addUnit(
391            new ProductUnit<Speed>(NAUTICAL_MILE_INTERNATIONAL.divide(HOUR)));
392    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
393    public static final Unit<Area> SQUARE_INCH_INTERNATIONAL = addUnit(
394            new ProductUnit<Area>(INCH_INTERNATIONAL.pow(2)));
395    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
396    public static final Unit<Area> SQUARE_FOOT_INTERNATIONAL = addUnit(
397            new ProductUnit<Area>(FOOT_INTERNATIONAL.pow(2)));
398    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
399    public static final Unit<Area> SQUARE_YARD_INTERNATIONAL = addUnit(
400            new ProductUnit<Area>(YARD_INTERNATIONAL.pow(2)));
401    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
402    public static final Unit<Volume> CUBIC_INCH_INTERNATIONAL = addUnit(
403            new ProductUnit<Volume>(INCH_INTERNATIONAL.pow(3)));
404    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
405    public static final Unit<Volume> CUBIC_FOOT_INTERNATIONAL = addUnit(
406            new ProductUnit<Volume>(FOOT_INTERNATIONAL.pow(3)));
407    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
408    public static final Unit<Volume> CUBIC_YARD_INTERNATIONAL = addUnit(
409            new ProductUnit<Volume>(YARD_INTERNATIONAL.pow(3)));
410    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
411    public static final Unit<Volume> BOARD_FOOT_INTERNATIONAL = addUnit(CUBIC_INCH_INTERNATIONAL.multiply(144));
412    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
413    public static final Unit<Volume> CORD_INTERNATIONAL = addUnit(CUBIC_FOOT_INTERNATIONAL.multiply(128));
414    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
415    public static final Unit<Length> MIL_INTERNATIONAL = addUnit(INCH_INTERNATIONAL.divide(1000));
416    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
417    public static final Unit<Area> CIRCULAR_MIL_INTERNATIONAL = addUnit(
418            new ProductUnit<Area>(MIL_INTERNATIONAL.pow(2).multiply(PI.divide(4))));
419    // public static final Unit<Area> CIRCULAR_MIL_INTERNATIONAL = addUnit(new
420    // ProductUnit<Area>(
421    // MIL_INTERNATIONAL.pow(2).multiply(PI).divide(4)));
422    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
423    public static final Unit<Length> HAND_INTERNATIONAL = addUnit(INCH_INTERNATIONAL.multiply(4));
424    //////////////////////////////////////////
425    // US SURVEY LENGTH UNITS: UCUM 4.4 §35 //
426    //////////////////////////////////////////
427    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
428    public static final Unit<Length> FOOT_US_SURVEY = addUnit(METER.multiply(1200).divide(3937));
429    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
430    public static final Unit<Length> YARD_US_SURVEY = addUnit(FOOT_US_SURVEY.multiply(3));
431    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
432    public static final Unit<Length> INCH_US_SURVEY = addUnit(FOOT_US_SURVEY.divide(12));
433    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
434    public static final Unit<Length> ROD_US_SURVEY = addUnit(FOOT_US_SURVEY.multiply(33).divide(2));
435    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
436    public static final Unit<Length> CHAIN_US_SURVEY = addUnit(ROD_US_SURVEY.multiply(4));
437    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
438    public static final Unit<Length> LINK_US_SURVEY = addUnit(CHAIN_US_SURVEY.divide(100));
439    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
440    public static final Unit<Length> RAMDEN_CHAIN_US_SURVEY = addUnit(FOOT_US_SURVEY.multiply(100));
441    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
442    public static final Unit<Length> RAMDEN_LINK_US_SURVEY = addUnit(CHAIN_US_SURVEY.divide(100));
443    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
444    public static final Unit<Length> FATHOM_US_SURVEY = addUnit(FOOT_US_SURVEY.multiply(6));
445    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
446    public static final Unit<Length> FURLONG_US_SURVEY = addUnit(ROD_US_SURVEY.multiply(40));
447    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
448    public static final Unit<Length> MILE_US_SURVEY = addUnit(FURLONG_US_SURVEY.multiply(8));
449    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
450    public static final Unit<Area> ACRE_US_SURVEY = addUnit(new ProductUnit<Area>(ROD_US_SURVEY.pow(2)).multiply(160));
451    // public static final Unit<Area> ACRE_US_SURVEY = addUnit(new
452    // ProductUnit<Area>(
453    // ROD_US_SURVEY.pow(2).multiply(160)));
454    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
455    public static final Unit<Area> SQUARE_ROD_US_SURVEY = addUnit(new ProductUnit<Area>(ROD_US_SURVEY.pow(2)));
456    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
457    public static final Unit<Area> SQUARE_MILE_US_SURVEY = addUnit(new ProductUnit<Area>(MILE_US_SURVEY.pow(2)));
458    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
459    public static final Unit<Area> SECTION_US_SURVEY = addUnit(new ProductUnit<Area>(MILE_US_SURVEY.pow(2)));
460    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
461    public static final Unit<Area> TOWNSHP_US_SURVEY = addUnit(SECTION_US_SURVEY.multiply(36));
462    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
463    public static final Unit<Length> MIL_US_SURVEY = addUnit(INCH_US_SURVEY.divide(1000));
464    /////////////////////////////////////////////////
465    // BRITISH IMPERIAL LENGTH UNITS: UCUM 4.4 §36 //
466    /////////////////////////////////////////////////
467    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
468    public static final Unit<Length> INCH_BRITISH = addUnit(CENTI(METER).multiply(2539998).divide(1000000));
469    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
470    public static final Unit<Length> FOOT_BRITISH = addUnit(INCH_BRITISH.multiply(12));
471    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
472    public static final Unit<Length> ROD_BRITISH = addUnit(FOOT_BRITISH.multiply(33).divide(2));
473    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
474    public static final Unit<Length> CHAIN_BRITISH = addUnit(ROD_BRITISH.multiply(4));
475    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
476    public static final Unit<Length> LINK_BRITISH = addUnit(CHAIN_BRITISH.divide(100));
477    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
478    public static final Unit<Length> FATHOM_BRITISH = addUnit(FOOT_BRITISH.multiply(6));
479    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
480    public static final Unit<Length> PACE_BRITISH = addUnit(FOOT_BRITISH.multiply(5).divide(2));
481    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
482    public static final Unit<Length> YARD_BRITISH = addUnit(FOOT_BRITISH.multiply(3));
483    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
484    public static final Unit<Length> MILE_BRITISH = addUnit(FOOT_BRITISH.multiply(5280));
485    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
486    public static final Unit<Length> NAUTICAL_MILE_BRITISH = addUnit(FOOT_BRITISH.multiply(6080));
487    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
488    public static final Unit<Speed> KNOT_BRITISH = addUnit(new ProductUnit<Speed>(NAUTICAL_MILE_BRITISH.divide(HOUR)));
489    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
490    public static final Unit<Area> ACRE_BRITISH = addUnit(new ProductUnit<Area>(YARD_BRITISH.pow(2)).multiply(4840));
491    // public static final Unit<Area> ACRE_BRITISH = addUnit(new
492    // ProductUnit<Area>(
493    // YARD_BRITISH.pow(2).multiply(4840)));
494    ///////////////////////////////////
495    // US VOLUME UNITS: UCUM 4.4 §37 //
496    ///////////////////////////////////
497    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
498    public static final Unit<Volume> GALLON_US = addUnit(CUBIC_INCH_INTERNATIONAL.multiply(231));
499    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
500    public static final Unit<Volume> BARREL_US = addUnit(GALLON_US.multiply(42));
501    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
502    public static final Unit<Volume> QUART_US = addUnit(GALLON_US.divide(4));
503    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
504    public static final Unit<Volume> PINT_US = addUnit(QUART_US.divide(2));
505    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
506    public static final Unit<Volume> GILL_US = addUnit(PINT_US.divide(4));
507    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
508    public static final Unit<Volume> FLUID_OUNCE_US = addUnit(GILL_US.divide(4));
509    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
510    public static final Unit<Volume> FLUID_DRAM_US = addUnit(FLUID_OUNCE_US.divide(8));
511    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
512    public static final Unit<Volume> MINIM_US = addUnit(FLUID_DRAM_US.divide(60));
513    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
514    public static final Unit<Volume> CORD_US = addUnit(CUBIC_FOOT_INTERNATIONAL.multiply(128));
515    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
516    public static final Unit<Volume> BUSHEL_US = addUnit(CUBIC_INCH_INTERNATIONAL.multiply(215042).divide(100));
517    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
518    public static final Unit<Volume> GALLON_WINCHESTER = addUnit(BUSHEL_US.divide(8));
519    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
520    public static final Unit<Volume> PECK_US = addUnit(BUSHEL_US.divide(4));
521    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
522    public static final Unit<Volume> DRY_QUART_US = addUnit(PECK_US.divide(8));
523    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
524    public static final Unit<Volume> DRY_PINT_US = addUnit(DRY_QUART_US.divide(2));
525    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
526    public static final Unit<Volume> TABLESPOON_US = addUnit(FLUID_OUNCE_US.divide(2));
527    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
528    public static final Unit<Volume> TEASPOON_US = addUnit(TABLESPOON_US.divide(3));
529    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
530    public static final Unit<Volume> CUP_US = addUnit(TABLESPOON_US.multiply(16));
531    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
532    public static final Unit<Volume> METRIC_FLUID_OUNCE_US = addUnit(MILLI(LITER).multiply(30));
533    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
534    public static final Unit<Volume> METRIC_CUP_US = addUnit(MILLI(LITER).multiply(240));
535    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
536    public static final Unit<Volume> METRIC_TEASPOON_CUP_US = addUnit(MILLI(LITER).multiply(5));
537    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
538    public static final Unit<Volume> METRIC_TABLESPOON_CUP_US = addUnit(MILLI(LITER).multiply(15));
539    /////////////////////////////////////////////////
540    // BRITISH IMPERIAL VOLUME UNITS: UCUM 4.4 §38 //
541    /////////////////////////////////////////////////
542    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
543    public static final Unit<Volume> GALLON_BRITISH = addUnit(LITER.multiply(454609).divide(100000));
544    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
545    public static final Unit<Volume> PECK_BRITISH = addUnit(GALLON_BRITISH.multiply(2));
546    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
547    public static final Unit<Volume> BUSHEL_BRITISH = addUnit(PECK_BRITISH.multiply(4));
548    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
549    public static final Unit<Volume> QUART_BRITISH = addUnit(GALLON_BRITISH.divide(4));
550    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
551    public static final Unit<Volume> PINT_BRITISH = addUnit(QUART_BRITISH.divide(2));
552    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
553    public static final Unit<Volume> GILL_BRITISH = addUnit(PINT_BRITISH.divide(4));
554    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
555    public static final Unit<Volume> FLUID_OUNCE_BRITISH = addUnit(GILL_BRITISH.divide(5));
556    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
557    public static final Unit<Volume> FLUID_DRAM_BRITISH = addUnit(FLUID_OUNCE_BRITISH.divide(8));
558    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
559    public static final Unit<Volume> MINIM_BRITISH = addUnit(FLUID_DRAM_BRITISH.divide(60));
560    ////////////////////////////////////////////
561    // AVOIRDUPOIS WIEGHT UNITS: UCUM 4.4 §39 //
562    ////////////////////////////////////////////
563    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
564    public static final Unit<Mass> GRAIN = addUnit(MILLI(GRAM).multiply(6479891).divide(100000));
565    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
566    public static final Unit<Mass> POUND = addUnit(GRAIN.multiply(7000));
567    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
568    public static final Unit<Mass> OUNCE = addUnit(POUND.divide(16));
569    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
570    public static final Unit<Mass> DRAM = addUnit(OUNCE.divide(16));
571    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
572    public static final Unit<Mass> SHORT_HUNDREDWEIGHT = addUnit(POUND.multiply(100));
573    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
574    public static final Unit<Mass> LONG_HUNDREDWEIGHT = addUnit(POUND.multiply(112));
575    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
576    public static final Unit<Mass> SHORT_TON = addUnit(SHORT_HUNDREDWEIGHT.multiply(20));
577    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
578    public static final Unit<Mass> LONG_TON = addUnit(LONG_HUNDREDWEIGHT.multiply(20));
579    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
580    public static final Unit<Mass> STONE = addUnit(POUND.multiply(14));
581    // CONTINUED FROM SECTION §32
582    // contains a forward reference to POUND, so we had to move it here, below
583    // section §39
584    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
585    // public static final Unit<Force> POUND_FORCE = addUnit(new
586    // ProductUnit<Force>(
587    // POUND.multiply(ACCELERATION_OF_FREEFALL)));
588    public static final Unit<Force> POUND_FORCE = addUnit(
589            POUND.multiply(ACCELERATION_OF_FREEFALL).asType(Force.class));
590
591    // public static final Unit<InformationRate> POUND_FORCE2 =
592    // addUnit(POUND.multiply(ACCELERATION_OF_FREEFALL).asType(InformationRate.class));
593
594    /////////////////////////////////////
595    // TROY WEIGHT UNITS: UCUM 4.4 §40 //
596    /////////////////////////////////////
597    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
598    public static final Unit<Mass> PENNYWEIGHT_TROY = addUnit(GRAIN.multiply(24));
599    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
600    public static final Unit<Mass> OUNCE_TROY = addUnit(PENNYWEIGHT_TROY.multiply(20));
601    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
602    public static final Unit<Mass> POUND_TROY = addUnit(OUNCE_TROY.multiply(12));
603    /////////////////////////////////////////////
604    // APOTECARIES' WEIGHT UNITS: UCUM 4.4 §41 //
605    /////////////////////////////////////////////
606    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
607    public static final Unit<Mass> SCRUPLE_APOTHECARY = addUnit(GRAIN.multiply(20));
608    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
609    public static final Unit<Mass> DRAM_APOTHECARY = addUnit(SCRUPLE_APOTHECARY.multiply(3));
610    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
611    public static final Unit<Mass> OUNCE_APOTHECARY = addUnit(DRAM_APOTHECARY.multiply(8));
612    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
613    public static final Unit<Mass> POUND_APOTHECARY = addUnit(OUNCE_APOTHECARY.multiply(12));
614    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
615    public static final Unit<Mass> METRIC_OUNCE = addUnit(GRAM.multiply(28));
616
617    /////////////////////////////////////////////
618    // TYPESETTER'S LENGTH UNITS: UCUM 4.4 §42 //
619    /////////////////////////////////////////////
620    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
621    public static final Unit<Length> LINE = addUnit(INCH_INTERNATIONAL.divide(12));
622    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
623    public static final Unit<Length> POINT = addUnit(LINE.divide(6));
624    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
625    public static final Unit<Length> PICA = addUnit(POINT.multiply(12));
626    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
627    public static final Unit<Length> POINT_PRINTER = addUnit(INCH_INTERNATIONAL.multiply(13837).divide(1000000));
628    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
629    public static final Unit<Length> PICA_PRINTER = addUnit(POINT_PRINTER.multiply(12));
630    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
631    public static final Unit<Length> PIED = addUnit(CENTI(METER).multiply(3248).divide(100));
632    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
633    public static final Unit<Length> POUCE = addUnit(PIED.divide(12));
634    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
635    public static final Unit<Length> LIGNE = addUnit(POUCE.divide(12));
636    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
637    public static final Unit<Length> DIDOT = addUnit(LIGNE.divide(6));
638    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
639    public static final Unit<Length> CICERO = addUnit(DIDOT.multiply(12));
640    //////////////////////////////////////
641    // OTHER LEGACY UNITS: UCUM 4.5 §43 //
642    //////////////////////////////////////
643    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
644    public static final Unit<Temperature> RANKINE = addUnit(KELVIN.divide(9).multiply(5));
645    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
646    public static final Unit<Temperature> FAHRENHEIT = addUnit(RANKINE.shift(459.67));
647    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
648    public static final Unit<Temperature> REAUMUR = addUnit((KELVIN.multiply(4).divide(5)).shift(218.52));
649    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
650    public static final Unit<Energy> CALORIE_AT_15C = addUnit(JOULE.multiply(41858).divide(10000));
651    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
652    public static final Unit<Energy> CALORIE_AT_20C = addUnit(JOULE.multiply(41819).divide(10000));
653    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
654    public static final Unit<Energy> CALORIE_MEAN = addUnit(JOULE.multiply(419002).divide(100000));
655    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
656    public static final Unit<Energy> CALORIE_INTERNATIONAL_TABLE = addUnit(JOULE.multiply(41868).divide(10000));
657    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
658    public static final Unit<Energy> CALORIE_THERMOCHEMICAL = addUnit(JOULE.multiply(4184).divide(1000));
659    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
660    public static final Unit<Energy> CALORIE = addUnit(CALORIE_THERMOCHEMICAL);
661    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
662    public static final Unit<Energy> CALORIE_FOOD = addUnit(KILO(CALORIE_THERMOCHEMICAL));
663
664    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
665    public static final Unit<Energy> BTU_AT_39F = addUnit(KILO(JOULE).multiply(105967).divide(100000));
666    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
667    public static final Unit<Energy> BTU_AT_59F = addUnit(KILO(JOULE).multiply(105480).divide(100000));
668    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
669    public static final Unit<Energy> BTU_AT_60F = addUnit(KILO(JOULE).multiply(105468).divide(100000));
670    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
671    public static final Unit<Energy> BTU_MEAN = addUnit(KILO(JOULE).multiply(105587).divide(100000));
672    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
673    public static final Unit<Energy> BTU_INTERNATIONAL_TABLE = addUnit(
674            KILO(JOULE).multiply(105505585262L).divide(100000000000L));
675    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
676    public static final Unit<Energy> BTU_THERMOCHEMICAL = addUnit(KILO(JOULE).multiply(105435).divide(100000));
677    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
678    public static final Unit<Energy> BTU = addUnit(BTU_THERMOCHEMICAL);
679    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
680    public static final Unit<Power> HORSEPOWER = addUnit(
681            new ProductUnit<Power>(FOOT_INTERNATIONAL.multiply(POUND_FORCE).divide(SECOND)));
682
683    ////////////////////////////////////////////
684    // CLINICAL MEDICINE UNITS: UCUM 4.5 §44 //
685    ///////////////////////////////////////////
686    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
687    public static final Unit<Pressure> METER_OF_WATER_COLUMN = addUnit(KILO(PASCAL).multiply(980665).divide(100000));
688    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
689    public static final Unit<Pressure> METER_OF_MERCURY_COLUMN = addUnit(KILO(PASCAL).multiply(1333220).divide(10000));
690    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
691    public static final Unit<Pressure> INCH_OF_WATER_COLUMN = addUnit(
692            new ProductUnit<Pressure>(METER_OF_WATER_COLUMN.multiply(INCH_INTERNATIONAL).divide(METER)));
693    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
694    public static final Unit<Pressure> INCH_OF_MERCURY_COLUMN = addUnit(
695            new ProductUnit<Pressure>(METER_OF_MERCURY_COLUMN.multiply(INCH_INTERNATIONAL).divide(METER)));
696
697    public static final Unit<Drag> PERIPHERAL_VASCULAR_RESISTANCE = addUnit(
698            MILLI(METER_OF_MERCURY_COLUMN).multiply(SECOND).divide(MILLI(LITER)).asType(Drag.class));
699    public static final Unit<Drag> WOOD = addUnit(MILLI(METER_OF_MERCURY_COLUMN).multiply(MINUTE).divide(LITER).asType(Drag.class));
700    // public static final Unit DIOPTER = addUnit(ONE.divide(METER));
701    // public static final Unit PRISM_DIOPTER =
702    // addUnit(ONE.multiply(100).multiply(Math.tan(1)));
703    // public static final Unit PERCENT_OF_SLOPE =
704    // addUnit(ONE.multiply(100).multiply(Math.tan(1)));
705    // public static final Unit MESH = addUnit(ONE.divide(INCH_INTERNATIONAL));
706    // public static final Unit CHARRIERE = addUnit(MILLI(METER).divide(3));
707
708    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
709    public static final Unit<Volume> DROP = addUnit(MILLI(LITER).divide(20));
710
711    // public static final Unit HOUNSFIELD = addUnit(ONE);
712    // public static final Unit METABOLIC_EQUIVALENT =
713    // addUnit(MILLI(LITER).divide(MINUTE).divide(KILO(GRAM)));
714
715    // public static final Unit HOMEOPATHIC_POTENCY_OF_DECIMAL =
716    // addUnit(ONE.multiply(-1).multiply(Math.log10(1)));
717    // public static final Unit HOMEOPATHIC_POTENCY_OF_CENTESIMAL =
718    // addUnit(ONE.multiply(-1).multiply(Math.log(1)).divide(Math.log(100)));
719    // public static final Unit HOMEOPATHIC_POTENCY_OF_MILLESIMAL =
720    // addUnit(ONE.multiply(-1).multiply(Math.log(1)).divide(Math.log(1000)));
721    // public static final Unit HOMEOPATHIC_POTENCY_OF_QUINTALLESIMAL =
722    // addUnit(ONE.multiply(-1).multiply(Math.log(1)).divide(Math.log(50000)));
723
724    // public static final Unit HOMEOPATHIC_POTENCY_OF_DECIMAL_HAHNEMANNIAN =
725    // UNDEFINED;
726    // public static final Unit HOMEOPATHIC_POTENCY_OF_CENTESIMAL_HAHNEMANNIAN =
727    // UNDEFINED;
728    // public static final Unit HOMEOPATHIC_POTENCY_OF_MILLESIMAL_HAHNEMANNIAN =
729    // UNDEFINED;
730    // public static final Unit
731    // HOMEOPATHIC_POTENCY_OF_QUINTAMILLESIMAL_HAHNEMANNIAN = UNDEFINED;
732    // public static final Unit HOMEOPATHIC_POTENCY_OF_DECIMAL_KORSAKOVIAN =
733    // UNDEFINED;
734    // public static final Unit HOMEOPATHIC_POTENCY_OF_CENTESIMAL_KORSAKOVIAN =
735    // UNDEFINED;
736    // public static final Unit HOMEOPATHIC_POTENCY_OF_MILLESIMAL_KORSAKOVIAN =
737    // UNDEFINED;
738    // public static final Unit
739    // HOMEOPATHIC_POTENCY_OF_QUINTAMILLESIMAL_KORSAKOVIAN = UNDEFINED;
740
741    //////////////////////////////////////////////////
742    // CHEMICAL AND BIOCHEMICAL UNITS: UCUM 4.5 §45 //
743    //////////////////////////////////////////////////
744    // public static final Unit EQUIVALENTS = addUnit(MOLE);
745    // public static final Unit OSMOLE = addUnit(MOLE);
746
747    public static final Unit<Acidity> PH = addUnit(
748            MOLE.divide(LITER).transform(new LogConverter(10)).multiply(-1).asType(Acidity.class));
749
750    // @SuppressWarnings("unchecked")
751    @SuppressWarnings("unchecked")
752    public static final Unit<Concentration<Mass>> GRAM_PERCENT = addUnit(
753            GRAM.divide(DECI(LITER)).asType(Concentration.class));
754
755    // public static final Unit SVEDBERG = addUnit(SECOND.multiply(1E-13));
756
757    public static final Unit<Dimensionless> HIGH_POWER_FIELD = addUnit(ONE);
758    public static final Unit<Dimensionless> LOW_POWER_FIELD = addUnit(ONE.multiply(100));
759
760    // public static final Unit KATAL = addUnit(MOLE.divide(SECOND));
761    // public static final Unit UNIT = addUnit(MICRO(MOLE).divide(MINUTE));
762
763    // public static final Unit INTERNATIONAL_UNIT = UNDEFINED;
764    // public static final Unit ARBITRARY_UNIT = UNDEFINED;
765    // public static final Unit US_PHARMACOPEIA = UNDEFINED;
766    // public static final Unit GPL = UNDEFINED;
767    // public static final Unit MPL = UNDEFINED;
768    // public static final Unit APL = UNDEFINED;
769    // public static final Unit BETHESDA = UNDEFINED;
770    // public static final Unit ANTI_FACTOR_XA = UNDEFINED;
771    // public static final Unit TODD = UNDEFINED;
772    // public static final Unit DYE = UNDEFINED;
773    // public static final Unit SOMOGYI = UNDEFINED;
774    // public static final Unit BODANSKY = UNDEFINED;
775    // public static final Unit KING_ARMSTRONG = UNDEFINED;
776    // public static final Unit KUNKEL = UNDEFINED;
777    // public static final Unit MAC_LAGAN = UNDEFINED;
778    // public static final Unit TUBERCULIN = UNDEFINED;
779    // public static final Unit CELL_CULTURE_INFECTIOUS_50_PERCENT_DOSE =
780    // UNDEFINED;
781    // public static final Unit TISSUE_CULTURE_INFECTIOUS_50_PERCENT_DOSE =
782    // UNDEFINED;
783    // public static final Unit EMBRYO_CULTURE_INFECTIOUS_50_PERCENT_DOSE =
784    // UNDEFINED;
785    // public static final Unit PLAQUE_FORMING = UNDEFINED;
786    // public static final Unit FOCUS_FORMING = UNDEFINED;
787    // public static final Unit COLONY_FORMING = UNDEFINED;
788    // public static final Unit INDEX_OF_REACTIVITY = UNDEFINED;
789    // public static final Unit BIOEQUIVALENT_ALLERGEN = UNDEFINED;
790    // public static final Unit ALLERGEN = UNDEFINED;
791    // public static final Unit ALLERGEN_FOR_AMBROSIA_ARTEMISIIFOLIA =
792    // UNDEFINED;
793    // public static final Unit PROTEIN_NITROGEN = UNDEFINED;
794    // public static final Unit LIMIT_OF_FLOCCULATION = UNDEFINED;
795    // public static final Unit D_ANTIGEN = UNDEFINED;
796    // public static final Unit FIBRINOGEN_EQUIVALENT = UNDEFINED;
797    // public static final Unit ELISA = UNDEFINED;
798    // public static final Unit EHRLICH = UNDEFINED;
799    // public static final Unit CHEMICAL = UNDEFINED;
800
801    /////////////////////////////////
802    // LEVELS UNITS: UCUM 4.5 §46 //
803    ////////////////////////////////
804    @SuppressWarnings("unchecked")
805    public static final Unit<Level<Dimensionless>> NEPER = addUnit(
806            ONE.transform(new LogConverter(Math.E)).asType(Level.class));
807    /**
808     * A logarithmic unit used to describe a power {@link Level} ratio (standard
809     * name <code>dB</code>).
810     */
811    // public static final Unit<Level<Power>> DECIBEL = addUnit(NEPER
812    // .transform(new LogConverter(10).inverse().concatenate(
813    // RationalConverter.of(1d, 10d))));
814
815    @SuppressWarnings("unchecked")
816    public static final Unit<Level<Dimensionless>> BEL = addUnit(
817            ONE.transform(new LogConverter(10)).asType(Level.class));
818
819    @SuppressWarnings("unchecked")
820    public static final Unit<Level<Pressure>> BEL_SOUND = addUnit(
821            PASCAL.divide(1E5).multiply(2).transform(new LogConverter(10)).multiply(2).asType(Level.class));
822
823    @SuppressWarnings("unchecked")
824    public static final Unit<Level<ElectricPotential>> BEL_VOLT = addUnit(
825            VOLT.transform(new LogConverter(10)).multiply(2).asType(Level.class));
826
827    @SuppressWarnings("unchecked")
828    public static final Unit<Level<ElectricPotential>> BEL_MILLIVOLT = addUnit(
829            MILLI(VOLT).transform(new LogConverter(10)).multiply(2).asType(Level.class));
830
831    @SuppressWarnings("unchecked")
832    public static final Unit<Level<ElectricPotential>> BEL_MICROVOLT = addUnit(
833            MICRO(VOLT).transform(new LogConverter(10)).multiply(2).asType(Level.class));
834
835    @SuppressWarnings("unchecked")
836    public static final Unit<Level<ElectricPotential>> BEL_10_NANOVOLT = addUnit(
837            NANO(VOLT).multiply(10).transform(new LogConverter(10)).multiply(2).asType(Level.class));
838
839    @SuppressWarnings("unchecked")
840    public static final Unit<Level<ElectricPotential>> BEL_WATT = addUnit(
841            WATT.transform(new LogConverter(10)).asType(Level.class));
842
843    @SuppressWarnings("unchecked")
844    public static final Unit<Level<ElectricPotential>> BEL_KILOWATT = addUnit(
845            KILO(WATT).transform(new LogConverter(10)).asType(Level.class));
846
847    ///////////////////////////////////////
848    // MISCELLANEOUS UNITS: UCUM 4.5 §47 //
849    ///////////////////////////////////////
850    /** temporary helper for MHO */
851    private static final Unit<? extends Quantity<?>> TMP_MHO = SIEMENS.alternate("mho");
852
853    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
854    //public static final Unit<Volume> STERE = addUnit(new ProductUnit<Volume>(METER.pow(3)));
855    public static final Unit<Volume> STERE = addUnit(new TransformedUnit<Volume>("st", Units.CUBIC_METRE, Units.CUBIC_METRE, MultiplyConverter.IDENTITY));
856    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
857    public static final Unit<Length> ANGSTROM = addUnit(NANO(METER).divide(10));
858    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
859    public static final Unit<Area> BARN = addUnit(new ProductUnit<Area>(FEMTO(METER).pow(2)).multiply(100));
860    // public static final Unit<Area> BARN = addUnit(new
861    // ProductUnit<Area>(FEMTO(
862    // METER).pow(2).multiply(100)));
863    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
864    public static final Unit<Pressure> ATMOSPHERE_TECHNICAL = addUnit(
865            new ProductUnit<Pressure>(KILO(GRAM_FORCE).divide(CENTI(METER).pow(2))));
866    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
867    public static final Unit<ElectricConductance> MHO = addUnit(
868            new AlternateUnit<ElectricConductance>(TMP_MHO, TMP_MHO.getSymbol()));
869    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
870    public static final Unit<Pressure> POUND_PER_SQUARE_INCH = addUnit(
871            new ProductUnit<Pressure>(POUND_FORCE.divide(INCH_INTERNATIONAL.pow(2))));
872    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
873    public static final Unit<Angle> CIRCLE = addUnit(new ProductUnit<Angle>(PI.multiply(RADIAN.multiply(2))));
874    // public static final Unit<Angle> CIRCLE = addUnit(new
875    // ProductUnit<Angle>(PI
876    // .multiply(RADIAN).multiply(2)));
877    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
878    public static final Unit<SolidAngle> SPHERE = addUnit(
879            new ProductUnit<SolidAngle>(PI.multiply(STERADIAN.multiply(4))));
880    // public static final Unit<SolidAngle> SPHERE = addUnit(new
881    // ProductUnit<SolidAngle>(
882    // PI.multiply(STERADIAN).multiply(4)));
883    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
884    public static final Unit<Mass> CARAT_METRIC = addUnit(GRAM.divide(5));
885    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
886    public static final Unit<Dimensionless> CARAT_GOLD = addUnit(ONE.divide(24));
887    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
888    public static final Unit<Length> SMOOT = addUnit(INCH_INTERNATIONAL.multiply(67));
889
890    ////////////////////////////////////////////////
891    // INFORMATION TECHNOLOGY UNITS: UCUM 4.6 §48 //
892    ////////////////////////////////////////////////
893    /**
894     * The unit for binary information (standard name <code>bit</code>).
895     * As per <a href="http://unitsofmeasure.org/">UCUM</a> standard.
896     */
897    public static final Unit<Information> BIT = addUnit(new AlternateUnit<Information>(ONE, "bit"), Information.class);
898    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
899    public static final Unit<Information> BYTE = addUnit(BIT.multiply(8));
900    /**
901     * The SI unit for binary information rate (standard name
902     * <code>bit/s</code>).
903     */
904    protected static final ProductUnit<InformationRate> BITS_PER_SECOND = addUnit(
905            new ProductUnit<InformationRate>(BIT.divide(SECOND)), InformationRate.class);
906    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
907    public static final Unit<InformationRate> BAUD = addUnit(BITS_PER_SECOND);
908
909    /////////////////////
910    // Collection View //
911    /////////////////////
912
913    @Override
914    public String getName() {
915        return "Unified Code for Units of Measure";
916    }
917
918    private static <U extends Unit<Q>, Q extends Quantity<Q>> U addUnit(U unit) {
919        INSTANCE.units.add(unit);
920        return unit;
921    }
922
923    /**
924     * Adds a new unit and maps it to the specified quantity type.
925     *
926     * @param unit
927     *            the unit being added.
928     * @param type
929     *            the quantity type.
930     * @return <code>unit</code>.
931     */
932    private static <U extends AbstractUnit<?>> U addUnit(U unit, Class<? extends Quantity<?>> type) {
933        INSTANCE.units.add(unit);
934        INSTANCE.quantityToUnit.put(type, unit);
935        return unit;
936    }
937    
938    /**
939     * Adds a new unit not mapped to any specified quantity type and puts a text
940     * as symbol or label.
941     *
942     * @param unit
943     *            the unit being added.
944     * @param name
945     *            the string to use as name
946     * @param text
947     *            the string to use as label or symbol
948     * @param isLabel
949     *            if the string should be used as a label or not
950     * @return <code>unit</code>.
951     */
952    private static <U extends Unit<?>> U addUnit(U unit, String name, String text, boolean isLabel) {
953        if (isLabel) {
954            SimpleUnitFormat.getInstance().label(unit, text);
955        }
956        if (name != null && unit instanceof AbstractUnit) {
957            return Helper.addUnit(INSTANCE.units, unit, name);
958        } else {
959            INSTANCE.units.add(unit);
960        }
961        return unit;
962    }
963
964    ////////////////////////////////////////////////////////////////////////////
965    // Label adjustments for UCUM system
966    static {
967        SimpleUnitFormat.getInstance().label(ATOMIC_MASS_UNIT, "AMU");
968        //SimpleUnitFormat.getInstance().label(LITER, "L");
969        //SimpleUnitFormat.getInstance().label(LITER_DM3, "l");
970        SimpleUnitFormat.getInstance().label(OUNCE, "oz");
971        SimpleUnitFormat.getInstance().label(POUND, "lb");
972        SimpleUnitFormat.getInstance().label(PLANCK, "h");
973        // TODO maybe we can find a better solution, but it would require to
974        // "harvest" the entire UCUMFormat ResourceBundle and label every
975        // matching UCUM unit in a loop.
976    }
977}