Package org.dizitart.no2
Class NitriteConfig
java.lang.Object
org.dizitart.no2.NitriteConfig
- All Implemented Interfaces:
AutoCloseable
NitriteConfig is a configuration class for Nitrite database.
- Since:
- 4.0
- Author:
- Anindya Chatterjee.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMigration(Migration migration) Adds a migration step to the configuration.voidAutomatically configures Nitrite database by finding and loading plugins.voidclose()Closes the NitriteConfig instance and releases any resources associated with it.currentSchemaVersion(Integer version) Sets the current schema version of the Nitrite database.voidDisables repository type validation.voidfieldSeparator(String separator) Sets the field separator for Nitrite database.findIndexer(String indexType) Finds theNitriteIndexerfor the given index type.List<EntityConverter<?>>A list ofEntityConverterinstances registered with the Nitrite database.static StringThe separator used to separate field names in a nested field.A map of migrations to be applied to the database.NitriteStore<?>Returns theNitriteStoreassociated with this instance.The schema version of the Nitrite database.booleanIndicates if repository type validation is disabled.loadModule(NitriteModule module) LoadsNitritePlugininstances defined in theNitriteModuleinto the configuration.Returns theNitriteMapperinstance used by Nitrite.voidregisterEntityConverter(EntityConverter<?> entityConverter) Registers anEntityConverterwith the Nitrite database.toString()
-
Constructor Details
-
NitriteConfig
public NitriteConfig()Instantiates a newNitriteConfig.
-
-
Method Details
-
fieldSeparator
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.
-
disableRepositoryTypeValidation
public void disableRepositoryTypeValidation()Disables repository type validation.- Throws:
InvalidOperationException- if the repository type validation is attempted to be changed after database initialization.
-
registerEntityConverter
Registers anEntityConverterwith the Nitrite database.- Parameters:
entityConverter- theEntityConverterto register- Throws:
InvalidOperationException- if the converter is attempted to be registered after database initialization.
-
loadModule
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
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
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
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
Returns theNitriteMapperinstance used by Nitrite.- Returns:
- the NitriteMapper instance used by Nitrite.
-
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
-
toString
-
getFieldSeparator
The separator used to separate field names in a nested field. -
getEntityConverters
A list ofEntityConverterinstances registered with the Nitrite database. -
getMigrations
A map of migrations to be applied to the database. -
getSchemaVersion
The schema version of the Nitrite database. Defaults toConstants.INITIAL_SCHEMA_VERSION. -
isRepositoryTypeValidationDisabled
public boolean isRepositoryTypeValidationDisabled()Indicates if repository type validation is disabled.
-