Class Outcome<T>


  • public class Outcome<T>
    extends java.lang.Object
    An Outcome represents the result of a task, which might be success or failure T is the class of the result of the task in the event that it is successful
    • Constructor Summary

      Constructors 
      Constructor Description
      Outcome​(java.lang.Exception exception)
      Create a failure outcome
      Outcome​(T result)
      Create a success outcome
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Exception getException()
      Get the result of the task if it was unsuccessful
      T getResult()
      Get the result of the task if it was successful
      boolean isSuccess()
      Ask if the task was successful
      • Methods inherited from class java.lang.Object

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

      • Outcome

        public Outcome​(T result)
        Create a success outcome
        Parameters:
        result - the successful outcome
      • Outcome

        public Outcome​(java.lang.Exception exception)
        Create a failure outcome
        Parameters:
        exception - the unsuccessful outcome
    • Method Detail

      • isSuccess

        public boolean isSuccess()
        Ask if the task was successful
        Returns:
        true if the task was successful
      • getResult

        public T getResult()
        Get the result of the task if it was successful
        Returns:
        the result of the task if it was successful, or null otherwise
      • getException

        public java.lang.Exception getException()
        Get the result of the task if it was unsuccessful
        Returns:
        the result of the task if it was unsuccessful, or null otherwise