Interface IConfigMigrator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Register a migrator with IConfigSchemaBuilder.setLegacyMigration(List, IConfigMigrator). Parse the old file in
migrate(Path, IConfigMigrationContext) and pass converted values to the migration context. MezzConfig handles
backup, validation, and writing the new config, so migrators never need to understand MezzConfig's file format.
- Since:
- 0.3.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidmigrate(Path legacyPath, IConfigMigrationContext context) Import values from the selected legacy file.default voidReceive the final migration outcome for logging, diagnostics, or user-facing feedback.
-
Method Details
-
migrate
Import values from the selected legacy file.Read the old format from
legacyPathand call the context's typed update methods for every setting to import. Throw an exception when the old file cannot be interpreted; MezzConfig will leave the new config unchanged.- Parameters:
legacyPath- normalized absolute path to the selected legacy filecontext- context for typed config value and sorting updates- Throws:
Exception- if the legacy file cannot be read or migrated- Since:
- 0.3.0
-
onMigrationComplete
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.IConfigMigrationContext)returns. Lambdas may ignore it. MezzConfig calls it once for every registered migration after reaching a final outcome. World-scoped schemas wait until their first local destination becomes active; waiting for a world or receiving a remote server snapshot does not complete the migration. Permanently inactive declarations reportConfigMigrationStatus.SKIPPED_INACTIVE. An exception from this method is logged and does not change that outcome.- Parameters:
result- final structured migration result- Since:
- 0.3.0
-