Package net.mezzdev.config.api.migration
Interface IConfigMigrationContext
@NonExtendable
public interface IConfigMigrationContext
Imports converted legacy settings without exposing MezzConfig's file format.
MezzConfig passes this to IConfigMigrator.migrate(Path, IConfigMigrationContext). Use
set(IConfigValue, Object) for schema values and setSortedValues(ISortingConfig, Collection, List) for
persistent sort orders. All updates from one migration succeed or fail together.
- Since:
- 0.3.0
-
Method Summary
Modifier and TypeMethodDescriptionrejectValue(String diagnostic) Report one legacy value that could not be imported while allowing other usable values to continue.set(IConfigValue<T> configValue, T value) Import a converted value into the destination schema.setSortedValues(ISortingConfig<T> sortingConfig, Collection<T> allValues, List<T> sortedValues) Import a saved order, including any values the user had hidden.
-
Method Details
-
set
Import a converted value into the destination schema. If the same value is set more than once, the last value is used.- Type Parameters:
T- config value type- Parameters:
configValue- config value to updatevalue- migrated value- Returns:
- this migration context
- Throws:
IllegalArgumentException- if the value is invalid, cannot be safely serialized, was not created by MezzConfig, or does not belong to the schema being migratedIllegalStateException- if the migration callback has returned- Since:
- 0.3.0
-
rejectValue
Report one legacy value that could not be imported while allowing other usable values to continue. Each call increments the final result's rejected-value count and includes the diagnostic in that result. If the migration reports rejected values but supplies no usable schema or sorting updates, the migration fails without creating or replacing the destination config.- Parameters:
diagnostic- explanation suitable for logs or user-facing recovery details- Returns:
- this migration context
- Throws:
IllegalArgumentException- ifdiagnosticis blankIllegalStateException- if the migration callback has returned- Since:
- 0.6.0
-
setSortedValues
<T> IConfigMigrationContext setSortedValues(ISortingConfig<T> sortingConfig, Collection<T> allValues, List<T> sortedValues) Import a saved order, including any values the user had hidden.The collections have the same meaning and validation rules as
ISortingConfig.setSortedValues(Collection, List). They are copied before this method returns. The sorting config may be owned by the same registration or another MezzConfig registration, but it must have a local backing file.- Type Parameters:
T- sortable value type- Parameters:
sortingConfig- sorting config to updateallValues- every migrated value known to this sort ordersortedValues- visible migrated values in their saved order- Returns:
- this migration context
- Throws:
IllegalArgumentException- if either collection violates the sorting config's contract or the sorting config was not created by MezzConfigIllegalStateException- if the sorting config has no local backing file, cannot be safely updated, or the migration callback has returned- Since:
- 0.3.0
-