Enum MetricPrefix

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<MetricPrefix>, Prefix

    public enum MetricPrefix
    extends java.lang.Enum<MetricPrefix>
    implements Prefix

    This class provides support for the 20 prefixes used in the metric system (decimal multiples and submultiples of units). For example:

     
         import static tech.units.indriya.unit.Units.*;  // Static import.
         import static tech.units.indriya.unit.MetricPrefix.*; // Static import.
         import javax.measure.*;
         import javax.measure.quantity.*;
         ...
         Unit HECTOPASCAL = HECTO(PASCAL);
         Unit KILOMETRE = KILO(METRE);
         
     

    Since:
    2.0
    Version:
    1.8, 2018-04-20
    See Also:
    Wikipedia: Metric Prefix
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int base
      Base part of the associated factor in base^exponent representation.
      private int exponent
      Exponent part of the associated factor in base^exponent representation.
      private java.lang.String symbol
      The symbol of this prefix, as returned by getSymbol().
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private MetricPrefix​(java.lang.String symbol, int base, int exponent)
      Creates a new prefix.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      ATTO​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-18
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      CENTI​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-2
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      DECI​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-1
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      DEKA​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 101
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      EXA​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1018
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      FEMTO​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-15
      int getBase()
      Base part of the associated factor in base^exponent representation.
      int getExponent()
      Exponent part of the associated factor in base^exponent representation.
      java.lang.String getSymbol()
      Returns the symbol of this prefix.
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      GIGA​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 109
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      HECTO​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 102
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      KILO​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 103
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      MEGA​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 106
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      MICRO​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-6
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      MILLI​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-3
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      NANO​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-9
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      PETA​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1015
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      PICO​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-12
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      TERA​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1012
      static MetricPrefix valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static MetricPrefix[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      YOCTO​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-24
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      YOTTA​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1024
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      ZEPTO​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10-21
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      ZETTA​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1021
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • symbol

        private final java.lang.String symbol
        The symbol of this prefix, as returned by getSymbol().
        See Also:
        getSymbol()
      • base

        private int base
        Base part of the associated factor in base^exponent representation.
      • exponent

        private int exponent
        Exponent part of the associated factor in base^exponent representation.
    • Constructor Detail

      • MetricPrefix

        private MetricPrefix​(java.lang.String symbol,
                             int base,
                             int exponent)
        Creates a new prefix.
        Parameters:
        symbol - the symbol of this prefix.
        base - part of the associated factor in base^exponent representation.
        exponent - part of the associated factor in base^exponent representation.
    • Method Detail

      • values

        public static MetricPrefix[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (MetricPrefix c : MetricPrefix.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static MetricPrefix valueOf​(java.lang.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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • YOTTA

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        public int getBase()
        Base part of the associated factor in base^exponent representation.
        Specified by:
        getBase in interface Prefix
      • getExponent

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