Package com.jummania

Class DataManagerFactory

java.lang.Object
com.jummania.DataManagerFactory

public class DataManagerFactory extends Object
Factory class for creating and managing a singleton instance of DataManager.

This class follows the Singleton design pattern to ensure that only one instance of DataManager is created and provides global access to it.

It is thread-safe and provides methods to create and retrieve the DataManager instance.

Created by Jummania on 20, November, 2024. Email: sharifuddinjumman@gmail.com Dhaka, Bangladesh.

  • Method Details

    • create

      public static DataManager create (File filesDir)
      Creates and returns the singleton instance of DataManager. If the DataManager instance does not exist, it is created with the provided filesDir. This method is synchronized to ensure thread safety during instance creation.
      Parameters:
      filesDir - The directory where data is to be stored.
      Returns:
      The singleton instance of DataManager.
    • create

      public static DataManager create (File filesDir, DataManager.Converter converter)
      Creates and returns the singleton instance of DataManager with a specified converter. If the DataManager instance does not exist, it is created with the provided filesDir and converter. This method is synchronized to ensure thread safety during instance creation.
      Parameters:
      filesDir - The directory where data is to be stored.
      converter - The converter to be used for data serialization/deserialization.
      Returns:
      The singleton instance of DataManager.
    • getDataManager

      public static DataManager getDataManager()
      Retrieves the singleton instance of DataManager. If the instance is not yet created, this method throws an IllegalStateException.
      Returns:
      The singleton instance of DataManager.
      Throws:
      IllegalStateException - If the DataManager instance is not yet created.