public class MigrationReportImpl extends Object implements MigrationReport
| Constructor and Description |
|---|
MigrationReportImpl(MigrationOperation operation,
Optional<Consumer<MigrationMessage>> consumer)
Creates a new migration report.
|
| Modifier and Type | Method and Description |
|---|---|
MigrationReport |
doAfterCompletion(Consumer<MigrationReport> code)
Registers code to be invoked at the completion of the migration operation.
|
Optional<Instant> |
getEndTime()
Gets the time the corresponding migration operation ended.
|
MigrationOperation |
getOperation()
Gets the type of migration operation this report is associated with.
|
Instant |
getStartTime()
Gets the time the corresponding migration operation started.
|
boolean |
hasErrors()
Checks if the operation that generated this migration recorded any errors.
|
boolean |
hasInfos()
Checks if the operation that generated this migration recorded any information messages.
|
boolean |
hasWarnings()
Checks if the operation that generated this migration recorded any warnings.
|
Stream<MigrationMessage> |
messages()
Retrieves all messages recorded by the operation that generated this migration report.
|
MigrationReportImpl |
record(MigrationMessage msg)
Records a message that occurred during the migration report.
|
void |
verifyCompletion()
Verifies if the operation that generated this migration report completed successfully.
|
boolean |
wasIOSuccessful(ThrowingRunnable<IOException> code)
Runs the specified code and report whether or not it was successful.
|
boolean |
wasSuccessful()
Checks if the operation that generated this migration report was successful or not.
|
boolean |
wasSuccessful(Runnable code)
Runs the specified code and report whether or not it was successful.
|
public MigrationReportImpl(MigrationOperation operation, Optional<Consumer<MigrationMessage>> consumer)
operation - the type of migration operation for this reportconsumer - an optional consumer to call whenever a new migration message is recorded
during the operationIllegalArgumentException - if operation is nullpublic MigrationOperation getOperation()
MigrationReportgetOperation in interface MigrationReportpublic Instant getStartTime()
MigrationReportgetStartTime in interface MigrationReportpublic Optional<Instant> getEndTime()
MigrationReportgetEndTime in interface MigrationReportpublic MigrationReportImpl record(MigrationMessage msg)
MigrationReportRecorded errors (i.e. MigrationException} will be thrown back when MigrationReport.verifyCompletion() is called at the end of the operation.
record in interface MigrationReportmsg - the message to recordpublic MigrationReport doAfterCompletion(Consumer<MigrationReport> code)
MigrationReportdoAfterCompletion in interface MigrationReportcode - the code to execute which will receive this report in parameter where additional
errors and/or warnings can be registeredpublic Stream<MigrationMessage> messages()
MigrationReportmessages in interface MigrationReportpublic boolean wasSuccessful()
MigrationReportNote: A successful operation might still report warnings.
wasSuccessful in interface MigrationReporttrue if the operation was successfull; false if notpublic boolean wasSuccessful(Runnable code)
MigrationReportNote: This method will only account for errors generated from the point where the provided code is called to the moment it terminates.
wasSuccessful in interface MigrationReportcode - the code to runtrue if no new errors were recorded while running the provided code;
false if at least one error was recordedpublic boolean wasIOSuccessful(ThrowingRunnable<IOException> code) throws IOException
MigrationReportNote: This method will only account for errors generated from the point where the provided code is called to the moment it terminates.
wasIOSuccessful in interface MigrationReportcode - the code to runtrue if no new errors were recorded while running the provided code;
false if at least one error was recordedIOException - if the code executed throws itpublic boolean hasInfos()
MigrationReporthasInfos in interface MigrationReporttrue if the operation recorded at least one informational message;
false if notpublic boolean hasWarnings()
MigrationReporthasWarnings in interface MigrationReporttrue if the operation recorded at least one warning; false if
notpublic boolean hasErrors()
MigrationReporthasErrors in interface MigrationReporttrue if the operation recorded at least one error; false if
notpublic void verifyCompletion()
MigrationReportNote: The first exception recorded will always be thrown out and all additional
exceptions recorded will be added to it as suppressed exceptions (see Throwable.getSuppressed()).
verifyCompletion in interface MigrationReportThis work is licensed under a Creative Commons Attribution 4.0 International License.