public final class MemorySize extends Object
MemoryUnit
.MemoryUnit
Constructor and Description |
---|
MemorySize(long value) |
MemorySize(long value,
MemoryUnit unit) |
Modifier and Type | Method and Description |
---|---|
long |
bytes()
Returns value of memory size in bytes.
|
boolean |
equals(Object o) |
MemoryUnit |
getUnit()
Returns unit of memory size
|
long |
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.
|
static MemorySize |
parseMemorySize(String memorySize)
Parses string representation of a memory size.
|
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() |
public MemorySize(long value)
public MemorySize(long value, MemoryUnit unit)
public long getValue()
public MemoryUnit getUnit()
public long bytes()
public long kiloBytes()
public long megaBytes()
public long gigaBytes()
public static MemorySize parse(String value)
Default unit is bytes.
Examples: 12345, 12345m, 12345K, 123456G
public static MemorySize parse(String value, MemoryUnit defaultUnit)
Uses default unit if value does not contain unit information.
Examples: 12345, 12345m, 12345K, 123456G
public static MemorySize parseMemorySize(String memorySize)
^[1-9]([0-9]*) (B|KB|MB|GB)$
.
Ex, "8192 MB", "1 GB" are valid inputs, while "01 MB", "2.2 GB" are not.
This method expects a well-formed input and does not do any kind of input validation.memorySize
- memory size.public String toPrettyString()
public static String toPrettyString(long size)
size
- size in bytespublic static String toPrettyString(long size, MemoryUnit unit)
size
- memory sizeunit
- memory unitCopyright © 2022 Hazelcast, Inc.. All rights reserved.