Package javax.measure

Enum BinaryPrefix

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

    public enum BinaryPrefix
    extends java.lang.Enum<BinaryPrefix>
    implements Prefix
    Provides support for common binary prefixes to be used by units. For example:
     import static systems.uom.unicode.CLDR.*;  // Static import (from Unicode System).
     import static javax.measure.BinaryPrefix.*; // Static import.
     import javax.measure.*;
     import systems.uom.quantity.Information; // (from Systems Quantities)
     ...
     Unit<Information> MEBIT  = MEBI(BIT);
     Unit<Information> GIBYTE = GIBI(BYTE); 
     
    You could also apply Unit.prefix:
     ...
     Unit<Information> MEBIT  = BIT.prefix(MEBI);
     Unit<Information> GIBYTE = BYTE.prefix(GIBI);
     

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

    Implementation Requirements
    This is an immutable and thread-safe enum.
    Since:
    2.0
    Version:
    2.2, May 20, 2023
    Author:
    Werner Keil
    See Also:
    Wikipedia: Binary Prefix
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      EXBI
      Prefix for 10246.
      GIBI
      Prefix for 10243.
      KIBI
      Prefix for 1024.
      MEBI
      Prefix for 10242.
      PEBI
      Prefix for 10245.
      TEBI
      Prefix for 10244.
      YOBI
      Prefix for 10248.
      ZEBI
      Prefix for 10247.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <Q extends Quantity<Q>>
      Unit<Q>
      EXBI​(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10246 (binary prefix).
      int getExponent()
      Exponent part of the associated factor in base^exponent representation.
      java.lang.String getName()
      Returns the name of this prefix.
      java.lang.String getSymbol()
      Returns the symbol of this prefix.
      java.lang.Integer getValue()
      Base part of the associated factor in base^exponent representation.
      static <Q extends Quantity<Q>>
      Unit<Q>
      GIBI​(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10243 (binary prefix).
      static <Q extends Quantity<Q>>
      Unit<Q>
      KIBI​(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1024 (binary prefix).
      static <Q extends Quantity<Q>>
      Unit<Q>
      MEBI​(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10242 (binary prefix).
      static <Q extends Quantity<Q>>
      Unit<Q>
      PEBI​(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10245 (binary prefix).
      static <Q extends Quantity<Q>>
      Unit<Q>
      TEBI​(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10244 (binary prefix).
      static BinaryPrefix valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static BinaryPrefix[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      static <Q extends Quantity<Q>>
      Unit<Q>
      YOBI​(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10248 (binary prefix).
      static <Q extends Quantity<Q>>
      Unit<Q>
      ZEBI​(Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10247 (binary prefix).
      • 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
    • Method Detail

      • values

        public static BinaryPrefix[] 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 (BinaryPrefix c : BinaryPrefix.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static BinaryPrefix 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
      • KIBI

        public static <Q extends Quantity<Q>> Unit<Q> KIBI​(Unit<Q> unit)
        Returns the specified unit multiplied by the factor 1024 (binary prefix).
        Type Parameters:
        Q - type of the quantity measured by the unit.
        Parameters:
        unit - any unit.
        Returns:
        unit.multiply(1024).
      • MEBI

        public static <Q extends Quantity<Q>> Unit<Q> MEBI​(Unit<Q> unit)
        Returns the specified unit multiplied by the factor 10242 (binary prefix).
        Type Parameters:
        Q - type of the quantity measured by the unit.
        Parameters:
        unit - any unit.
        Returns:
        unit.multiply(1048576).
      • GIBI

        public static <Q extends Quantity<Q>> Unit<Q> GIBI​(Unit<Q> unit)
        Returns the specified unit multiplied by the factor 10243 (binary prefix).
        Type Parameters:
        Q - type of the quantity measured by the unit.
        Parameters:
        unit - any unit.
        Returns:
        unit.multiply(1073741824).
      • TEBI

        public static <Q extends Quantity<Q>> Unit<Q> TEBI​(Unit<Q> unit)
        Returns the specified unit multiplied by the factor 10244 (binary prefix).
        Type Parameters:
        Q - type of the quantity measured by the unit.
        Parameters:
        unit - any unit.
        Returns:
        unit.multiply(1099511627776L).
      • PEBI

        public static <Q extends Quantity<Q>> Unit<Q> PEBI​(Unit<Q> unit)
        Returns the specified unit multiplied by the factor 10245 (binary prefix).
        Type Parameters:
        Q - type of the quantity measured by the unit.
        Parameters:
        unit - any unit.
        Returns:
        unit.multiply(1125899906842624L).
      • EXBI

        public static <Q extends Quantity<Q>> Unit<Q> EXBI​(Unit<Q> unit)
        Returns the specified unit multiplied by the factor 10246 (binary prefix).
        Type Parameters:
        Q - type of the quantity measured by the unit.
        Parameters:
        unit - any unit.
        Returns:
        unit.multiply(1152921504606846976L).
      • ZEBI

        public static <Q extends Quantity<Q>> Unit<Q> ZEBI​(Unit<Q> unit)
        Returns the specified unit multiplied by the factor 10247 (binary prefix).
        Type Parameters:
        Q - type of the quantity measured by the unit.
        Parameters:
        unit - any unit.
        Returns:
        unit.multiply(1152921504606846976d).
      • YOBI

        public static <Q extends Quantity<Q>> Unit<Q> YOBI​(Unit<Q> unit)
        Returns the specified unit multiplied by the factor 10248 (binary prefix).
        Type Parameters:
        Q - type of the quantity measured by the unit.
        Parameters:
        unit - any unit.
        Returns:
        unit.multiply(1208925819614629174706176d).
      • getSymbol

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

        public java.lang.Integer getValue()
        Base part of the associated factor in base^exponent representation. For binary prefix, this is always 1024.
        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 java.lang.String getName()
        Returns the name of this prefix.
        Specified by:
        getName in interface Prefix
        Returns:
        this prefix name, not null.