001/* 002 * SI Units of Measurement for Java 003 * Copyright (c) 2005-2016, Jean-Marie Dautelle, Werner Keil, V2COM. 004 * 005 * All rights reserved. 006 * 007 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 008 * 009 * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 010 * 011 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 012 * 013 * 3. Neither the name of JSR-363 nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 014 * 015 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 016 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 017 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 018 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 019 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 020 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 021 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 022 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 024 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 025 */ 026package si.uom; 027 028import static tec.units.ri.AbstractUnit.ONE; 029import static tec.units.ri.unit.Units.*; 030 031import javax.measure.Unit; 032import javax.measure.quantity.Acceleration; 033import javax.measure.quantity.AmountOfSubstance; 034import javax.measure.quantity.Angle; 035import javax.measure.quantity.Area; 036import javax.measure.quantity.Dimensionless; 037import javax.measure.quantity.ElectricCharge; 038import javax.measure.quantity.ElectricCurrent; 039import javax.measure.quantity.Energy; 040import javax.measure.quantity.Force; 041import javax.measure.quantity.Frequency; 042import javax.measure.quantity.Illuminance; 043import javax.measure.quantity.Length; 044import javax.measure.quantity.MagneticFlux; 045import javax.measure.quantity.MagneticFluxDensity; 046import javax.measure.quantity.Mass; 047import javax.measure.quantity.Pressure; 048import javax.measure.quantity.RadiationDoseAbsorbed; 049import javax.measure.quantity.RadiationDoseEffective; 050import javax.measure.quantity.Radioactivity; 051import javax.measure.quantity.SolidAngle; 052import javax.measure.quantity.Speed; 053import javax.measure.quantity.Temperature; 054import javax.measure.quantity.Time; 055 056import si.uom.quantity.IonizingRadiation; 057import tec.units.ri.AbstractSystemOfUnits; 058import tec.units.ri.AbstractUnit; 059import tec.units.ri.format.SimpleUnitFormat; 060import tec.units.ri.function.LogConverter; 061import tec.units.ri.function.MultiplyConverter; 062import tec.units.ri.function.PiMultiplierConverter; 063import tec.units.ri.function.RationalConverter; 064import tec.units.ri.unit.TransformedUnit; 065 066/** 067 * <p> 068 * This class contains units that are not part of the International System of 069 * Units, that is, they are outside the SI, but some are still widely used. 070 * </p> 071 * 072 * <p> 073 * This class is not intended to be implemented by clients. 074 * </p> 075 * 076 * @noimplement This class is not intended to be implemented by clients. 077 * @noextend This class is not intended to be extended by clients. 078 * 079 * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a> 080 * @author <a href="mailto:units@catmedia.us">Werner Keil</a> 081 * @version 1.0.3, $Date: 2017-02-28$ 082 * @see <a href= 083 * "https://en.wikipedia.org/wiki/Non-SI_units_mentioned_in_the_SI#Common_units_not_officially_sanctioned">Wikipedia: 084 * Common Units not officially sanctioned</a> 085 */ 086public class NonSI extends AbstractSystemOfUnits { 087 private static final String SYSTEM_NAME = "Non-SI Units"; 088 089 /** 090 * Holds the standard gravity constant: 9.80665 m/s² exact. 091 */ 092 private static final int STANDARD_GRAVITY_DIVIDEND = 980665; 093 094 private static final int STANDARD_GRAVITY_DIVISOR = 100000; 095 096 /** 097 * Holds the avoirdupois pound: 0.45359237 kg exact 098 */ 099 static final int AVOIRDUPOIS_POUND_DIVIDEND = 45359237; 100 101 static final int AVOIRDUPOIS_POUND_DIVISOR = 100000000; 102 103 /** 104 * Holds the Avogadro constant. 105 */ 106 private static final double AVOGADRO_CONSTANT = 6.02214199e23; // (1/mol). 107 108 /** 109 * Holds the electric charge of one electron. 110 */ 111 private static final double ELEMENTARY_CHARGE = 1.602176462e-19; // (C). 112 113 /** 114 * Default constructor (prevents this class from being instantiated). 115 */ 116 private NonSI() { 117 } 118 119 /** 120 * Returns the unique instance of this class. 121 * 122 * @return the NonSI instance. 123 */ 124 public static NonSI getInstance() { 125 return INSTANCE; 126 } 127 128 private static final NonSI INSTANCE = new NonSI(); 129 ///////////////////////////////////////////////////////////////// 130 // Units outside the SI that are accepted for use with the SI. // 131 ///////////////////////////////////////////////////////////////// 132 133 /** 134 * An angle unit accepted for use with SI units (standard name 135 * <code>deg</code>). 136 */ 137 public static final Unit<Angle> DEGREE_ANGLE = addUnit( 138 new TransformedUnit<Angle>(RADIAN, new PiMultiplierConverter().concatenate(new RationalConverter(1, 180))), 139 "Degree Angle", "deg"); 140 141 /** 142 * An angle unit accepted for use with SI units (standard name 143 * <code>'</code>). 144 */ 145 public static final Unit<Angle> MINUTE_ANGLE = addUnit(new TransformedUnit<Angle>(RADIAN, 146 new PiMultiplierConverter().concatenate(new RationalConverter(1, 180 * 60))), "Minute Angle", "'"); 147 148 /** 149 * An angle unit accepted for use with SI units (standard name 150 * <code>''</code>). 151 */ 152 public static final Unit<Angle> SECOND_ANGLE = addUnit( 153 new TransformedUnit<Angle>(RADIAN, 154 new PiMultiplierConverter().concatenate(new RationalConverter(1, 180 * 60 * 60))), 155 "Second Angle", "''"); 156 157 /** 158 * A mass unit accepted for use with SI units (standard name 159 * <code>t</code>). 160 */ 161 public static final Unit<Mass> TONNE = addUnit(new TransformedUnit<Mass>(KILOGRAM, new RationalConverter(1000, 1)), 162 "Tonne", "t"); 163 164 /** 165 * An energy unit accepted for use with SI units (standard name 166 * <code>eV</code>). The electronvolt is the kinetic energy acquired by an 167 * electron passing through a potential difference of 1 V in vacuum. The 168 * value must be obtained by experiment, and is therefore not known exactly. 169 */ 170 public static final Unit<Energy> ELECTRON_VOLT = addUnit( 171 new TransformedUnit<Energy>(JOULE, new MultiplyConverter(1.602176487E-19)), "Electron Volt", "eV"); 172 // CODATA 2006 - http://physics.nist.gov/cuu/Constants/codata.pdf 173 174 /** 175 * A mass unit accepted for use with SI units (standard name 176 * <code>u</code>). The unified atomic mass unit is equal to 1/12 of the 177 * mass of an unbound atom of the nuclide 12C, at rest and in its ground 178 * state. The value must be obtained by experiment, and is therefore not 179 * known exactly. 180 */ 181 public static final Unit<Mass> UNIFIED_ATOMIC_MASS = addUnit( 182 new TransformedUnit<Mass>(KILOGRAM, new MultiplyConverter(1.660538782E-27)), "Unified atomic mass", "u", 183 true); 184 // CODATA 2006 - http://physics.nist.gov/cuu/Constants/codata.pdf 185 186 /** 187 * A length unit accepted for use with SI units (standard name 188 * <code>UA</code>). The astronomical unit is a unit of length. Its value is 189 * such that, when used to describe the motion of bodies in the solar 190 * system, the heliocentric gravitation constant is (0.017 202 098 95)2 191 * ua3·d-2. The value must be obtained by experiment, and is therefore not 192 * known exactly. 193 */ 194 public static final Unit<Length> ASTRONOMICAL_UNIT = addUnit( 195 new TransformedUnit<Length>(METRE, new MultiplyConverter(149597871000.0)), "Astronomical Unit", "UA"); 196 // Best estimate source: http://maia.usno.navy.mil/NSFA/CBE.html 197 198 /** 199 * An angle unit accepted for use with SI units (standard name 200 * <code>ha</code>). 201 */ 202 public static final Unit<Area> HECTARE = addUnit( 203 new TransformedUnit<Area>(SQUARE_METRE, new RationalConverter(10000, 1)), "Hectare", "ha"); 204 205 // ///////////////// 206 // Dimensionless // 207 // ///////////////// 208 /** 209 * A dimensionless unit equals to <code>pi</code> (standard name 210 * <code>Ï€</code>). 211 */ 212 static final Unit<Dimensionless> PI = addUnit(ONE.multiply(StrictMath.PI)); 213 214 /** 215 * A logarithmic unit used to describe a ratio (standard name 216 * <code>dB</code>). 217 */ 218 static final Unit<Dimensionless> DECIBEL = ONE 219 .transform(new LogConverter(10).inverse().concatenate(new RationalConverter(1d, 10d))); 220 221 // /////////////////////// 222 // Amount of substance // 223 // /////////////////////// 224 /** 225 * A unit of amount of substance equals to one atom (standard name 226 * <code>atom</code>). 227 */ 228 static final Unit<AmountOfSubstance> ATOM = MOLE.divide(AVOGADRO_CONSTANT); 229 230 // ////////// 231 // Length // 232 // ////////// 233 234 /** 235 * A unit of length equal to <code>1E-10 m</code> (standard name 236 * <code>\u00C5ngstr\u00F6m</code>). 237 */ 238 public static final Unit<Length> ANGSTROM = addUnit(METRE.divide(10000000000L), "\u00C5ngstr\u00F6m", "\u00C5"); 239 240 /** 241 * A unit of length equal to the average distance from the center of the 242 * Earth to the center of the Sun (standard name <code>ua</code>). 243 */ 244 // static final Unit<Length> ASTRONOMICAL_UNIT = 245 // addUnit(METRE.multiply(149597870691.0)); 246 247 /** 248 * A unit of length equal to the distance that light travels in one year 249 * through a vacuum (standard name <code>ly</code>). 250 */ 251 static final Unit<Length> LIGHT_YEAR = addUnit(METRE.multiply(9.460528405e15)); 252 253 /** 254 * A unit of length equal to the distance at which a star would appear to 255 * shift its position by one arcsecond over the course the time (about 3 256 * months) in which the Earth moves a distance of {@link #ASTRONOMICAL_UNIT} 257 * in the direction perpendicular to the direction to the star (standard 258 * name <code>pc</code>). 259 */ 260 static final Unit<Length> PARSEC = METRE.multiply(30856770e9); 261 262 /** 263 * A unit of duration equal to the time required for a complete rotation of 264 * the earth in reference to any star or to the vernal equinox at the 265 * meridian, equal to 23 hours, 56 minutes, 4.09 seconds (standard name 266 * <code>day_sidereal</code>). 267 */ 268 static final Unit<Time> DAY_SIDEREAL = addUnit(SECOND.multiply(86164.09)); 269 270 /** 271 * A unit of duration equal to one complete revolution of the earth about 272 * the sun, relative to the fixed stars, or 365 days, 6 hours, 9 minutes, 273 * 9.54 seconds (standard name <code>year_sidereal</code>). 274 */ 275 static final Unit<Time> YEAR_SIDEREAL = addUnit(SECOND.multiply(31558149.54)); 276 277 /** 278 * The Julian year, as used in astronomy and other sciences, is a time unit 279 * defined as exactly 365.25 days. This is the normal meaning of the unit 280 * "year" (symbol "a" from the Latin annus, annata) used in various 281 * scientific contexts. 282 */ 283 static final Unit<Time> YEAR_JULIEN = addUnit(SECOND.multiply(31557600)); 284 285 // //////// 286 // Mass // 287 // //////// 288 /** 289 * A unit of mass equal to 1/12 the mass of the carbon-12 atom (standard 290 * name <code>u</code>). 291 */ 292 static final Unit<Mass> ATOMIC_MASS = addUnit(KILOGRAM.multiply(1e-3 / AVOGADRO_CONSTANT)); 293 294 /** 295 * A unit of mass equal to the mass of the electron (standard name 296 * <code>me</code>). 297 */ 298 static final Unit<Mass> ELECTRON_MASS = addUnit(KILOGRAM.multiply(9.10938188e-31)); 299 300 // /////////////////// 301 // Electric charge // 302 // /////////////////// 303 /** 304 * A unit of electric charge equal to the charge on one electron (standard 305 * name <code>e</code>). 306 */ 307 static final Unit<ElectricCharge> E = addUnit(COULOMB.multiply(ELEMENTARY_CHARGE)); 308 309 /** 310 * A unit of electric charge equal to equal to the product of Avogadro's 311 * number (see {@link SI#MOLE}) and the charge (1 e) on a single electron 312 * (standard name <code>Fd</code>). 313 */ 314 static final Unit<ElectricCharge> FARADAY = addUnit(COULOMB.multiply(ELEMENTARY_CHARGE * AVOGADRO_CONSTANT)); // e/mol 315 316 /** 317 * A unit of electric charge which exerts a force of one dyne on an equal 318 * charge at a distance of one centimeter (standard name <code>Fr</code>). 319 */ 320 static final Unit<ElectricCharge> FRANKLIN = addUnit(COULOMB.multiply(3.3356e-10)); 321 322 // /////////////// 323 // Temperature // 324 // /////////////// 325 /** 326 * A unit of temperature equal to <code>5/9 °K</code> (standard name 327 * <code>°R</code>). 328 */ 329 static final Unit<Temperature> RANKINE = KELVIN.multiply(5).divide(9); 330 331 // ///////// 332 // Angle // 333 // ///////// 334 335 /** 336 * A unit of angle equal to a full circle or <code>2<i>π</i> 337 * {@link SI#RADIAN}</code> (standard name <code>rev</code>). 338 */ 339 static final Unit<Angle> REVOLUTION = addUnit(RADIAN.multiply(2).multiply(Math.PI).asType(Angle.class)); 340 341 // //////////// 342 // Velocity // 343 // //////////// 344 /** 345 * A unit of velocity relative to the speed of light (standard name 346 * <code>c</code>). 347 */ 348 static final Unit<Speed> C = METRE_PER_SECOND.multiply(299792458); 349 350 // //////////////// 351 // Acceleration // 352 // //////////////// 353 /** 354 * A unit of acceleration equal to the gravity at the earth's surface 355 * (standard name <code>grav</code>). 356 */ 357 static final Unit<Acceleration> G = METRE_PER_SQUARE_SECOND.multiply(STANDARD_GRAVITY_DIVIDEND) 358 .divide(STANDARD_GRAVITY_DIVISOR); 359 360 // //////////////////// 361 // Electric current // 362 // //////////////////// 363 /** 364 * A unit of electric charge equal to the centimeter-gram-second 365 * electromagnetic unit of magnetomotive force, equal to <code>10/4 366 * πampere-turn</code> (standard name <code>Gi</code>). 367 */ 368 public static final Unit<ElectricCurrent> GILBERT = AMPERE.multiply(10).divide(4).multiply(PI) 369 .asType(ElectricCurrent.class); 370 371 // ////////// 372 // Energy // 373 // ////////// 374 /** 375 * A unit of energy equal to <code>1E-7 J</code> (standard name 376 * <code>erg</code>). 377 */ 378 public static final Unit<Energy> ERG = JOULE.divide(10000000); 379 380 /** 381 * A unit of energy equal to one electron-volt (standard name 382 * <code>eV</code>, also recognized <code>keV, MeV, GeV</code>). 383 */ 384 // static final Unit<Energy> ELECTRON_VOLT = 385 // JOULE.multiply(ELEMENTARY_CHARGE); 386 387 // /////////////// 388 // Illuminance // 389 // /////////////// 390 /** 391 * A unit of illuminance equal to <code>1E4 Lx</code> (standard name 392 * <code>La</code>). 393 */ 394 static final Unit<Illuminance> LAMBERT = addUnit(LUX.multiply(10000)); 395 396 // ///////////////// 397 // Magnetic Flux // 398 // ///////////////// 399 /** 400 * A unit of magnetic flux equal <code>1E-8 Wb</code> (standard name 401 * <code>Mx</code>). 402 */ 403 static final Unit<MagneticFlux> MAXWELL = addUnit(WEBER.divide(100000000)); 404 405 // ///////////////////////// 406 // Magnetic Flux Density // 407 // ///////////////////////// 408 /** 409 * A unit of magnetic flux density equal <code>1000 A/m</code> (standard 410 * name <code>G</code>). 411 */ 412 static final Unit<MagneticFluxDensity> GAUSS = addUnit(TESLA.divide(10000)); 413 414 // ///////// 415 // Force // 416 // ///////// 417 /** 418 * A unit of force equal to <code>1E-5 N</code> (standard name 419 * <code>dyn</code>). 420 */ 421 static final Unit<Force> DYNE = addUnit(NEWTON.divide(100000)); 422 423 /** 424 * A unit of force equal to <code>9.80665 N</code> (standard name 425 * <code>kgf</code>). 426 */ 427 static final Unit<Force> KILOGRAM_FORCE = NEWTON.multiply(STANDARD_GRAVITY_DIVIDEND) 428 .divide(STANDARD_GRAVITY_DIVISOR); 429 430 /** 431 * A unit of force equal to <code>{@link #POUND}·{@link #G}</code> 432 * (standard name <code>lbf</code>). 433 */ 434 static final Unit<Force> POUND_FORCE = NEWTON.multiply(1L * AVOIRDUPOIS_POUND_DIVIDEND * STANDARD_GRAVITY_DIVIDEND) 435 .divide(1L * AVOIRDUPOIS_POUND_DIVISOR * STANDARD_GRAVITY_DIVISOR); 436 437 // //////////// 438 // Pressure // 439 // //////////// 440 /** 441 * A unit of pressure equal to the average pressure of the Earth's 442 * atmosphere at sea level (standard name <code>atm</code>). 443 */ 444 static final Unit<Pressure> ATMOSPHERE = addUnit(PASCAL.multiply(101325)); 445 446 /** 447 * A unit of pressure equal to <code>100 kPa</code> (standard name 448 * <code>bar</code>). 449 */ 450 public static final Unit<Pressure> BAR = addUnit(PASCAL.multiply(100000), "Bar", "b"); 451 452 /** 453 * A unit of pressure equal to the pressure exerted at the Earth's surface 454 * by a column of mercury 1 millimeter high (standard name <code>mmHg</code> 455 * ). 456 */ 457 public static final Unit<Pressure> MILLIMETRE_OF_MERCURY = addUnit(PASCAL.multiply(133.322)); 458 459 /** 460 * A unit of pressure equal to the pressure exerted at the Earth's surface 461 * by a column of mercury 1 inch high (standard name <code>inHg</code>). 462 */ 463 static final Unit<Pressure> INCH_OF_MERCURY = addUnit(PASCAL.multiply(3386.388)); 464 465 // /////////////////////////// 466 // Radiation dose absorbed // 467 // /////////////////////////// 468 /** 469 * A unit of radiation dose absorbed equal to a dose of 0.01 joule of energy 470 * per kilogram of mass (J/kg) (standard name <code>rd</code>). 471 */ 472 public static final Unit<RadiationDoseAbsorbed> RAD = addUnit(GRAY.divide(100), "Rad", "rd"); 473 474 /** 475 * A unit of radiation dose effective equal to <code>0.01 Sv</code> 476 * (standard name <code>rem</code>). 477 */ 478 static final Unit<RadiationDoseEffective> REM = addUnit(SIEVERT.divide(100)); 479 480 // //////////////////////// 481 // Radioactive activity // 482 // //////////////////////// 483 /** 484 * A unit of radioctive activity equal to the activity of a gram of radium 485 * (standard name <code>Ci</code>). 486 */ 487 static final Unit<Radioactivity> CURIE = addUnit(BECQUEREL.multiply(37000000000L)); 488 489 /** 490 * A unit of radioctive activity equal to 1 million radioactive 491 * disintegrations per second (standard name <code>Rd</code>). 492 */ 493 static final Unit<Radioactivity> RUTHERFORD = addUnit(BECQUEREL.multiply(1000000)); 494 495 // /////////////// 496 // Solid angle // 497 // /////////////// 498 /** 499 * A unit of solid angle equal to <code>4 <i>π</i> steradians</code> 500 * (standard name <code>sphere</code>). 501 */ 502 static final Unit<SolidAngle> SPHERE = addUnit(STERADIAN.multiply(4).multiply(PI).asType(SolidAngle.class)); 503 504 // ////////// 505 // Volume // 506 // ////////// 507 508 // ///////////// 509 // Viscosity // 510 // ///////////// 511 /** 512 * A unit of dynamic viscosity equal to <code>1 g/(cm·s)</code> (cgs unit). 513 */ 514 // static final Unit<DynamicViscosity> POISE = addUnit( 515 // GRAM.divide(CENTI(METRE).multiply(SECOND))).asType( 516 // DynamicViscosity.class); 517 // FIXME move to CGS module, see https://de.wikipedia.org/wiki/Poise 518 /** 519 * A unit of kinematic viscosity equal to <code>1 cm²/s</code> (cgs unit). 520 */ 521 // static final Unit<KinematicViscosity> STOKES = addUnit( 522 // CENTI(METRE).pow(2).divide(SECOND)) 523 // .asType(KinematicViscosity.class); 524 // FIXME move to CGS module 525 526 // ///////////// 527 // Frequency // 528 // ///////////// 529 /** 530 * A unit used to measure the frequency (rate) at which an imaging device 531 * produces unique consecutive images (standard name <code>fps</code>). 532 */ 533 static final Unit<Frequency> FRAMES_PER_SECOND = addUnit(ONE.divide(SECOND)).asType(Frequency.class); 534 535 // ////////// 536 // Others // 537 // ////////// 538 /** 539 * A unit used to measure the ionizing ability of radiation (standard name 540 * <code>Roentgen</code>). 541 */ 542 // static final Unit<IonizingRadiation> ROENTGEN = SI.ROENTGEN; 543 544 /** 545 * A unit used to measure the ionizing ability of radiation (standard name 546 * <code>Roentgen</code>). 547 */ 548 @SuppressWarnings("unchecked") 549 public static final Unit<IonizingRadiation> ROENTGEN = (Unit<IonizingRadiation>) addUnit( 550 COULOMB.divide(KILOGRAM).multiply(2.58e-4), "Roentgen", "r", true); 551 552 public String getName() { 553 return SYSTEM_NAME; 554 } 555 556 /** 557 * Adds a new unit not mapped to any specified quantity type. 558 * 559 * @param unit 560 * the unit being added. 561 * @return <code>unit</code>. 562 */ 563 private static <U extends Unit<?>> U addUnit(U unit) { 564 INSTANCE.units.add(unit); 565 return unit; 566 } 567 568 /** 569 * Adds a new unit not mapped to any specified quantity type and puts a text 570 * as symbol or label. 571 * 572 * @param unit 573 * the unit being added. 574 * @param name 575 * the string to use as name 576 * @param text 577 * the string to use as label or symbol 578 * @param isLabel 579 * if the string should be used as a label or not 580 * @return <code>unit</code>. 581 */ 582 private static <U extends Unit<?>> U addUnit(U unit, String name, String text, boolean isLabel) { 583 if (isLabel && text != null) { 584 SimpleUnitFormat.getInstance().label(unit, text); 585 } 586 if (name != null && unit instanceof AbstractUnit) { 587 return Helper.addUnit(INSTANCE.units, unit, name); 588 } else { 589 INSTANCE.units.add(unit); 590 } 591 return unit; 592 } 593 594 /** 595 * Adds a new unit not mapped to any specified quantity type and puts a text 596 * as symbol or label. 597 * 598 * @param unit 599 * the unit being added. 600 * @param name 601 * the string to use as name 602 * @param text 603 * the string to use as label 604 * @return <code>unit</code>. 605 */ 606 private static <U extends Unit<?>> U addUnit(U unit, String name, String text) { 607 return addUnit(unit, name, text, true); 608 } 609}