Package org.dizitart.no2
Class NitriteConfig
- java.lang.Object
-
- org.dizitart.no2.NitriteConfig
-
- All Implemented Interfaces:
AutoCloseable
public class NitriteConfig extends Object implements AutoCloseable
NitriteConfig is a configuration class for Nitrite database.- Since:
- 4.0
- Author:
- Anindya Chatterjee.
-
-
Constructor Summary
Constructors Constructor Description NitriteConfig()Instantiates a newNitriteConfig.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NitriteConfigaddMigration(Migration migration)Adds a migration step to the configuration.voidautoConfigure()Automatically configures Nitrite database by finding and loading plugins.voidclose()Closes the NitriteConfig instance and releases any resources associated with it.NitriteConfigcurrentSchemaVersion(Integer version)Sets the current schema version of the Nitrite database.voidfieldSeparator(String separator)Sets the field separator for Nitrite database.NitriteIndexerfindIndexer(String indexType)Finds theNitriteIndexerfor the given index type.List<EntityConverter<?>>getEntityConverters()A list ofEntityConverterinstances registered with the Nitrite database.static StringgetFieldSeparator()The separator used to separate field names in a nested field.Map<Integer,TreeMap<Integer,Migration>>getMigrations()A map of migrations to be applied to the database.NitriteStore<?>getNitriteStore()Returns theNitriteStoreassociated with this instance.IntegergetSchemaVersion()The schema version of the Nitrite database.NitriteConfigloadModule(NitriteModule module)LoadsNitritePlugininstances defined in theNitriteModuleinto the configuration.NitriteMappernitriteMapper()Returns theNitriteMapperinstance used by Nitrite.voidregisterEntityConverter(EntityConverter<?> entityConverter)Registers anEntityConverterwith the Nitrite database.StringtoString()
-
-
-
Constructor Detail
-
NitriteConfig
public NitriteConfig()
Instantiates a newNitriteConfig.
-
-
Method Detail
-
fieldSeparator
public void fieldSeparator(String separator)
Sets the field separator for Nitrite database.- Parameters:
separator- the field separator to be set.- Throws:
InvalidOperationException- if the separator is attempted to be changed after database initialization.
-
registerEntityConverter
public void registerEntityConverter(EntityConverter<?> entityConverter)
Registers anEntityConverterwith the Nitrite database.- Parameters:
entityConverter- theEntityConverterto register- Throws:
InvalidOperationException- if the converter is attempted to be registered after database initialization.
-
loadModule
public NitriteConfig loadModule(NitriteModule module)
LoadsNitritePlugininstances defined in theNitriteModuleinto the configuration.- Parameters:
module- the Nitrite module to be loaded- Returns:
- the Nitrite configuration instance
- Throws:
InvalidOperationException- if the database is already initialized
-
addMigration
public NitriteConfig addMigration(Migration migration)
Adds a migration step to the configuration. A migration step is a process of updating the database from one version to another. If the database is already initialized, then migration steps cannot be added.- Parameters:
migration- the migration step to be added.- Returns:
- the NitriteConfig instance.
- Throws:
InvalidOperationException- if migration steps are added after database initialization.
-
currentSchemaVersion
public NitriteConfig currentSchemaVersion(Integer version)
Sets the current schema version of the Nitrite database.- Parameters:
version- the current schema version.- Returns:
- the NitriteConfig instance.
- Throws:
InvalidOperationException- if the schema version is attempted to be added after database initialization.
-
autoConfigure
public void autoConfigure()
Automatically configures Nitrite database by finding and loading plugins.- Throws:
InvalidOperationException- if autoconfigure is executed after database initialization.
-
findIndexer
public NitriteIndexer findIndexer(String indexType)
Finds theNitriteIndexerfor the given index type.- Parameters:
indexType- the type of the index to find- Returns:
- the
NitriteIndexerfor the given index type - Throws:
IndexingException- if no indexer is found for the given index type
-
nitriteMapper
public NitriteMapper nitriteMapper()
Returns theNitriteMapperinstance used by Nitrite.- Returns:
- the NitriteMapper instance used by Nitrite.
-
getNitriteStore
public NitriteStore<?> getNitriteStore()
Returns theNitriteStoreassociated with this instance.- Returns:
- the
NitriteStoreassociated with this instance.
-
close
public void close()
Closes the NitriteConfig instance and releases any resources associated with it.- Specified by:
closein interfaceAutoCloseable
-
getFieldSeparator
public static String getFieldSeparator()
The separator used to separate field names in a nested field.
-
getEntityConverters
public List<EntityConverter<?>> getEntityConverters()
A list ofEntityConverterinstances registered with the Nitrite database.
-
getMigrations
public Map<Integer,TreeMap<Integer,Migration>> getMigrations()
A map of migrations to be applied to the database.
-
getSchemaVersion
public Integer getSchemaVersion()
The schema version of the Nitrite database. Defaults toConstants.INITIAL_SCHEMA_VERSION.
-
-