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 Details

    • set

      <T> IConfigMigrationContext set(IConfigValue<T> configValue, T value)
      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 update
      value - 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 migrated
      IllegalStateException - if the migration callback has returned
      Since:
      0.3.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 update
      allValues - every migrated value known to this sort order
      sortedValues - 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 MezzConfig
      IllegalStateException - if the sorting config has no local backing file, cannot be safely updated, or the migration callback has returned
      Since:
      0.3.0