Interface MigrateSource<C>
- Type Parameters:
C- the config type
- All Known Implementing Classes:
MigrateFromConfiguration
A migration source is responsible for loading the old version, checking whether it is applicable, and if so, returning it.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA filter for old configuration versions. -
Method Summary
Modifier and TypeMethodDescription@NonNull MigrateSource<C> addFilter(@NonNull MigrateSource.Filter<C> filter) Returns a new migration source, with the given filter applied.@NonNull LoadResult<@NonNull C> load(@NonNull MigrateContext migrateContext) Attempts to load this configuration version.voidSignals that the migration was fully completed.
-
Method Details
-
load
Attempts to load this configuration version.If the old version isn't detectable or in usable, returns an error.
Updated paths
If the loading the old configuration produced any new keys, or updated existing ones, the implementor should use the migration context's load listener to flag these updates.
UpdateReason.MIGRATEDshould be used for all key updates.Importantly, updates should only be flagged when the implementation is sure it will return a success value, and after filters have been applied. Please see
MigrateFromConfigurationfor a reference implementation.- Parameters:
migrateContext- migration context to use if necessary- Returns:
- the old configuration version, or an error if not found and usable
- Throws:
UncheckedIOException- upon an I/O failure
-
onCompletion
void onCompletion()Signals that the migration was fully completed.This means that the old config version may not be necessary to keep around. It might be time to delete, or move to a different place (like config_old.yml) for archival purposes.
- Throws:
UncheckedIOException- upon an I/O failure
-
addFilter
Returns a new migration source, with the given filter applied.Values from the original
load(MigrateContext)will be passed through the filter, and if the filter returns false, the resultingload(MigrateContext)will return an empty error instead.- Parameters:
filter- the source filter to apply- Returns:
- a new migration source, taking into account the filter
- Throws:
UnsupportedOperationException- if the implementation does not support adding filters
-