Enum MemoryUnit

    • Method Detail

      • values

        public static MemoryUnit[] 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 (MemoryUnit c : MemoryUnit.values())
            System.out.println(c);
        
        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
      • getUnit

        public String getUnit()
        Returns the name of the memory unit, e.g. "KB" for kilobyte or "MB" for megabyte.
        Returns:
        The name (abbreviation) of the unit.
      • getBytes

        public BigDecimal getBytes()
        Returns the number of bytes representing a unit, e.g. 1024 for KILOBYTE.
        Returns:
        The number of bytes per unit.
      • toBytes

        public BigDecimal toBytes​(double aUnitValue)
        Calculates the number of bytes for the given value provided for the according MemoryUnit.
        Parameters:
        aUnitValue - The value to be converted.
        Returns:
        The converted value in bytes.
      • toBytes

        public BigDecimal toBytes​(BigDecimal aUnitValue)
        Calculates the number of bytes for the given value provided for the according MemoryUnit.
        Parameters:
        aUnitValue - The value to be converted.
        Returns:
        The converted value in bytes.
      • toBytes

        public BigDecimal toBytes​(long aUnitValue)
        Calculates the number of bytes for the given value provided for the according MemoryUnit.
        Parameters:
        aUnitValue - The value to be converted.
        Returns:
        The converted value in bytes.
      • fromBytes

        public BigDecimal fromBytes​(long aBytes)
        Calculates the number of bytes for the given value provided for the according MemoryUnit.
        Parameters:
        aBytes - the bytes
        Returns:
        The converted value in bytes.
      • fromBytes

        public BigDecimal fromBytes​(BigDecimal aBytes)
        Calculates the number of bytes for the given value provided for the according MemoryUnit.
        Parameters:
        aBytes - the bytes
        Returns:
        The converted value in bytes.
      • toSuitableUnit

        public static MemoryUnit toSuitableUnit​(long aBytes)
        Determines the best fitting unit to represent the given number of bytes in terms of "which memory unit is the biggest memory unit of which one unit is smaller than the given amount of bytes".
        Parameters:
        aBytes - The number of bytes for which to determine the most suitable MemoryUnit
        Returns:
        The according MemoryUnit;
      • toSuitableUnit

        public static MemoryUnit toSuitableUnit​(BigDecimal aBytes)
        Determines the best fitting unit to represent the given number of bytes in terms of "which memory unit is the biggest memory unit of which one unit is smaller than the given amount of bytes".
        Parameters:
        aBytes - The number of bytes for which to determine the most suitable MemoryUnit
        Returns:
        The according MemoryUnit;