Class MigrationMethodResult<T>

  • Type Parameters:
    T - the type of the result

    public final class MigrationMethodResult<T>
    extends java.lang.Object
    Results of a method associated with a migration origin.

    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();
       })
     
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • Failure

        public static <U> MigrationMethodResult<U> Failure()
        Construct a method result representing a 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).

        Type Parameters:
        U - the type of the method result
        Returns:
        a method result
      • Failure

        public static <U> MigrationMethodResult<U> Failure​(java.lang.Exception err)
        Construct a method result representing a failure based on an Exception.
        Type Parameters:
        U - the type of the method result
        Parameters:
        err - the exception which caused the failure
        Returns:
        a method result
      • Success

        public static <U> MigrationMethodResult<U> Success​(U result)
        Create a successful method result.
        Type Parameters:
        U - the type of the method result
        Parameters:
        result - the result of the method
        Returns:
        a method result
      • isSuccess

        public boolean isSuccess()
        Returns true if the method was successful.
        Returns:
        true if the method was successful
      • getResult

        public java.util.Optional<T> getResult()
        Get the result of the method.
        Returns:
        the result, or an empty optional if no result was produced
      • getException

        public java.util.Optional<java.lang.Exception> getException()
        Get the exception associated with the method or an empty optional if there was no exception.
        Returns:
        the exception, or an empty optional if no result was produced