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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongbytes()Returns value of the capacity in bytes.final booleangetUnit()Returns unit of the capacitylonggetValue()Returns value of the capacity in its original unit.longReturns value of the capacity in giga-bytes.final inthashCode()longReturns value of the capacity in kilo-bytes.longReturns value of the capacity in mega-bytes.static Capacityof(long value, MemoryUnit unit) Returns an instance ofCapacity.static CapacityParses string representation of a capacity.static Capacityparse(String value, MemoryUnit defaultUnit) Parses string representation of a capacity.Returns a pretty format String representation of this capacity.static StringtoPrettyString(long capacity) Utility method to create a pretty format representation of given capacity in bytes.static StringtoPrettyString(long capacity, MemoryUnit unit) Utility method to create a pretty format representation of given capacity with a specified unit.final StringtoString()
-
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 kilo-bytes.- Returns:
- capacity in kilo-bytes
-
megaBytes
public long megaBytes()Returns value of the capacity in mega-bytes.- Returns:
- capacity in mega-bytes
-
gigaBytes
public long gigaBytes()Returns value of the capacity in giga-bytes.- Returns:
- capacity in giga-bytes
-
of
Returns an instance ofCapacity.- Parameters:
value- value of the capacityunit- unit of the capacity- Returns:
- a
Capacityinstance
-
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()
-