Class 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 Detail

      • NitriteConfig

        public NitriteConfig()
        Instantiates a new NitriteConfig.
    • 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.
      • 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.
      • nitriteMapper

        public NitriteMapper nitriteMapper()
        Returns the NitriteMapper instance used by Nitrite.
        Returns:
        the NitriteMapper instance used by Nitrite.
      • close

        public void close()
        Closes the NitriteConfig instance and releases any resources associated with it.
        Specified by:
        close in interface AutoCloseable
      • getFieldSeparator

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

        public Integer getSchemaVersion()
        The schema version of the Nitrite database. Defaults to Constants.INITIAL_SCHEMA_VERSION.