Package ej.bon

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