Interface IConfigValueBuilder<T>

Type Parameters:
T - effectively immutable value type with stable equality

@NonExtendable public interface IConfigValueBuilder<T>
Configures optional behavior before adding a value to its category.

Get an instance from one of the value methods on IConfigCategoryBuilder. Most values can be built immediately. Use this builder when a setting needs a restart, a different config-screen category, or a legacy source imported with IConfigSchemaBuilder.setLegacySources(List).

Since:
0.1.0
  • Method Details

    • setEditMode

      IConfigValueBuilder<T> setEditMode(ConfigValueEditMode editMode)
      Set the edit mode hint for this value.

      Config editors can use this to decide when changes should be saved. If this is not called, values use ConfigValueEditMode.BATCH.

      Parameters:
      editMode - edit mode hint for config editors
      Returns:
      this builder
      Since:
      0.1.0
    • setRestartRequirement

      IConfigValueBuilder<T> setRestartRequirement(ConfigValueRestartRequirement restartRequirement)
      Set when saved changes to this value become effective.

      Until that lifecycle boundary, IConfigValue.get() retains the effective value and IConfigValueEditorInfo.getPendingValue() returns the saved change. If this is not called, values use ConfigValueRestartRequirement.NONE and update immediately.

      Parameters:
      restartRequirement - when saved changes become effective
      Returns:
      this builder
      Since:
      0.1.0
    • addEditorCategory

      IConfigValueBuilder<T> addEditorCategory(IConfigEditorCategoryBuilder categoryBuilder)
      Add a category where config editors should show this value.

      Pass an editor category builder or storage category builder from the same schema. The category does not need to be built yet. If no editor categories are added, config editors can show the value in its storage category. Values may be added to multiple editor categories.

      Parameters:
      categoryBuilder - category where config editors should show this value
      Returns:
      this builder
      Since:
      0.1.0
    • addLegacyName

      IConfigValueBuilder<T> addLegacyName(String legacyName)
      Map this value from its old name when importing a legacy MezzConfig source.

      Use this with IConfigSchemaBuilder.setLegacySources(List) when this value was renamed within the same storage category, but its serialized format did not change. Legacy mappings are considered only while importing a source into a destination config that does not exist yet.

      Parameters:
      legacyName - old stable storage name for this value
      Since:
      0.1.0
    • addLegacyValue

      IConfigValueBuilder<T> addLegacyValue(String legacyCategoryName, String legacyValueName)
      Map this value from its old storage location when importing a legacy MezzConfig source.

      Use this with IConfigSchemaBuilder.setLegacySources(List) when this value moved from another category, another name, or both, but its serialized format did not change. Legacy mappings are considered only while importing a source into a destination config that does not exist yet.

      Parameters:
      legacyCategoryName - old stable storage category name
      legacyValueName - old stable storage value name
      Since:
      0.1.0
    • addLegacyValueMigration

      <U> IConfigValueBuilder<T> addLegacyValueMigration(String legacyCategoryName, String legacyValueName, IConfigValueSerializer<U> legacySerializer, Function<U,T> migration)
      Convert a value previously stored by MezzConfig when its type or serialized form changed.

      Use this with IConfigSchemaBuilder.setLegacySources(List) for one setting that moved to a new category or name and now uses a different representation. While importing the selected legacy source, MezzConfig reads the old value with legacySerializer and passes the typed result to migration. This conversion is not run while loading an existing destination config.

      To import a file that was not written by MezzConfig, use IConfigSchemaBuilder.setLegacyMigration(List, IConfigMigrator) instead.

      Type Parameters:
      U - old value type
      Parameters:
      legacyCategoryName - old stable storage category name
      legacyValueName - old stable storage value name
      legacySerializer - serializer for the old value type and storage format
      migration - converts a usable old value into a valid current value; it must be deterministic and thread-safe
      Since:
      0.1.0
    • build

      IConfigValue<T> build()
      Build and add the config value to its category. A value builder may only be built once.
      Since:
      0.1.0