Class MigrationResult.Builder
java.lang.Object
net.blockhost.commons.config.migration.MigrationResult.Builder
- Enclosing interface:
MigrationResult
Builder for creating migration results incrementally.
This is useful when executing multiple migrations and tracking progress:
MigrationResult.Builder builder = MigrationResult.builder(1, data);
for (Migration migration : migrations) {
try {
builder.startStep();
migration.migrate(context);
builder.completeStep(migration);
} catch (Exception e) {
return builder.fail(migration.targetVersion(), e);
}
}
return builder.build(targetVersion);
-
Method Summary
Modifier and TypeMethodDescriptionbuild(int toVersion) Builds a successful result.voidcompleteStep(Migration migration) Records the completion of a migration step.fail(int failedAtVersion, MigrationException cause) Builds a failed result.Builds a result indicating no migration was needed.voidMarks the start of a migration step.
-
Method Details
-
startStep
public void startStep()Marks the start of a migration step. -
completeStep
Records the completion of a migration step.- Parameters:
migration- the migration that was applied
-
build
Builds a successful result.- Parameters:
toVersion- the final version- Returns:
- the successful result
-
fail
Builds a failed result.- Parameters:
failedAtVersion- the version where migration failedcause- the exception that caused the failure- Returns:
- the failed result
-
noMigrationNeeded
Builds a result indicating no migration was needed.- Returns:
- the no-op result
-