Class Failure<SuccessType>

    • Method Detail

      • of

        public static <T> Failure<T> of​(String errorMessage)
        Creates a Failure object containing the errorMessage
        Type Parameters:
        T - the type of the result
        Parameters:
        errorMessage - the error message describing the reason for failure.
        Returns:
        an Failure instance containing the errorMessage
      • of

        public static <T> Failure<T> of​(Throwable throwable)
        Creates a Failure object containing the throwable
        Type Parameters:
        T - the type of the result
        Parameters:
        throwable - the error message describing the reason for failure.
        Returns:
        an Failure instance containing the throwable
      • of

        public static <T> Failure<T> of​(String errorMessage,
                                        Throwable throwable)
        Creates a Failure object containing the errorMessage
        Type Parameters:
        T - the type of the result
        Parameters:
        errorMessage - the error message describing the reason for failure.
        throwable - the throwable that caused the failure
        Returns:
        an Failure instance containing the errorMessage
      • map

        public <T> T map​(Function<SuccessType,​T> successFunction,
                         Function<String,​T> errorFunction)
        Description copied from interface: Result
        A mapping function that maps to either SuccessType or FailureType depending on success or failure of the operation.
        Specified by:
        map in interface Result<SuccessType,​String>
        Specified by:
        map in interface ServiceResult<SuccessType>
        Type Parameters:
        T - the resultant type
        Parameters:
        successFunction - the mapping function to map the SuccessType to the resultant type
        errorFunction - the mapping function to map the FailureType to the resultant error type
        Returns:
        result of type T
      • isFailure

        public boolean isFailure()
        Description copied from interface: Result
        Returns a boolean to indicate the success or failure of the operation
        Specified by:
        isFailure in interface Result<SuccessType,​String>
        Returns:
        true indicating the failure of the operation