T
- the type of the resultpublic final class MigrationMethodResult<T>
extends java.lang.Object
A result may either be a success, which will include a result type, or a failure.
The static methods are intended to be used to create results in a migration method.
An exception thrown from a migration method will be equivalent to using the
Failure(Exception)
method.
.read((payload) -> {
return MigrationMethodResult.Success("My Result!");
})
.read((payload) -> {
return MigrationMethodResult.Failure();
})
Modifier and Type | Method and Description |
---|---|
static <U> MigrationMethodResult<U> |
Failure()
Construct a method result representing a failure.
|
static <U> MigrationMethodResult<U> |
Failure(java.lang.Exception err)
Construct a method result representing a failure based on an Exception.
|
java.util.Optional<java.lang.Exception> |
getException()
Get the exception associated with the method or an empty optional if there
was no exception.
|
java.util.Optional<T> |
getResult()
Get the result of the method.
|
boolean |
isSuccess()
Returns true if the method was successful.
|
static <U> MigrationMethodResult<U> |
Success(U result)
Create a successful method result.
|
public static <U> MigrationMethodResult<U> Failure()
This method doesn't provide any information about the cause of the failure. It is recommended
to throw an exception or use Failure(Exception)
.
U
- the type of the method resultpublic static <U> MigrationMethodResult<U> Failure(java.lang.Exception err)
U
- the type of the method resulterr
- the exception which caused the failurepublic static <U> MigrationMethodResult<U> Success(U result)
U
- the type of the method resultresult
- the result of the methodpublic boolean isSuccess()
public java.util.Optional<T> getResult()
public java.util.Optional<java.lang.Exception> getException()