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 NitriteConfig
addMigration(Migration migration)
Adds a migration step to the configuration.void
autoConfigure()
Automatically configures Nitrite database by finding and loading plugins.void
close()
Closes the NitriteConfig instance and releases any resources associated with it.NitriteConfig
currentSchemaVersion(Integer version)
Sets the current schema version of the Nitrite database.void
fieldSeparator(String separator)
Sets the field separator for Nitrite database.NitriteIndexer
findIndexer(String indexType)
Finds theNitriteIndexer
for the given index type.List<EntityConverter<?>>
getEntityConverters()
A list ofEntityConverter
instances registered with the Nitrite database.static String
getFieldSeparator()
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 theNitriteStore
associated with this instance.Integer
getSchemaVersion()
The schema version of the Nitrite database.NitriteConfig
loadModule(NitriteModule module)
LoadsNitritePlugin
instances defined in theNitriteModule
into the configuration.NitriteMapper
nitriteMapper()
Returns theNitriteMapper
instance used by Nitrite.void
registerEntityConverter(EntityConverter<?> entityConverter)
Registers anEntityConverter
with the Nitrite database.String
toString()
-
-
-
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 anEntityConverter
with the Nitrite database.- Parameters:
entityConverter
- theEntityConverter
to register- Throws:
InvalidOperationException
- if the converter is attempted to be registered after database initialization.
-
loadModule
public NitriteConfig loadModule(NitriteModule module)
LoadsNitritePlugin
instances defined in theNitriteModule
into 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 theNitriteIndexer
for the given index type.- Parameters:
indexType
- the type of the index to find- Returns:
- the
NitriteIndexer
for the given index type - Throws:
IndexingException
- if no indexer is found for the given index type
-
nitriteMapper
public NitriteMapper nitriteMapper()
Returns theNitriteMapper
instance used by Nitrite.- Returns:
- the NitriteMapper instance used by Nitrite.
-
getNitriteStore
public NitriteStore<?> getNitriteStore()
Returns theNitriteStore
associated with this instance.- Returns:
- the
NitriteStore
associated with this instance.
-
close
public void close()
Closes the NitriteConfig instance and releases any resources associated with it.- Specified by:
close
in interfaceAutoCloseable
-
getFieldSeparator
public static String getFieldSeparator()
The separator used to separate field names in a nested field.
-
getEntityConverters
public List<EntityConverter<?>> getEntityConverters()
A list ofEntityConverter
instances 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
.
-
-