Class AttributeSetResultsDatabaseFactory

java.lang.Object
modelarium.attributes.results.databases.AttributeSetResultsDatabaseFactory

public final class AttributeSetResultsDatabaseFactory extends Object
Factory class for creating instances of AttributeSetResultsDatabase.

Supports dynamic switching between in-memory and disk-based result storage via static configuration methods. This allows the simulation to use different result backends without changing core logic.

  • Method Details

    • setDatabaseClass

      public static <T extends AttributeSetResultsDatabase> void setDatabaseClass(Class<T> databaseClass)
      Manually sets the class used for creating result databases.
      Type Parameters:
      T - the database type
      Parameters:
      databaseClass - a class that extends AttributeSetResultsDatabase and has a no-argument constructor
    • setCustomFactory

      public static void setCustomFactory(Supplier<AttributeSetResultsDatabase> factory)
      Sets a custom factory to be used instead of the default class-based instantiation. This is useful for testing.
      Parameters:
      factory - the custom supplier of AttributeSetResultsDatabase instances
    • clearCustomFactory

      public static void clearCustomFactory()
      Clears any custom factory that was previously set, reverting to default behaviour.
    • setDatabaseToMemoryBased

      public static void setDatabaseToMemoryBased()
      Sets the results database to use an in-memory backend. Useful for lightweight or test simulations.
    • setDatabaseToDiskBased

      public static void setDatabaseToDiskBased()
      Sets the results database to use a disk-based SQLite backend. Useful for full-scale runs or persistent storage.
    • createDatabase

      public static AttributeSetResultsDatabase createDatabase()
      Creates a new instance of the configured results database.

      If no database class has been configured, the default is a disk-based database. A unique database path is generated automatically.

      Returns:
      a new AttributeSetResultsDatabase instance, or null on error