Interface IConfigValueBuilder<T>
- Type Parameters:
T- effectively immutable value type with stable equality
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 Summary
Modifier and TypeMethodDescriptionaddEditorCategory(IConfigEditorCategoryBuilder categoryBuilder) Add a category where config editors should show this value.addLegacyName(String legacyName) Map this value from its old name when importing a legacy MezzConfig source.addLegacyValue(String legacyCategoryName, String legacyValueName) Map this value from its old storage location when importing a legacy MezzConfig source.<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.build()Build and add the config value to its category.setEditMode(ConfigValueEditMode editMode) Set the edit mode hint for this value.setRestartRequirement(ConfigValueRestartRequirement restartRequirement) Set when saved changes to this value become effective.
-
Method Details
-
setEditMode
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
Set when saved changes to this value become effective.Until that lifecycle boundary,
IConfigValue.get()retains the effective value andIConfigValueEditorInfo.getPendingValue()returns the saved change. If this is not called, values useConfigValueRestartRequirement.NONEand update immediately.- Parameters:
restartRequirement- when saved changes become effective- Returns:
- this builder
- Since:
- 0.1.0
-
addEditorCategory
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
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
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 namelegacyValueName- 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 withlegacySerializerand passes the typed result tomigration. 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 namelegacyValueName- old stable storage value namelegacySerializer- serializer for the old value type and storage formatmigration- 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
-