Class Result.Failure<T>

java.lang.Object
org.javimmutable.collections.Result<T>
org.javimmutable.collections.Result.Failure<T>
Enclosing class:
Result<T>

public static class Result.Failure<T> extends Result<T>
  • Method Details

    • get

      public T get() throws Exception
      Description copied from class: Result
      Gets the value or throws the exception. Used to unwrap the result so it can be handled using try/catch.
      Specified by:
      get in class Result<T>
      Returns:
      the value if we are a successful result
      Throws:
      Exception - if we are a failure result
    • orElse

      public T orElse(T defaultValue)
      Description copied from class: Result
      Converts a failure result into a success result with a specified value. If we are a failure result return a success result containing the specified value. Otherwise return this.
      Specified by:
      orElse in class Result<T>
    • orElseGet

      public T orElseGet(java.util.function.Supplier<T> defaultValue)
      Description copied from class: Result
      Converts a failure result into a success result with the value returned by a Supplier. If we are a failure result return a success result containing the value returned by the Supplier. Otherwise return this. Does not capture any runtime exception thrown by the supplier.
      Specified by:
      orElseGet in class Result<T>
    • map

      @Nonnull public <U> Result<U> map(Func1Throws<T,U,Exception> func)
      Description copied from class: Result
      Replaces our successful result with a new value computed using the provided function. Simply returns this if we are a failure result.
      Specified by:
      map in class Result<T>
    • flatMap

      @Nonnull public <U> Result<U> flatMap(Func1<T,Result<U>> func)
      Description copied from class: Result
      Replaces our successful result with a new value computed using the provided function. Simply returns this if we are a failure result.
      Specified by:
      flatMap in class Result<T>
    • mapFailure

      @Nonnull public Result<T> mapFailure(Func1Throws<Exception,T,Exception> func)
      Description copied from class: Result
      Replaces our failure result with a new value computed using the provided function. Simply returns this if we are a success result.
      Specified by:
      mapFailure in class Result<T>
    • flatMapFailure

      @Nonnull public Result<T> flatMapFailure(Func1Throws<Exception,Result<T>,Exception> func)
      Description copied from class: Result
      Replaces our failure result with a new value computed using the provided function. Simply returns this if we are a success result.
      Specified by:
      flatMapFailure in class Result<T>
    • apply

      @Nonnull public Result<T> apply(@Nonnull Proc1Throws<T,? super Exception> proc)
      Description copied from class: Result
      Does nothing if we are a failure result. Calls a function with our value if we are a success result. If the function throws an exception returns a new failure result containing that exception. Otherwise returns this.
      Specified by:
      apply in class Result<T>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object