com.hazelcast.memory

## 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 Summary

    Constructors
    Constructor and Description
    `MemorySize(long value)`
    `MemorySize(long value, MemoryUnit unit)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `bytes()` Returns value of memory size in bytes.
    `boolean` | `equals(Object o)`
    `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.
    `int` | `hashCode()`
    `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, finalize, getClass, 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;
      - '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`

Copyright © 2019. All rights reserved.