Class MigrateFromConfiguration<C>
- Type Parameters:
C- the config type
- All Implemented Interfaces:
MigrateSource<C>
Warning: This migration source only verifies that the old configuration could be loaded from the current
backend, using that backend's recommended key mapper. However, if your old configuration provides default values
everywhere, it will load anything, and it will appear to be always detected! See the package javadoc for more
information on this problem, or consider adding a MigrateSource.Filter to this migration source.
-
Nested Class Summary
Nested classes/interfaces inherited from interface space.arim.dazzleconf.migration.MigrateSource
MigrateSource.Filter<C_OLD> -
Constructor Summary
Constructors -
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.
-
Constructor Details
-
MigrateFromConfiguration
Creates- Parameters:
config- the configuration to use
-
-
Method Details
-
load
Description copied from interface:MigrateSourceAttempts 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.- Specified by:
loadin interfaceMigrateSource<C>- Parameters:
migrateContext- migration context to use if necessary- Returns:
- the old configuration version, or an error if not found and usable
-
onCompletion
public void onCompletion()Description copied from interface:MigrateSourceSignals 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.
- Specified by:
onCompletionin interfaceMigrateSource<C>
-
addFilter
Description copied from interface:MigrateSourceReturns a new migration source, with the given filter applied.Values from the original
MigrateSource.load(MigrateContext)will be passed through the filter, and if the filter returns false, the resultingload(MigrateContext)will return an empty error instead.- Specified by:
addFilterin interfaceMigrateSource<C>- Parameters:
filter- the source filter to apply- Returns:
- a new migration source, taking into account the filter
-