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 Details

    • NitriteConfig

      public NitriteConfig()
      Instantiates a new NitriteConfig.
  • Method Details

    • 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.
    • disableRepositoryTypeValidation

      public void disableRepositoryTypeValidation()
      Disables repository type validation.
      Throws:
      InvalidOperationException - if the repository type validation is attempted to be changed after database initialization.
    • registerEntityConverter

      public void registerEntityConverter(EntityConverter<?> entityConverter)
      Registers an EntityConverter with the Nitrite database.
      Parameters:
      entityConverter - the EntityConverter to register
      Throws:
      InvalidOperationException - if the converter is attempted to be registered after database initialization.
    • loadModule

      public NitriteConfig loadModule(NitriteModule module)
      Loads NitritePlugin instances defined in the NitriteModule 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 the NitriteIndexer 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 the NitriteMapper instance used by Nitrite.
      Returns:
      the NitriteMapper instance used by Nitrite.
    • getNitriteStore

      public NitriteStore<?> getNitriteStore()
      Returns the NitriteStore 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 interface AutoCloseable
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getFieldSeparator

      public static String getFieldSeparator()
      The separator used to separate field names in a nested field.
    • getEntityConverters

      public List<EntityConverter<?>> getEntityConverters()
      A list of EntityConverter 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 to Constants.INITIAL_SCHEMA_VERSION.
    • isRepositoryTypeValidationDisabled

      public boolean isRepositoryTypeValidationDisabled()
      Indicates if repository type validation is disabled.