com.hazelcast.memory
Class MemorySize

java.lang.Object
  extended by com.hazelcast.memory.MemorySize

public final class MemorySize
extends Object

MemorySize represents a memory size with given value and MemoryUnit.

Since:
3.4
See Also:
MemoryUnit

Constructor Summary
MemorySize(long value)
           
MemorySize(long value, MemoryUnit unit)
           
 
Method Summary
 long bytes()
          Returns value of memory size in bytes.
 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.
 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.
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemorySize

public MemorySize(long value)

MemorySize

public MemorySize(long value,
                  MemoryUnit unit)
Method Detail

getValue

public long getValue()
Returns value of memory size in its original unit.

Returns:
memory size in its original unit

getUnit

public MemoryUnit getUnit()
Returns unit of memory size

Returns:
unit of memory size

bytes

public long bytes()
Returns value of memory size in bytes.

Returns:
memory size in bytes

kiloBytes

public long kiloBytes()
Returns value of memory size in kilo-bytes.

Returns:
memory size in kilo-bytes

megaBytes

public long megaBytes()
Returns value of memory size in mega-bytes.

Returns:
memory size in mega-bytes

gigaBytes

public long gigaBytes()
Returns value of memory size in giga-bytes.

Returns:
memory size in giga-bytes

parse

public static MemorySize parse(String value)
Parses string representation of a memory size value. Value may end with one of suffixes;

Default unit is bytes.

Examples: 12345, 12345m, 12345K, 123456G


parse

public static MemorySize parse(String value,
                               MemoryUnit defaultUnit)
Parses string representation of a memory size value. Value may end with one of suffixes;

Uses default unit if value does not contain unit information.

Examples: 12345, 12345m, 12345K, 123456G


toPrettyString

public String toPrettyString()
Returns a pretty format String representation of this memory size.

Returns:
a pretty format representation of this memory size

toString

public String toString()
Overrides:
toString in class Object

toPrettyString

public static String toPrettyString(long size)
Utility method to create a pretty format representation of given value in bytes.

Parameters:
size - size in bytes
Returns:
pretty format representation of given value

toPrettyString

public static String toPrettyString(long size,
                                    MemoryUnit unit)
Utility method to create a pretty format representation of given value in given unit.

Parameters:
size - memory size
unit - memory unit
Returns:
pretty format representation of given value


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.