001/* 002 * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences. 003 * Copyright (C) 2006 - JScience (http://jscience.org/) 004 * All rights reserved. 005 * 006 * Permission to use, copy, modify, and distribute this software is 007 * freely granted, provided that this notice is preserved. 008 */ 009package javax.measure.unit; 010 011import java.util.Collections; 012import java.util.HashSet; 013import java.util.Set; 014 015import javax.measure.converter.MultiplyConverter; 016import javax.measure.converter.RationalConverter; 017import javax.measure.quantity.*; 018 019/** 020 * <p> This class contains SI (Système International d'Unités) base units, 021 * and derived units.</p> 022 * 023 * <p> It also defines the 20 SI prefixes used to form decimal multiples and 024 * submultiples of SI units. For example:[code] 025 * import static org.jscience.physics.units.SI.*; // Static import. 026 * ... 027 * Unit<Pressure> HECTO_PASCAL = HECTO(PASCAL); 028 * Unit<Length> KILO_METER = KILO(METER); 029 * [/code]</p> 030 * 031 * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a> 032 * @version 4.2, August 26, 2006 033 * @see <a href="http://en.wikipedia.org/wiki/SI">Wikipedia: SI</a> 034 * @see <a href="http://en.wikipedia.org/wiki/SI_prefix">Wikipedia: SI prefix</a> 035 */ 036public final class SI extends SystemOfUnits { 037 038 /** 039 * Holds collection of SI units. 040 */ 041 private static HashSet<Unit<?>> UNITS = new HashSet<Unit<?>>(); 042 043 /** 044 * Default constructor (prevents this class from being instantiated). 045 */ 046 private SI() { 047 } 048 049 050 /** 051 * Returns the unique instance of this class. 052 * 053 * @return the SI instance. 054 */ 055 public static SI getInstance() { 056 return INSTANCE; 057 } 058 private static final SI INSTANCE = new SI(); 059 060 //////////////// 061 // BASE UNITS // 062 //////////////// 063 064 /** 065 * The base unit for electric current quantities (<code>A</code>). 066 * The Ampere is that constant current which, if maintained in two straight 067 * parallel conductors of infinite length, of negligible circular 068 * cross-section, and placed 1 metre apart in vacuum, would produce between 069 * these conductors a force equal to 2 × 10-7 newton per metre of length. 070 * It is named after the French physicist Andre Ampere (1775-1836). 071 */ 072 public static final BaseUnit<ElectricCurrent> AMPERE = si(new BaseUnit<ElectricCurrent>( 073 "A")); 074 075 /** 076 * The base unit for luminous intensity quantities (<code>cd</code>). 077 * The candela is the luminous intensity, in a given direction, 078 * of a source that emits monochromatic radiation of frequency 079 * 540 × 1012 hertz and that has a radiant intensity in that 080 * direction of 1/683 watt per steradian 081 * @see <a href="http://en.wikipedia.org/wiki/Candela"> 082 * Wikipedia: Candela</a> 083 */ 084 public static final BaseUnit<LuminousIntensity> CANDELA = si(new BaseUnit<LuminousIntensity>( 085 "cd")); 086 087 /** 088 * The base unit for thermodynamic temperature quantities (<code>K</code>). 089 * The kelvin is the 1/273.16th of the thermodynamic temperature of the 090 * triple point of water. It is named after the Scottish mathematician and 091 * physicist William Thomson 1st Lord Kelvin (1824-1907) 092 */ 093 public static final BaseUnit<Temperature> KELVIN = si(new BaseUnit<Temperature>( 094 "K")); 095 096 /** 097 * The base unit for mass quantities (<code>kg</code>). 098 * It is the only SI unit with a prefix as part of its name and symbol. 099 * The kilogram is equal to the mass of an international prototype in the 100 * form of a platinum-iridium cylinder kept at Sevres in France. 101 * @see #GRAM 102 */ 103 public static final BaseUnit<Mass> KILOGRAM = si(new BaseUnit<Mass>("kg")); 104 105 /** 106 * The base unit for length quantities (<code>m</code>). 107 * One meter was redefined in 1983 as the distance traveled by light in 108 * a vacuum in 1/299,792,458 of a second. 109 */ 110 public static final BaseUnit<Length> METRE = si(new BaseUnit<Length>("m")); 111 112 /** 113 * Equivalent to {@link #METRE} (American spelling). 114 */ 115 public static final Unit<Length> METER = METRE; 116 117 /** 118 * The base unit for amount of substance quantities (<code>mol</code>). 119 * The mole is the amount of substance of a system which contains as many 120 * elementary entities as there are atoms in 0.012 kilogram of carbon 12. 121 */ 122 public static final BaseUnit<AmountOfSubstance> MOLE = si(new BaseUnit<AmountOfSubstance>( 123 "mol")); 124 125 /** 126 * The base unit for duration quantities (<code>s</code>). 127 * It is defined as the duration of 9,192,631,770 cycles of radiation 128 * corresponding to the transition between two hyperfine levels of 129 * the ground state of cesium (1967 Standard). 130 */ 131 public static final BaseUnit<Duration> SECOND = si(new BaseUnit<Duration>( 132 "s")); 133 134 //////////////////////////////// 135 // SI DERIVED ALTERNATE UNITS // 136 //////////////////////////////// 137 138 /** 139 * The derived unit for mass quantities (<code>g</code>). 140 * The base unit for mass quantity is {@link #KILOGRAM}. 141 */ 142 public static final Unit<Mass> GRAM = KILOGRAM.divide(1000); 143 144 /** 145 * The unit for plane angle quantities (<code>rad</code>). 146 * One radian is the angle between two radii of a circle such that the 147 * length of the arc between them is equal to the radius. 148 */ 149 public static final AlternateUnit<Angle> RADIAN = si(new AlternateUnit<Angle>( 150 "rad", Unit.ONE)); 151 152 /** 153 * The unit for solid angle quantities (<code>sr</code>). 154 * One steradian is the solid angle subtended at the center of a sphere by 155 * an area on the surface of the sphere that is equal to the radius squared. 156 * The total solid angle of a sphere is 4*Pi steradians. 157 */ 158 public static final AlternateUnit<SolidAngle> STERADIAN = si(new AlternateUnit<SolidAngle>( 159 "sr", Unit.ONE)); 160 161 /** 162 * The unit for binary information (<code>bit</code>). 163 */ 164 public static final AlternateUnit<DataAmount> BIT = si(new AlternateUnit<DataAmount>( 165 "bit", Unit.ONE)); 166 167 /** 168 * The derived unit for frequency (<code>Hz</code>). 169 * A unit of frequency equal to one cycle per second. 170 * After Heinrich Rudolf Hertz (1857-1894), German physicist who was the 171 * first to produce radio waves artificially. 172 */ 173 public static final AlternateUnit<Frequency> HERTZ = si(new AlternateUnit<Frequency>( 174 "Hz", Unit.ONE.divide(SECOND))); 175 176 /** 177 * The derived unit for force (<code>N</code>). 178 * One newton is the force required to give a mass of 1 kilogram an Force 179 * of 1 metre per second per second. It is named after the English 180 * mathematician and physicist Sir Isaac Newton (1642-1727). 181 */ 182 public static final AlternateUnit<Force> NEWTON = si(new AlternateUnit<Force>( 183 "N", METRE.times(KILOGRAM).divide(SECOND.pow(2)))); 184 185 /** 186 * The derived unit for pressure, stress (<code>Pa</code>). 187 * One pascal is equal to one newton per square meter. It is named after 188 * the French philosopher and mathematician Blaise Pascal (1623-1662). 189 */ 190 public static final AlternateUnit<Pressure> PASCAL = si(new AlternateUnit<Pressure>( 191 "Pa", NEWTON.divide(METRE.pow(2)))); 192 193 /** 194 * The derived unit for energy, work, quantity of heat (<code>J</code>). 195 * One joule is the amount of work done when an applied force of 1 newton 196 * moves through a distance of 1 metre in the direction of the force. 197 * It is named after the English physicist James Prescott Joule (1818-1889). 198 */ 199 public static final AlternateUnit<Energy> JOULE = si(new AlternateUnit<Energy>( 200 "J", NEWTON.times(METRE))); 201 202 /** 203 * The derived unit for power, radiant, flux (<code>W</code>). 204 * One watt is equal to one joule per second. It is named after the British 205 * scientist James Watt (1736-1819). 206 */ 207 public static final AlternateUnit<Power> WATT = si(new AlternateUnit<Power>( 208 "W", JOULE.divide(SECOND))); 209 210 /** 211 * The derived unit for electric charge, quantity of electricity 212 * (<code>C</code>). 213 * One Coulomb is equal to the quantity of charge transferred in one second 214 * by a steady current of one ampere. It is named after the French physicist 215 * Charles Augustin de Coulomb (1736-1806). 216 */ 217 public static final AlternateUnit<ElectricCharge> COULOMB = si(new AlternateUnit<ElectricCharge>( 218 "C", SECOND.times(AMPERE))); 219 220 /** 221 * The derived unit for electric potential difference, electromotive force 222 * (<code>V</code>). 223 * One Volt is equal to the difference of electric potential between two 224 * points on a conducting wire carrying a constant current of one ampere 225 * when the power dissipated between the points is one watt. It is named 226 * after the Italian physicist Count Alessandro Volta (1745-1827). 227 */ 228 public static final AlternateUnit<ElectricPotential> VOLT = si(new AlternateUnit<ElectricPotential>( 229 "V", WATT.divide(AMPERE))); 230 231 /** 232 * The derived unit for capacitance (<code>F</code>). 233 * One Farad is equal to the capacitance of a capacitor having an equal 234 * and opposite charge of 1 coulomb on each plate and a potential difference 235 * of 1 volt between the plates. It is named after the British physicist 236 * and chemist Michael Faraday (1791-1867). 237 */ 238 public static final AlternateUnit<ElectricCapacitance> FARAD = si(new AlternateUnit<ElectricCapacitance>( 239 "F", COULOMB.divide(VOLT))); 240 241 /** 242 * The derived unit for electric resistance (<code>Ω</code> or 243 * <code>Ohm</code>). 244 * One Ohm is equal to the resistance of a conductor in which a current of 245 * one ampere is produced by a potential of one volt across its terminals. 246 * It is named after the German physicist Georg Simon Ohm (1789-1854). 247 */ 248 public static final AlternateUnit<ElectricResistance> OHM = si(new AlternateUnit<ElectricResistance>( 249 "Ω", VOLT.divide(AMPERE))); 250 251 /** 252 * The derived unit for electric conductance (<code>S</code>). 253 * One Siemens is equal to one ampere per volt. It is named after 254 * the German engineer Ernst Werner von Siemens (1816-1892). 255 */ 256 public static final AlternateUnit<ElectricConductance> SIEMENS = si(new AlternateUnit<ElectricConductance>( 257 "S", AMPERE.divide(VOLT))); 258 259 /** 260 * The derived unit for magnetic flux (<code>Wb</code>). 261 * One Weber is equal to the magnetic flux that in linking a circuit of one 262 * turn produces in it an electromotive force of one volt as it is uniformly 263 * reduced to zero within one second. It is named after the German physicist 264 * Wilhelm Eduard Weber (1804-1891). 265 */ 266 public static final AlternateUnit<MagneticFlux> WEBER = si(new AlternateUnit<MagneticFlux>( 267 "Wb", VOLT.times(SECOND))); 268 269 /** 270 * The derived unit for magnetic flux density (<code>T</code>). 271 * One Tesla is equal equal to one weber per square meter. It is named 272 * after the Serbian-born American electrical engineer and physicist 273 * Nikola Tesla (1856-1943). 274 */ 275 public static final AlternateUnit<MagneticFluxDensity> TESLA = si(new AlternateUnit<MagneticFluxDensity>( 276 "T", WEBER.divide(METRE.pow(2)))); 277 278 /** 279 * The derived unit for inductance (<code>H</code>). 280 * One Henry is equal to the inductance for which an induced electromotive 281 * force of one volt is produced when the current is varied at the rate of 282 * one ampere per second. It is named after the American physicist 283 * Joseph Henry (1791-1878). 284 */ 285 public static final AlternateUnit<ElectricInductance> HENRY = si(new AlternateUnit<ElectricInductance>( 286 "H", WEBER.divide(AMPERE))); 287 288 /** 289 * The derived unit for Celsius temperature (<code>℃</code>). 290 * This is a unit of temperature such as the freezing point of water 291 * (at one atmosphere of pressure) is 0 ℃, while the boiling point is 292 * 100 ℃. 293 */ 294 public static final Unit<Temperature> CELSIUS = si(KELVIN.plus(273.15)); 295 296 /** 297 * The derived unit for luminous flux (<code>lm</code>). 298 * One Lumen is equal to the amount of light given out through a solid angle 299 * by a source of one candela intensity radiating equally in all directions. 300 */ 301 public static final AlternateUnit<LuminousFlux> LUMEN = si(new AlternateUnit<LuminousFlux>( 302 "lm", CANDELA.times(STERADIAN))); 303 304 /** 305 * The derived unit for illuminance (<code>lx</code>). 306 * One Lux is equal to one lumen per square meter. 307 */ 308 public static final AlternateUnit<Illuminance> LUX = si(new AlternateUnit<Illuminance>( 309 "lx", LUMEN.divide(METRE.pow(2)))); 310 311 /** 312 * The derived unit for activity of a radionuclide (<code>Bq</code>). 313 * One becquerel is the radiation caused by one disintegration per second. 314 * It is named after the French physicist, Antoine-Henri Becquerel 315 * (1852-1908). 316 */ 317 public static final AlternateUnit<RadioactiveActivity> BECQUEREL = si(new AlternateUnit<RadioactiveActivity>( 318 "Bq", Unit.ONE.divide(SECOND))); 319 320 /** 321 * The derived unit for absorbed dose, specific energy (imparted), kerma 322 * (<code>Gy</code>). 323 * One gray is equal to the dose of one joule of energy absorbed per one 324 * kilogram of matter. It is named after the British physician 325 * L. H. Gray (1905-1965). 326 */ 327 public static final AlternateUnit<RadiationDoseAbsorbed> GRAY = si(new AlternateUnit<RadiationDoseAbsorbed>( 328 "Gy", JOULE.divide(KILOGRAM))); 329 330 /** 331 * The derived unit for dose equivalent (<code>Sv</code>). 332 * One Sievert is equal is equal to the actual dose, in grays, multiplied 333 * by a "quality factor" which is larger for more dangerous forms of 334 * radiation. It is named after the Swedish physicist Rolf Sievert 335 * (1898-1966). 336 */ 337 public static final AlternateUnit<RadiationDoseEffective> SIEVERT = si(new AlternateUnit<RadiationDoseEffective>( 338 "Sv", JOULE.divide(KILOGRAM))); 339 340 /** 341 * The derived unit for catalytic activity (<code>kat</code>). 342 */ 343 public static final AlternateUnit<CatalyticActivity> KATAL = si(new AlternateUnit<CatalyticActivity>( 344 "kat", MOLE.divide(SECOND))); 345 346 ////////////////////////////// 347 // SI DERIVED PRODUCT UNITS // 348 ////////////////////////////// 349 350 /** 351 * The metric unit for velocity quantities (<code>m/s</code>). 352 */ 353 public static final Unit<Velocity> METRES_PER_SECOND = si(new ProductUnit<Velocity>( 354 METRE.divide(SECOND))); 355 356 /** 357 * Equivalent to {@link #METRES_PER_SECOND}. 358 */ 359 public static final Unit<Velocity> METERS_PER_SECOND = METRES_PER_SECOND; 360 361 /** 362 * The metric unit for acceleration quantities (<code>m/s²</code>). 363 */ 364 public static final Unit<Acceleration> METRES_PER_SQUARE_SECOND = si(new ProductUnit<Acceleration>( 365 METRES_PER_SECOND.divide(SECOND))); 366 367 /** 368 * Equivalent to {@link #METRES_PER_SQUARE_SECOND}. 369 */ 370 public static final Unit<Acceleration> METERS_PER_SQUARE_SECOND = METRES_PER_SQUARE_SECOND; 371 372 /** 373 * The metric unit for area quantities (<code>m²</code>). 374 */ 375 public static final Unit<Area> SQUARE_METRE = si(new ProductUnit<Area>( 376 METRE.times(METRE))); 377 378 /** 379 * The metric unit for volume quantities (<code>m³</code>). 380 */ 381 public static final Unit<Volume> CUBIC_METRE = si(new ProductUnit<Volume>( 382 SQUARE_METRE.times(METRE))); 383 384 /** 385 * Equivalent to <code>KILO(METRE)</code>. 386 */ 387 public static final Unit<Length> KILOMETRE = METER.times(1000); 388 389 /** 390 * Equivalent to {@link #KILOMETRE}. 391 */ 392 public static final Unit<Length> KILOMETER = KILOMETRE; 393 394 /** 395 * Equivalent to <code>CENTI(METRE)</code>. 396 */ 397 public static final Unit<Length> CENTIMETRE = METRE.divide(100); 398 399 /** 400 * Equivalent to {@link #CENTIMETRE}. 401 */ 402 public static final Unit<Length> CENTIMETER = CENTIMETRE; 403 404 /** 405 * Equivalent to <code>MILLI(METRE)</code>. 406 */ 407 public static final Unit<Length> MILLIMETRE = METRE.divide(1000); 408 409 /** 410 * Equivalent to {@link #MILLIMETRE}. 411 */ 412 public static final Unit<Length> MILLIMETER = MILLIMETRE; 413 414 ///////////////// 415 // SI PREFIXES // 416 ///////////////// 417 418 /** 419 * Returns the specified unit multiplied by the factor 420 * <code>10<sup>24</sup></code> 421 * 422 * @param unit any unit. 423 * @return <code>unit.multiply(1e24)</code>. 424 */ 425 public static <Q extends Quantity> Unit<Q> YOTTA(Unit<Q> unit) { 426 return unit.transform(E24); 427 } 428 429 /** 430 * Returns the specified unit multiplied by the factor 431 * <code>10<sup>21</sup></code> 432 * 433 * @param unit any unit. 434 * @return <code>unit.multiply(1e21)</code>. 435 */ 436 public static <Q extends Quantity> Unit<Q> ZETTA(Unit<Q> unit) { 437 return unit.transform(E21); 438 } 439 440 /** 441 * Returns the specified unit multiplied by the factor 442 * <code>10<sup>18</sup></code> 443 * 444 * @param unit any unit. 445 * @return <code>unit.multiply(1e18)</code>. 446 */ 447 public static <Q extends Quantity> Unit<Q> EXA(Unit<Q> unit) { 448 return unit.transform(E18); 449 } 450 451 /** 452 * Returns the specified unit multiplied by the factor 453 * <code>10<sup>15</sup></code> 454 * 455 * @param unit any unit. 456 * @return <code>unit.multiply(1e15)</code>. 457 */ 458 public static <Q extends Quantity> Unit<Q> PETA(Unit<Q> unit) { 459 return unit.transform(E15); 460 } 461 462 /** 463 * Returns the specified unit multiplied by the factor 464 * <code>10<sup>12</sup></code> 465 * 466 * @param unit any unit. 467 * @return <code>unit.multiply(1e12)</code>. 468 */ 469 public static <Q extends Quantity> Unit<Q> TERA(Unit<Q> unit) { 470 return unit.transform(E12); 471 } 472 473 /** 474 * Returns the specified unit multiplied by the factor 475 * <code>10<sup>9</sup></code> 476 * 477 * @param unit any unit. 478 * @return <code>unit.multiply(1e9)</code>. 479 */ 480 public static <Q extends Quantity> Unit<Q> GIGA(Unit<Q> unit) { 481 return unit.transform(E9); 482 } 483 484 /** 485 * Returns the specified unit multiplied by the factor 486 * <code>10<sup>6</sup></code> 487 * 488 * @param unit any unit. 489 * @return <code>unit.multiply(1e6)</code>. 490 */ 491 public static <Q extends Quantity> Unit<Q> MEGA(Unit<Q> unit) { 492 return unit.transform(E6); 493 } 494 495 /** 496 * Returns the specified unit multiplied by the factor 497 * <code>10<sup>3</sup></code> 498 * 499 * @param unit any unit. 500 * @return <code>unit.multiply(1e3)</code>. 501 */ 502 public static <Q extends Quantity> Unit<Q> KILO(Unit<Q> unit) { 503 return unit.transform(E3); 504 } 505 506 /** 507 * Returns the specified unit multiplied by the factor 508 * <code>10<sup>2</sup></code> 509 * 510 * @param unit any unit. 511 * @return <code>unit.multiply(1e2)</code>. 512 */ 513 public static <Q extends Quantity> Unit<Q> HECTO(Unit<Q> unit) { 514 return unit.transform(E2); 515 } 516 517 /** 518 * Returns the specified unit multiplied by the factor 519 * <code>10<sup>1</sup></code> 520 * 521 * @param unit any unit. 522 * @return <code>unit.multiply(1e1)</code>. 523 */ 524 public static <Q extends Quantity> Unit<Q> DEKA(Unit<Q> unit) { 525 return unit.transform(E1); 526 } 527 528 /** 529 * Returns the specified unit multiplied by the factor 530 * <code>10<sup>-1</sup></code> 531 * 532 * @param unit any unit. 533 * @return <code>unit.multiply(1e-1)</code>. 534 */ 535 public static <Q extends Quantity> Unit<Q> DECI(Unit<Q> unit) { 536 return unit.transform(Em1); 537 } 538 539 /** 540 * Returns the specified unit multiplied by the factor 541 * <code>10<sup>-2</sup></code> 542 * 543 * @param unit any unit. 544 * @return <code>unit.multiply(1e-2)</code>. 545 */ 546 public static <Q extends Quantity> Unit<Q> CENTI(Unit<Q> unit) { 547 return unit.transform(Em2); 548 } 549 550 /** 551 * Returns the specified unit multiplied by the factor 552 * <code>10<sup>-3</sup></code> 553 * 554 * @param unit any unit. 555 * @return <code>unit.multiply(1e-3)</code>. 556 */ 557 public static <Q extends Quantity> Unit<Q> MILLI(Unit<Q> unit) { 558 return unit.transform(Em3); 559 } 560 561 /** 562 * Returns the specified unit multiplied by the factor 563 * <code>10<sup>-6</sup></code> 564 * 565 * @param unit any unit. 566 * @return <code>unit.multiply(1e-6)</code>. 567 */ 568 public static <Q extends Quantity> Unit<Q> MICRO(Unit<Q> unit) { 569 return unit.transform(Em6); 570 } 571 572 /** 573 * Returns the specified unit multiplied by the factor 574 * <code>10<sup>-9</sup></code> 575 * 576 * @param unit any unit. 577 * @return <code>unit.multiply(1e-9)</code>. 578 */ 579 public static <Q extends Quantity> Unit<Q> NANO(Unit<Q> unit) { 580 return unit.transform(Em9); 581 } 582 583 /** 584 * Returns the specified unit multiplied by the factor 585 * <code>10<sup>-12</sup></code> 586 * 587 * @param unit any unit. 588 * @return <code>unit.multiply(1e-12)</code>. 589 */ 590 public static <Q extends Quantity> Unit<Q> PICO(Unit<Q> unit) { 591 return unit.transform(Em12); 592 } 593 594 /** 595 * Returns the specified unit multiplied by the factor 596 * <code>10<sup>-15</sup></code> 597 * 598 * @param unit any unit. 599 * @return <code>unit.multiply(1e-15)</code>. 600 */ 601 public static <Q extends Quantity> Unit<Q> FEMTO(Unit<Q> unit) { 602 return unit.transform(Em15); 603 } 604 605 /** 606 * Returns the specified unit multiplied by the factor 607 * <code>10<sup>-18</sup></code> 608 * 609 * @param unit any unit. 610 * @return <code>unit.multiply(1e-18)</code>. 611 */ 612 public static <Q extends Quantity> Unit<Q> ATTO(Unit<Q> unit) { 613 return unit.transform(Em18); 614 } 615 616 /** 617 * Returns the specified unit multiplied by the factor 618 * <code>10<sup>-21</sup></code> 619 * 620 * @param unit any unit. 621 * @return <code>unit.multiply(1e-21)</code>. 622 */ 623 public static <Q extends Quantity> Unit<Q> ZEPTO(Unit<Q> unit) { 624 return unit.transform(Em21); 625 } 626 627 /** 628 * Returns the specified unit multiplied by the factor 629 * <code>10<sup>-24</sup></code> 630 * 631 * @param unit any unit. 632 * @return <code>unit.multiply(1e-24)</code>. 633 */ 634 public static <Q extends Quantity> Unit<Q> YOCTO(Unit<Q> unit) { 635 return unit.transform(Em24); 636 } 637 638 ///////////////////// 639 // Collection View // 640 ///////////////////// 641 642 /** 643 * Returns a read only view over theunits defined in this class. 644 * 645 * @return the collection of SI units. 646 */ 647 public Set<Unit<?>> getUnits() { 648 return Collections.unmodifiableSet(UNITS); 649 } 650 651 /** 652 * Adds a new unit to the collection. 653 * 654 * @param unit the unit being added. 655 * @return <code>unit</code>. 656 */ 657 private static <U extends Unit<?>> U si(U unit) { 658 UNITS.add(unit); 659 return unit; 660 } 661 662 // Holds prefix converters (optimization). 663 664 static final MultiplyConverter E24 = new MultiplyConverter(1E24); 665 666 static final MultiplyConverter E21 = new MultiplyConverter(1E21); 667 668 static final RationalConverter E18 = new RationalConverter( 669 1000000000000000000L, 1); 670 671 static final RationalConverter E15 = new RationalConverter( 672 1000000000000000L, 1); 673 674 static final RationalConverter E12 = new RationalConverter(1000000000000L, 675 1); 676 677 static final RationalConverter E9 = new RationalConverter(1000000000L, 1); 678 679 static final RationalConverter E6 = new RationalConverter(1000000L, 1); 680 681 static final RationalConverter E3 = new RationalConverter(1000L, 1); 682 683 static final RationalConverter E2 = new RationalConverter(100L, 1); 684 685 static final RationalConverter E1 = new RationalConverter(10L, 1); 686 687 static final RationalConverter Em1 = new RationalConverter(1, 10L); 688 689 static final RationalConverter Em2 = new RationalConverter(1, 100L); 690 691 static final RationalConverter Em3 = new RationalConverter(1, 1000L); 692 693 static final RationalConverter Em6 = new RationalConverter(1, 1000000L); 694 695 static final RationalConverter Em9 = new RationalConverter(1, 1000000000L); 696 697 static final RationalConverter Em12 = new RationalConverter(1, 698 1000000000000L); 699 700 static final RationalConverter Em15 = new RationalConverter(1, 701 1000000000000000L); 702 703 static final RationalConverter Em18 = new RationalConverter(1, 704 1000000000000000000L); 705 706 static final MultiplyConverter Em21 = new MultiplyConverter(1E-21); 707 708 static final MultiplyConverter Em24 = new MultiplyConverter(1E-24); 709 710 /** 711 * @deprecated replaced by {@link #METRES_PER_SECOND}. 712 */ 713 public static final Unit<Velocity> METRE_PER_SECOND = METRES_PER_SECOND; 714 715 /** 716 * @deprecated replaced by {@link #METRES_PER_SQUARE_SECOND}. 717 */ 718 public static final Unit<Acceleration> METRE_PER_SQUARE_SECOND = METRES_PER_SQUARE_SECOND; 719}