Package ej.bon

## Class Immutables

- java.lang.Object
- - ej.bon.Immutables

-     public class Immutables
      extends Object

  This class gives access to the global immutable objects pool.

  Immutable objects are persistent and normally reside in read-only-memory, such as flash memory.

  The method `get(String)` allows to retrieve an object from the pool using its ID.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Immutables()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static String[]` | `allIDs()` | Returns an array with the IDs of all the objects in the pool.
    `static long` | `freeMemory()` | Returns the amount of free immutable memory still available.
    `static Object` | `get​(String ID)` | Retrieves the object that match the the given ID in the immutable objects pool.
    `static boolean` | `isImmutable​(Object object)` | Gets whether or not the given object is in the immutable objects pool or not.
    `static void` | `put​(String ID, Object object)` | Deprecated.
    `static void` | `putAll​(Hashtable table)` | Deprecated.
    `static long` | `totalMemory()` | Returns the total amount of immutable memory.

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

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Immutables

          public Immutables()

  - ### Method Detail

    - #### get

          public static Object get​(String ID)

      Retrieves the object that match the the given ID in the immutable objects pool.

      If no object can be found with such ID, a `NoSuchElementException` is thrown.

      Parameters:
        `ID` - the ID of the immutable object to get
      Returns:
        the immutable object matching the ID
      Throws:
        `NoSuchElementException` - if the ID is not found
        `ImmutablesError` - if an internal error occurred during immutable access

    - #### put

          @Deprecated
          public static void put​(String ID,
                                 Object object)

      Deprecated.
      Maps the given ID to the given object in the immutable objects pool.

      The object can be retrieved by calling the get method with an ID that is equal to the original ID.

      Parameters:
        `ID` - the ID of the immutable object to set
        `object` - the object to set immutable
      Throws:
        `NullPointerException` - if given object is `null`
        `OutOfMemoryError` - if the immutable memory is full
      See Also:
        `freeMemory()`

    - #### putAll

          @Deprecated
          public static void putAll​(Hashtable table)

      Deprecated.
      Maps all the mappings in the given table in the immutable objects pool.
      Parameters:
        `table` - the table that contains the objects to set immutable
      Throws:
        `NullPointerException` - if given table is `null`
        `ClassCastException` - if an ID is not a `String`
        `OutOfMemoryError` - if the immutable memory is full
      See Also:
        `freeMemory()`, `put(String, Object)`

    - #### isImmutable

          public static boolean isImmutable​(Object object)

      Gets whether or not the given object is in the immutable objects pool or not.
      Parameters:
        `object` - the object to check
      Returns:
        `true` if the given object is immutable, `false` otherwise
      Throws:
        `NullPointerException` - if given object is `null`

    - #### allIDs

          public static String[] allIDs()

      Returns an array with the IDs of all the objects in the pool.
      Returns:
        all the immutable objects ID.
      See Also:
        `get(String)`

    - #### freeMemory

          public static long freeMemory()

      Returns the amount of free immutable memory still available.
      Returns:
        the amount of free immutable memory

    - #### totalMemory

          public static long totalMemory()

      Returns the total amount of immutable memory.

      Note that the amount of memory required to hold an object of any given type may be implementation-dependent.

      Returns:
        the total amount of immutable memory