@PublicEvolving public class MemorySize extends Object implements Serializable
The size can be parsed from a text expression. If the expression is a pure number, the value will be interpreted as bytes.
Modifier and Type | Class and Description |
---|---|
static class |
MemorySize.MemoryUnit
Enum which defines memory unit, mostly used to parse value from configuration file.
|
Constructor and Description |
---|
MemorySize(long bytes)
Constructs a new MemorySize.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
long |
getBytes()
Gets the memory size in bytes.
|
long |
getGibiBytes()
Gets the memory size in Gibibytes (= 1024 Mebibytes).
|
long |
getKibiBytes()
Gets the memory size in Kibibytes (= 1024 bytes).
|
int |
getMebiBytes()
Gets the memory size in Mebibytes (= 1024 Kibibytes).
|
long |
getTebiBytes()
Gets the memory size in Tebibytes (= 1024 Gibibytes).
|
int |
hashCode() |
static MemorySize |
parse(String text)
Parses the given string as as MemorySize.
|
static MemorySize |
parse(String text,
MemorySize.MemoryUnit defaultUnit)
Parses the given string with a default unit.
|
static long |
parseBytes(String text)
Parses the given string as bytes.
|
String |
toString() |
public MemorySize(long bytes)
bytes
- The size, in bytes. Must be zero or larger.public long getBytes()
public long getKibiBytes()
public int getMebiBytes()
public long getGibiBytes()
public long getTebiBytes()
public static MemorySize parse(String text) throws IllegalArgumentException
text
- The string to parseIllegalArgumentException
- Thrown, if the expression cannot be parsed.public static MemorySize parse(String text, MemorySize.MemoryUnit defaultUnit) throws IllegalArgumentException
text
- The string to parse.defaultUnit
- specify the default unit.IllegalArgumentException
- Thrown, if the expression cannot be parsed.public static long parseBytes(String text) throws IllegalArgumentException
MemorySize
.text
- The string to parseIllegalArgumentException
- Thrown, if the expression cannot be parsed.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.