Class MemorySize

java.lang.Object
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 Details

  • Method Details

    • 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;
      • '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

      public static MemorySize parse​(String value, MemoryUnit defaultUnit)
      Parses string representation of a memory size value. 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

      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
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object