public interface MigrationReport
This code is experimental. While this interface is functional and tested, it may change or be removed in a future version of the library.
Modifier and Type | Method and Description |
---|---|
MigrationReport |
doAfterCompletion(Consumer<MigrationReport> code)
Registers code to be invoked at the completion of the migration operation.
|
default Stream<MigrationException> |
errors()
Retrieves all errors recorded by the operation that generated this migration report.
|
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.
|
default Stream<MigrationInformation> |
infos()
Retrieves all informational messages recorded by the operation that generated this migration
report.
|
Stream<MigrationMessage> |
messages()
Retrieves all messages recorded by the operation that generated this migration report.
|
MigrationReport |
record(MigrationMessage msg)
Records a message that occurred during the migration report.
|
default MigrationReport |
record(String msg)
Records an informational message that occurred during the migration report.
|
default MigrationReport |
record(String format,
Object... args)
Records an informational message that occurred during the migration report.
|
void |
verifyCompletion()
Verifies if the operation that generated this migration report completed successfully.
|
default Stream<MigrationWarning> |
warnings()
Retrieves all warnings recorded by the operation that generated this migration report.
|
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.
|
MigrationOperation getOperation()
Instant getStartTime()
Optional<Instant> getEndTime()
default MigrationReport record(String msg)
Note: This is equivalent to record(new MigrationInformation(msg))
.
msg
- the information message to recordIllegalArgumentException
- if msg
is null
default MigrationReport record(String format, @Nullable Object... args)
Note: This is equivalent to record(new MigrationInformation(format, args))
.
format
- the format string for the detail message for the information message to record
(see String.format(java.lang.String, java.lang.Object...)
)args
- the arguments to the format messageIllegalArgumentException
- if format
is null
MigrationReport record(MigrationMessage msg)
Recorded errors (i.e. MigrationException} will be thrown back when verifyCompletion()
is called at the end of the operation.
msg
- the message to recordIllegalArgumentException
- if msg
is null
MigrationReport doAfterCompletion(Consumer<MigrationReport> code)
code
- the code to execute which will receive this report in parameter where additional
errors and/or warnings can be registeredIllegalArgumentException
- if code
is null
Stream<MigrationMessage> messages()
default Stream<MigrationException> errors()
default Stream<MigrationWarning> warnings()
default Stream<MigrationInformation> infos()
boolean wasSuccessful()
Note: A successful operation might still report warnings.
true
if the operation was successfull; false
if notboolean wasSuccessful(@Nullable Runnable code)
Note: This method will only account for errors generated from the point where the provided code is called to the moment it terminates.
code
- the code to runtrue
if no new errors were recorded while running the provided code;
false
if at least one error was recordedboolean wasIOSuccessful(@Nullable ThrowingRunnable<IOException> code) throws IOException
Note: This method will only account for errors generated from the point where the provided code is called to the moment it terminates.
code
- 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 itboolean hasInfos()
true
if the operation recorded at least one informational message;
false
if notboolean hasWarnings()
true
if the operation recorded at least one warning; false
if
notboolean hasErrors()
true
if the operation recorded at least one error; false
if
notvoid verifyCompletion()
Note: 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()
).
MigrationException
- if at least one error occurred during the operationThis work is licensed under a Creative Commons Attribution 4.0 International License.