Enum Class MemoryUtils
- All Implemented Interfaces:
Serializable,Comparable<MemoryUtils>,Constable
Util class that contains methods to convert memory units of measure.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatMemory(long bytes) Formats the given bytes amount usinggetDisplayedUnit()and truncating to the decimals places specified at "settings.displayed-memory.decimals" inConfigurationType.CONFIG.static StringformatMemory(long bytes, MemoryUtils scale) Formats the given bytes amount using the specified scale.static MemoryUtilsGets the default displayed memory unit.intGets this unit's to bytes ratio.getUnit()Gets this unit's string representation.static MemoryUtilsReturns the enum constant of this class with the specified name.static MemoryUtils[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
TERABYTE
Represents a terabyte (1024 * 1024 * 1024 * 1024 bytes). -
GIGABYTE
Represents a gigabyte (1024 * 1024 * 1024 bytes). -
MEGABYTE
Represents a megabyte (1024 * 1024 bytes). -
KILOBYTE
Represents a kilobyte (1024 bytes). -
BYTE
Represents a byte.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null
-
getToBytesRatio
public int getToBytesRatio()Gets this unit's to bytes ratio.- Returns:
- To bytes ratio
-
getUnit
Gets this unit's string representation.Example:
MEGABYTE➝ "MB"- Returns:
- Unit's string representation
-
getDisplayedUnit
Gets the default displayed memory unit.Found at: "settings.displayed-memory.unit" in
ConfigurationType.CONFIG- Returns:
- Displayed memory unit
-
formatMemory
Formats the given bytes amount usinggetDisplayedUnit()and truncating to the decimals places specified at "settings.displayed-memory.decimals" inConfigurationType.CONFIG.- Parameters:
bytes- Bytes amount- Returns:
- Formatted memory
-
formatMemory
Formats the given bytes amount using the specified scale.- Parameters:
bytes- Bytes amountscale- Scale to use- Returns:
- Formatted memory
-