Enum BinaryPrefix

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

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

    This class provides support for common binary prefixes to be used by units.

    Since:
    2.0
    Version:
    1.3, April 20, 2018
    See Also:
    Wikipedia: Binary 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 BinaryPrefix​(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>
      EXBI​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10246 (binary prefix).
      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>
      GIBI​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10243 (binary prefix).
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      KIBI​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 1024 (binary prefix).
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      MEBI​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10242 (binary prefix).
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      PEBI​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10245 (binary prefix).
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      TEBI​(javax.measure.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 javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      YOBI​(javax.measure.Unit<Q> unit)
      Returns the specified unit multiplied by the factor 10248 (binary prefix).
      static <Q extends javax.measure.Quantity<Q>>
      javax.measure.Unit<Q>
      ZEBI​(javax.measure.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
    • 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

      • BinaryPrefix

        private BinaryPrefix​(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 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 javax.measure.Quantity<Q>> javax.measure.Unit<Q> KIBI​(javax.measure.Unit<Q> unit)
        Returns the specified unit multiplied by the factor 1024 (binary prefix).
        Parameters:
        unit - any unit.
        Returns:
        unit.multiply(1024).
      • MEBI

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

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

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

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

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

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

        public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> YOBI​(javax.measure.Unit<Q> unit)
        Returns the specified unit multiplied by the factor 10248 (binary prefix).
        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.
      • 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