Class AttributeSetResultsDatabaseFactory
java.lang.Object
modelarium.attributes.results.databases.AttributeSetResultsDatabaseFactory
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 Summary
Modifier and TypeMethodDescriptionstatic voidClears any custom factory that was previously set, reverting to default behaviour.static AttributeSetResultsDatabaseCreates a new instance of the configured results database.static voidSets a custom factory to be used instead of the default class-based instantiation.static <T extends AttributeSetResultsDatabase>
voidsetDatabaseClass(Class<T> databaseClass) Manually sets the class used for creating result databases.static voidSets the results database to use a disk-based SQLite backend.static voidSets the results database to use an in-memory backend.
-
Method Details
-
setDatabaseClass
Manually sets the class used for creating result databases.- Type Parameters:
T- the database type- Parameters:
databaseClass- a class that extendsAttributeSetResultsDatabaseand has a no-argument constructor
-
setCustomFactory
Sets a custom factory to be used instead of the default class-based instantiation. This is useful for testing.- Parameters:
factory- the custom supplier ofAttributeSetResultsDatabaseinstances
-
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
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
AttributeSetResultsDatabaseinstance, ornullon error
-