public class Capacity extends Object
MemoryUnit
.
This class is immutable.MemoryUnit
Constructor and Description |
---|
Capacity(long value) |
Capacity(long value,
MemoryUnit unit) |
Modifier and Type | Method and Description |
---|---|
long |
bytes()
Returns value of the capacity in bytes.
|
boolean |
equals(Object o) |
MemoryUnit |
getUnit()
Returns unit of the capacity
|
long |
getValue()
Returns value of the capacity in its original unit.
|
long |
gigaBytes()
Returns value of the capacity in giga-bytes.
|
int |
hashCode() |
long |
kiloBytes()
Returns value of the capacity in kilo-bytes.
|
long |
megaBytes()
Returns value of the capacity in mega-bytes.
|
static Capacity |
of(long value,
MemoryUnit unit)
Returns an instance of
Capacity . |
static Capacity |
parse(String value)
Parses string representation of a capacity.
|
static Capacity |
parse(String value,
MemoryUnit defaultUnit)
Parses string representation of a capacity.
|
String |
toPrettyString()
Returns a pretty format String representation of this capacity.
|
static String |
toPrettyString(long capacity)
Utility method to create a pretty format representation of given capacity in bytes.
|
static String |
toPrettyString(long capacity,
MemoryUnit unit)
Utility method to create a pretty format representation of given capacity with a specified unit.
|
String |
toString() |
public Capacity(long value)
public Capacity(long value, MemoryUnit unit)
public long getValue()
public MemoryUnit getUnit()
public long bytes()
public long kiloBytes()
public long megaBytes()
public long gigaBytes()
public static Capacity of(long value, MemoryUnit unit)
Capacity
.value
- value of the capacityunit
- unit of the capacityCapacity
instancepublic static Capacity parse(String value)
Default unit is bytes.
Examples: 12345, 12345m, 12345K, 123456G
public static Capacity parse(String value, MemoryUnit defaultUnit)
Uses default unit if value does not contain unit information.
Examples: 12345, 12345m, 12345K, 123456G
public String toPrettyString()
public static String toPrettyString(long capacity)
capacity
- capacity in bytespublic static String toPrettyString(long capacity, MemoryUnit unit)
capacity
- capacityunit
- unitCopyright © 2024 Hazelcast, Inc.. All rights reserved.