Interface ISortingConfigMigrator<T>

Type Parameters:
T - sortable value type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ISortingConfigMigrator<T>
Imports a saved order from the format a mod used before adopting a MezzConfig sorting config.

Register a migrator with ISortingConfig.setLegacyMigration(java.util.List<java.nio.file.Path>, net.mezzdev.config.api.migration.ISortingConfigMigrator<T>). Parse the old file in migrate(java.nio.file.Path, net.mezzdev.config.api.migration.ISortingConfigMigrationContext<T>) and pass the converted order to the supplied context. MezzConfig handles backup, validation, and writing its current sorting format.

Since:
0.3.0
  • Method Details

    • migrate

      void migrate(Path legacyPath, ISortingConfigMigrationContext<T> context) throws Exception
      Import the order from the selected legacy file.
      Parameters:
      legacyPath - normalized absolute path to the selected legacy file
      context - context for supplying the converted saved order
      Throws:
      Exception - if the legacy file cannot be read or migrated
      Since:
      0.3.0
    • onMigrationComplete

      default void onMigrationComplete(IConfigMigrationResult result)
      Receive the final migration outcome for logging, diagnostics, or user-facing feedback.

      Override this when the mod needs to handle skipped migrations or failures that happen after migrate(java.nio.file.Path, net.mezzdev.config.api.migration.ISortingConfigMigrationContext<T>) returns. Lambdas may ignore it. An exception from this method is logged and does not change the completed outcome.

      Parameters:
      result - final structured migration result
      Since:
      0.3.0