Enum MemoryUnit

  • All Implemented Interfaces:
    Serializable, Comparable<MemoryUnit>, java.lang.constant.Constable

    public enum MemoryUnit
    extends Enum<MemoryUnit>
    A collection of useful methods to deal with memory units.

    The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable unit of memory in many computer architectures. The international standard IEC 80000-13 codified this common meaning. The popularity of major commercial computing architectures has aided in the ubiquitous acceptance of the 8-bit size.
    Since:
    2.0.0
    Author:
    Mohammed Shaik Hussain Ali
    See Also:
    Byte (Wikipedia), IEC 80000-13 (Wikipedia)
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      EXBI_BYTE
      The exbibyte is a multiple of the unit byte for digital information.
      GIBI_BYTE
      The gibibyte is a multiple of the unit byte for digital information.
      KIBI_BYTE
      The kibibyte is a multiple of the unit byte for digital information.
      MEBI_BYTE
      The mebibyte is a multiple of the unit byte for digital information.
      PEBI_BYTE
      The pebibyte is a multiple of the unit byte for digital information.
      TEBI_BYTE
      The tebibyte is a multiple of the unit byte for digital information.
      YOBI_BYTE
      The yobibyte is a multiple of the unit byte for digital information.
      ZEBI_BYTE
      The zebibyte is a multiple of the unit byte for digital information.
    • Enum Constant Detail

      • KIBI_BYTE

        public static final MemoryUnit KIBI_BYTE
        The kibibyte is a multiple of the unit byte for digital information. It is a member of the set of units with binary prefixes defined by the International Electrotechnical Commission (IEC). Its unit symbol is KiB.

        1 Kibibyte = 1024 Bytes
        Since:
        2.0.0
        See Also:
        Kibibyte (Wikipedia)
      • MEBI_BYTE

        public static final MemoryUnit MEBI_BYTE
        The mebibyte is a multiple of the unit byte for digital information. It is a member of the set of units with binary prefixes defined by the International Electrotechnical Commission (IEC). Its unit symbol is MiB.

        1 Mebibyte = 1024 Kibibytes
        Since:
        2.0.0
        See Also:
        Mebibyte (Wikipedia)
      • GIBI_BYTE

        public static final MemoryUnit GIBI_BYTE
        The gibibyte is a multiple of the unit byte for digital information. It is a member of the set of units with binary prefixes defined by the International Electrotechnical Commission (IEC). Its unit symbol is GiB.

        1 Gibibyte = 1024 Mebibytes
        Since:
        2.0.0
        See Also:
        Gibibyte (Wikipedia)
      • TEBI_BYTE

        public static final MemoryUnit TEBI_BYTE
        The tebibyte is a multiple of the unit byte for digital information. It is a member of the set of units with binary prefixes defined by the International Electrotechnical Commission (IEC). Its unit symbol is TiB.

        1 Tebibyte = 1024 Gibibytes
        Since:
        2.0.0
        See Also:
        Tebibyte (Wikipedia)
      • PEBI_BYTE

        public static final MemoryUnit PEBI_BYTE
        The pebibyte is a multiple of the unit byte for digital information. It is a member of the set of units with binary prefixes defined by the International Electrotechnical Commission (IEC). Its unit symbol is PiB.

        1 Pebibyte = 1024 Tebibytes
        Since:
        2.0.0
        See Also:
        Pebibyte (Wikipedia)
      • EXBI_BYTE

        public static final MemoryUnit EXBI_BYTE
        The exbibyte is a multiple of the unit byte for digital information. It is a member of the set of units with binary prefixes defined by the International Electrotechnical Commission (IEC). Its unit symbol is EiB.

        1 Exbibyte = 1024 Pebibytes
        Since:
        2.0.0
        See Also:
        Exbibyte (Wikipedia)
      • ZEBI_BYTE

        public static final MemoryUnit ZEBI_BYTE
        The zebibyte is a multiple of the unit byte for digital information. It is a member of the set of units with binary prefixes defined by the International Electrotechnical Commission (IEC). Its unit symbol is ZiB.

        1 Zebibyte = 1024 Exbibytes
        Since:
        2.0.0
        See Also:
        Zebibyte (Wikipedia)
      • YOBI_BYTE

        public static final MemoryUnit YOBI_BYTE
        The yobibyte is a multiple of the unit byte for digital information. It is a member of the set of units with binary prefixes defined by the International Electrotechnical Commission (IEC). Its unit symbol is YiB.

        1 Yobibyte = 1024 Zebibytes
        Since:
        2.0.0
        See Also:
        Yobibyte (Wikipedia)
    • Method Detail

      • values

        public static MemoryUnit[] 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 MemoryUnit 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
      • getByteValue

        public double getByteValue()
        Returns the number of bytes in the unit.
        Returns:
        Number of bytes in the unit.
        Since:
        2.0.0
      • extract

        public static MemoryUnit extract​(double value)
        Extracts the closest equivalent in Bytes.

        Note: The smallest unit returned is KIBI_BYTE
        Parameters:
        value - for which the byte equivalent is to be extracted
        Returns:
        Closest byte equivalent of the provided number
        Throws:
        IllegalArgumentException - when a negative number is passed
        Since:
        2.0.0