Class Result<T,E>

java.lang.Object
blazing.types.Result<T,E>
Type Parameters:
T - The type of the expression stored in result
E - The type of the error that is returned

public class Result<T,E> extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T, E> Result<T,E>
    err(E value)
    Used to represent an error
    boolean
    Checks if the value is an error
    boolean
    Checks if the value is ok
    static <T, E> Result<T,E>
    ok(T value)
    Used to represent a successful result
    Unwraps the Ok value and panics if there is an error
    Unwraps the error and panics if the value is Ok
    unwrapOr(T value)
    Unwraps an Ok value and returns the provided value if there is an error
    Unwraps an Ok value and calls the supplier method if there is an error

    Methods inherited from class java.lang.Object

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

    • ok

      public static <T, E> Result<T,E> ok(T value)
      Used to represent a successful result
      Type Parameters:
      T -
      E -
      Parameters:
      value -
      Returns:
    • err

      public static <T, E> Result<T,E> err(E value)
      Used to represent an error
      Type Parameters:
      T -
      E -
      Parameters:
      value -
      Returns:
    • unwrap

      public T unwrap()
      Unwraps the Ok value and panics if there is an error
      Returns:
    • unwrapOr

      public T unwrapOr(T value)
      Unwraps an Ok value and returns the provided value if there is an error
      Parameters:
      value -
      Returns:
    • unwrapOrElse

      public T unwrapOrElse(Supplier<T> fx)
      Unwraps an Ok value and calls the supplier method if there is an error
      Parameters:
      fx -
      Returns:
    • unwrapErr

      public E unwrapErr()
      Unwraps the error and panics if the value is Ok
      Returns:
    • isErr

      public boolean isErr()
      Checks if the value is an error
      Returns:
    • isOk

      public boolean isOk()
      Checks if the value is ok
      Returns: