de.caff.util

## Enum MemFormat

- java.lang.Object
- - java.lang.Enum<MemFormat>
  - - de.caff.util.MemFormat

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<MemFormat>

      public enum MemFormat
      extends java.lang.Enum<MemFormat>

  Helper for formatting memory sizes in a more human-readable form.
  Since:
    Mai 14, 2021
  Author:
    Rammi

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `Base10` Memory sizes are based on 10, i.e. a kilobyte is 1000 (10^3) bytes.
    `Base2` Memory sizes are based on 2, i.e. a kilobyte is 1024 (2^10) bytes.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `java.math.BigInteger` | `bigKiloSize` Size of one kilobyte when using this base, as BigInteger.
    `int` | `kiloSize` Size of one kilobyte when using this base.
    `Indexable<java.lang.String>` | `prefixes` List of prefixes when using this base.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `toString(java.math.BigInteger memSize)` Get a human-readable string representation of a memory size.
    `java.lang.String` | `toString(java.math.BigInteger memSize, java.lang.String sep, java.lang.String suf)` Get a human-readable string representation of a memory size.
    `java.lang.String` | `toString(long memSize)` Get a human-readable string representation of a memory size.
    `java.lang.String` | `toString(long memSize, java.lang.String sep, java.lang.String suf)` Get a human-readable string representation of a memory size.
    `static MemFormat` | `valueOf(java.lang.String name)` Returns the enum constant of this type with the specified name.
    `static MemFormat[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

    - ### Methods inherited from class java.lang.Enum

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### Base10

          public static final MemFormat Base10

      Memory sizes are based on 10, i.e. a kilobyte is 1000 (10^3) bytes.

    - #### Base2

          public static final MemFormat Base2

      Memory sizes are based on 2, i.e. a kilobyte is 1024 (2^10) bytes.

  - ### Field Detail

    - #### kiloSize

          public final int kiloSize

      Size of one kilobyte when using this base.

    - #### bigKiloSize

          public final java.math.BigInteger bigKiloSize

      Size of one kilobyte when using this base, as BigInteger.

    - #### prefixes

          @NotNull
          public final Indexable<java.lang.String> prefixes

      List of prefixes when using this base.

  - ### Method Detail

    - #### values

          public static MemFormat[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (MemFormat c : MemFormat.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static MemFormat valueOf(java.lang.String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `java.lang.IllegalArgumentException` - if this enum type has no constant with the specified name
        `java.lang.NullPointerException` - if the argument is null

    - #### toString

          @NotNull
          public java.lang.String toString(long memSize)

      Get a human-readable string representation of a memory size. This will ussually return a string with no more than 3 significant digits.
      Parameters:
        `memSize` - memory size
      Returns:
        human-readable string representation like 256M

    - #### toString

          @NotNull
          public java.lang.String toString(@NotNull
                                                    java.math.BigInteger memSize)

      Get a human-readable string representation of a memory size. This will usually return a string with no more than 3 significant digits.
      Parameters:
        `memSize` - memory size
      Returns:
        human-readable string representation like 256M

    - #### toString

          @NotNull
          public java.lang.String toString(long memSize,
                                                    @Nullable
                                                    java.lang.String sep,
                                                    @Nullable
                                                    java.lang.String suf)

      Get a human-readable string representation of a memory size. This will usually return a string with no more than 3 significant digits.
      Parameters:
        `memSize` - memory size
        `sep` - separator between number and memory prefix, none if `null` or empty
        `suf` - additional suffix, e.g. `"Byte"`, none if `null` or empty
      Returns:
        human-readable string representation like `256 MB` with a space character as separator and a `"B"` as suffix

    - #### toString

          @NotNull
          public java.lang.String toString(@NotNull
                                                    java.math.BigInteger memSize,
                                                    @Nullable
                                                    java.lang.String sep,
                                                    @Nullable
                                                    java.lang.String suf)

      Get a human-readable string representation of a memory size. This will usually return a string with no more than 3 significant digits.
      Parameters:
        `memSize` - memory size
        `sep` - separator between number and memory prefix, none if `null` or empty
        `suf` - additional suffix, e.g. `"Bytes"`, none if `null` or empty
      Returns:
        human-readable string representation like `256 MB` with a space character as separator and a `"B"` as suffix