Interface MigrateContext

All Superinterfaces:
UpdateListener

public interface MigrateContext extends UpdateListener
Contextual resources to be used by migrations.

This interface is implemented by the caller when passed to migrations.

  • Method Summary

    Modifier and Type
    Method
    Description
    A factory allowing migrations to produce errors.
    @NonNull Backend
    The backend being used to load the main configuration.
    void
    notifyUpdate(@NonNull KeyPath entryPath, @NonNull UpdateReason updateReason)
    Allows migrations to signal updated paths.
  • Method Details

    • mainBackend

      @NonNull Backend mainBackend()
      The backend being used to load the main configuration.

      This will not necessarily be used by all migrations. Some migrations, for example, may source from a separate file, or combine different backends to get the data they need.

      Returns:
      the main backend being used to load the configuraion
    • notifyUpdate

      void notifyUpdate(@NonNull KeyPath entryPath, @NonNull UpdateReason updateReason)
      Allows migrations to signal updated paths.

      Migrations may optionally use this method to identify which parts of a configuration (if applicable) were changed during the course of migration.

      Specified by:
      notifyUpdate in interface UpdateListener
      Parameters:
      entryPath - the path of the entry
      updateReason - the update reason, note that some implementors will discard this parameter in favor of UpdateReason.MIGRATED even if a different value is passed
    • errorSource

      @NonNull ErrorContext.Source errorSource()
      A factory allowing migrations to produce errors.

      Unlike other parts of the API, the error source is provided as a getter, and not as an extended interface. This reflects the want to make implementing MigrateContext convenient, if library users wish to call migrations using their own approach.

      Returns:
      a factory for error production