Package javax.measure

Enum MetricPrefix

java.lang.Object
java.lang.Enum<MetricPrefix>
javax.measure.MetricPrefix
All Implemented Interfaces:
Serializable, Comparable<MetricPrefix>, java.lang.constant.Constable, Prefix

public enum MetricPrefix extends Enum<MetricPrefix> implements Prefix
Provides support for the 24 prefixes used in the metric system (decimal multiples and submultiples of units). For example:
 import static tech.units.indriya.unit.Units.*;  // Static import (from the RI).
 import static javax.measure.MetricPrefix.*; // Static import.
 import javax.measure.*;
 import javax.measure.quantity.*;
 ...
 Unit<Pressure> HECTOPASCAL = HECTO(PASCAL);
 Unit<Length> KILOMETRE = KILO(METRE); 
 
You could also apply Unit.prefix:
 ...
 Unit<Pressure> HECTOPASCAL = PASCAL.prefix(HECTO);
 Unit<Length> KILOMETRE = METRE.prefix(KILO);
 

Do not use ordinal() to obtain the numeric representation of MetricPrefix. Use getValue() and getExponent() instead.

Implementation Requirements
This is an immutable and thread-safe enum.
Since:
2.0
Version:
2.3, May 20, 2023
Author:
Jean-Marie Dautelle, Werner Keil
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Prefix for 10-18.
    Prefix for 10-2.
    Prefix for 101.
    Prefix for 10-1.
    Prefix for 1018.
    Prefix for 10-15.
    Prefix for 109.
    Prefix for 102.
    Prefix for 103.
    Prefix for 106.
    Prefix for 10-6.
    Prefix for 10-3.
    Prefix for 10-9.
    Prefix for 1015.
    Prefix for 10-12.
    Prefix for 10-30.
    Prefix for 1030.
    Prefix for 1027.
    Prefix for 10-27.
    Prefix for 1012.
    Prefix for 10-24.
    Prefix for 1024.
    Prefix for 10-21.
    Prefix for 1021.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <Q extends Quantity<Q>>
    Unit<Q>
    ATTO(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-18
    static <Q extends Quantity<Q>>
    Unit<Q>
    CENTI(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-2
    static <Q extends Quantity<Q>>
    Unit<Q>
    DECA(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 101
    static <Q extends Quantity<Q>>
    Unit<Q>
    DECI(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-1
    static <Q extends Quantity<Q>>
    Unit<Q>
    DEKA(Unit<Q> unit)
    US alias for DECA.
    static <Q extends Quantity<Q>>
    Unit<Q>
    EXA(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 1018
    static <Q extends Quantity<Q>>
    Unit<Q>
    FEMTO(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-15
    int
    Exponent part of the associated factor in base^exponent representation.
    Returns the name of this prefix.
    Returns the symbol of this prefix.
    Base part of the associated factor in base^exponent representation.
    static <Q extends Quantity<Q>>
    Unit<Q>
    GIGA(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 109
    static <Q extends Quantity<Q>>
    Unit<Q>
    HECTO(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 102
    static <Q extends Quantity<Q>>
    Unit<Q>
    KILO(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 103
    static <Q extends Quantity<Q>>
    Unit<Q>
    MEGA(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 106
    static <Q extends Quantity<Q>>
    Unit<Q>
    MICRO(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-6
    static <Q extends Quantity<Q>>
    Unit<Q>
    MILLI(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-3
    static <Q extends Quantity<Q>>
    Unit<Q>
    NANO(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-9
    static <Q extends Quantity<Q>>
    Unit<Q>
    PETA(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 1015
    static <Q extends Quantity<Q>>
    Unit<Q>
    PICO(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-12
    static <Q extends Quantity<Q>>
    Unit<Q>
    QUECTO(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-30
    static <Q extends Quantity<Q>>
    Unit<Q>
    QUETTA(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 1030
    static <Q extends Quantity<Q>>
    Unit<Q>
    RONNA(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 1027
    static <Q extends Quantity<Q>>
    Unit<Q>
    RONTO(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-27
    static <Q extends Quantity<Q>>
    Unit<Q>
    TERA(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 1012
    Returns the enum constant of this type with the specified name.
    static MetricPrefix[]
    Returns an array containing the constants of this enum type, in the order they are declared.
    static <Q extends Quantity<Q>>
    Unit<Q>
    YOCTO(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-24
    static <Q extends Quantity<Q>>
    Unit<Q>
    YOTTA(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 1024
    static <Q extends Quantity<Q>>
    Unit<Q>
    ZEPTO(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 10-21
    static <Q extends Quantity<Q>>
    Unit<Q>
    ZETTA(Unit<Q> unit)
    Returns the specified unit multiplied by the factor 1021

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

  • Method Details

    • values

      public static MetricPrefix[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static MetricPrefix valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • QUETTA

      public static <Q extends Quantity<Q>> Unit<Q> QUETTA(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1030
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e30).
      See Also:
    • RONNA

      public static <Q extends Quantity<Q>> Unit<Q> RONNA(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1027
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e27).
      See Also:
    • YOTTA

      public static <Q extends Quantity<Q>> Unit<Q> YOTTA(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1024
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e24).
      See Also:
    • ZETTA

      public static <Q extends Quantity<Q>> Unit<Q> ZETTA(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1021
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e21).
      See Also:
    • EXA

      public static <Q extends Quantity<Q>> Unit<Q> EXA(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1018
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e18).
      See Also:
    • PETA

      public static <Q extends Quantity<Q>> Unit<Q> PETA(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1015
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e15).
      See Also:
    • TERA

      public static <Q extends Quantity<Q>> Unit<Q> TERA(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1012
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e12).
      See Also:
    • GIGA

      public static <Q extends Quantity<Q>> Unit<Q> GIGA(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 109
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e9).
      See Also:
    • MEGA

      public static <Q extends Quantity<Q>> Unit<Q> MEGA(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 106
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e6).
      See Also:
    • KILO

      public static <Q extends Quantity<Q>> Unit<Q> KILO(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 103
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e3).
      See Also:
    • HECTO

      public static <Q extends Quantity<Q>> Unit<Q> HECTO(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 102
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e2).
      See Also:
    • DECA

      public static <Q extends Quantity<Q>> Unit<Q> DECA(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 101
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e1).
      See Also:
    • DEKA

      public static <Q extends Quantity<Q>> Unit<Q> DEKA(Unit<Q> unit)
      US alias for DECA.
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e1).
      See Also:
    • DECI

      public static <Q extends Quantity<Q>> Unit<Q> DECI(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-1
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-1).
      See Also:
    • CENTI

      public static <Q extends Quantity<Q>> Unit<Q> CENTI(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-2
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-2).
      See Also:
    • MILLI

      public static <Q extends Quantity<Q>> Unit<Q> MILLI(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-3
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-3).
      See Also:
    • MICRO

      public static <Q extends Quantity<Q>> Unit<Q> MICRO(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-6
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-6).
      See Also:
    • NANO

      public static <Q extends Quantity<Q>> Unit<Q> NANO(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-9
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-9).
      See Also:
    • PICO

      public static <Q extends Quantity<Q>> Unit<Q> PICO(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-12
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-12).
      See Also:
    • FEMTO

      public static <Q extends Quantity<Q>> Unit<Q> FEMTO(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-15
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-15).
      See Also:
    • ATTO

      public static <Q extends Quantity<Q>> Unit<Q> ATTO(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-18
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-18).
      See Also:
    • ZEPTO

      public static <Q extends Quantity<Q>> Unit<Q> ZEPTO(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-21
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-21). #see ZEPTO
    • YOCTO

      public static <Q extends Quantity<Q>> Unit<Q> YOCTO(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-24
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-24).
      See Also:
    • RONTO

      public static <Q extends Quantity<Q>> Unit<Q> RONTO(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-27
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-27).
      See Also:
    • QUECTO

      public static <Q extends Quantity<Q>> Unit<Q> QUECTO(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-30
      Type Parameters:
      Q - type of the quantity measured by the unit.
      Parameters:
      unit - any unit.
      Returns:
      unit.times(1e-30).
      See Also:
    • getSymbol

      public String getSymbol()
      Returns the symbol of this prefix.
      Specified by:
      getSymbol in interface Prefix
      Returns:
      this prefix symbol, not null.
    • getValue

      public Integer getValue()
      Base part of the associated factor in base^exponent representation. For metric prefix, this is always 10.
      Specified by:
      getValue in interface Prefix
      Returns:
      The prefix value.
    • getExponent

      public int getExponent()
      Exponent part of the associated factor in base^exponent representation.
      Specified by:
      getExponent in interface Prefix
      Returns:
      the exponent part of this prefix.
    • getName

      public String getName()
      Returns the name of this prefix.
      Specified by:
      getName in interface Prefix
      Returns:
      this prefix name, not null.