Package com.hazelcast.memory
Class MemorySize
java.lang.Object
com.hazelcast.memory.MemorySize
public final class MemorySize extends Object
MemorySize represents a memory size with given value and
MemoryUnit
.- Since:
- 3.4
- See Also:
MemoryUnit
-
Constructor Summary
Constructors Constructor Description MemorySize(long value)
MemorySize(long value, MemoryUnit unit)
-
Method Summary
Modifier and Type Method Description long
bytes()
Returns value of memory size in bytes.boolean
equals(Object o)
MemoryUnit
getUnit()
Returns unit of memory sizelong
getValue()
Returns value of memory size in its original unit.long
gigaBytes()
Returns value of memory size in giga-bytes.int
hashCode()
long
kiloBytes()
Returns value of memory size in kilo-bytes.long
megaBytes()
Returns value of memory size in mega-bytes.static MemorySize
parse(String value)
Parses string representation of a memory size value.static MemorySize
parse(String value, MemoryUnit defaultUnit)
Parses string representation of a memory size value.String
toPrettyString()
Returns a pretty format String representation of this memory size.static String
toPrettyString(long size)
Utility method to create a pretty format representation of given value in bytes.static String
toPrettyString(long size, MemoryUnit unit)
Utility method to create a pretty format representation of given value in given unit.String
toString()
-
Constructor Details
-
MemorySize
public MemorySize(long value) -
MemorySize
-
-
Method Details
-
getValue
public long getValue()Returns value of memory size in its original unit.- Returns:
- memory size in its original unit
-
getUnit
Returns unit of memory size- Returns:
- unit of memory size
-
bytes
public long bytes()Returns value of memory size in bytes.- Returns:
- memory size in bytes
-
kiloBytes
public long kiloBytes()Returns value of memory size in kilo-bytes.- Returns:
- memory size in kilo-bytes
-
megaBytes
public long megaBytes()Returns value of memory size in mega-bytes.- Returns:
- memory size in mega-bytes
-
gigaBytes
public long gigaBytes()Returns value of memory size in giga-bytes.- Returns:
- memory size in giga-bytes
-
parse
Parses string representation of a memory size value. Value may end with one of suffixes;- 'k' or 'K' for 'kilo',
- 'm' or 'M' for 'mega',
- 'g' or 'G' for 'giga'.
Default unit is bytes.
Examples: 12345, 12345m, 12345K, 123456G
-
parse
Parses string representation of a memory size value. Value may end with one of suffixes;- 'k' or 'K' for 'kilo',
- 'm' or 'M' for 'mega',
- 'g' or 'G' for 'giga'.
Uses default unit if value does not contain unit information.
Examples: 12345, 12345m, 12345K, 123456G
-
toPrettyString
Returns a pretty format String representation of this memory size.- Returns:
- a pretty format representation of this memory size
-
toString
-
toPrettyString
Utility method to create a pretty format representation of given value in bytes.- Parameters:
size
- size in bytes- Returns:
- pretty format representation of given value
-
toPrettyString
Utility method to create a pretty format representation of given value in given unit.- Parameters:
size
- memory sizeunit
- memory unit- Returns:
- pretty format representation of given value
-
equals
-
hashCode
public int hashCode()
-