Package com.hazelcast.memory
Class Capacity
java.lang.Object
com.hazelcast.memory.Capacity
- Direct Known Subclasses:
MemorySize
Capacity represents a memory capacity with given value and
MemoryUnit
.
This class is immutable.- Since:
- 5.1
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
bytes()
Returns value of the capacity in bytes.final boolean
getUnit()
Returns unit of the capacitylong
getValue()
Returns value of the capacity in its original unit.long
Returns value of the capacity in gigabytes.final int
hashCode()
long
Returns value of the capacity in kilobytes.long
Returns value of the capacity in megabytes.static Capacity
of
(long value, MemoryUnit unit) Returns an instance ofCapacity
.static Capacity
Parses string representation of a capacity.static Capacity
parse
(String value, MemoryUnit defaultUnit) Parses string representation of a capacity.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.final String
toString()
-
Constructor Details
-
Capacity
public Capacity(long value) -
Capacity
-
-
Method Details
-
getValue
public long getValue()Returns value of the capacity in its original unit.- Returns:
- capacity in its original unit
-
getUnit
Returns unit of the capacity- Returns:
- unit of capacity
-
bytes
public long bytes()Returns value of the capacity in bytes.- Returns:
- capacity in bytes
-
kiloBytes
public long kiloBytes()Returns value of the capacity in kilobytes.- Returns:
- capacity in kilobytes
-
megaBytes
public long megaBytes()Returns value of the capacity in megabytes.- Returns:
- capacity in megabytes
-
gigaBytes
public long gigaBytes()Returns value of the capacity in gigabytes.- Returns:
- capacity in gigabytes
-
of
Returns an instance ofCapacity
.- Parameters:
value
- value of the capacityunit
- unit of the capacity- Returns:
- a
Capacity
instance
-
parse
Parses string representation of a capacity. 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 capacity. 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 capacity.- Returns:
- a pretty format representation of this capacity
-
toString
-
toPrettyString
Utility method to create a pretty format representation of given capacity in bytes.- Parameters:
capacity
- capacity in bytes- Returns:
- pretty format representation of given capacity
-
toPrettyString
Utility method to create a pretty format representation of given capacity with a specified unit.- Parameters:
capacity
- capacityunit
- unit- Returns:
- pretty format representation of given capacity
-
equals
-
hashCode
public final int hashCode()
-