Class RxTry

java.lang.Object
io.github.venkateshamurthy.exceptional.RxTry

public class RxTry extends Object
A convenience set of utility methods making use of Try methods for callable, runnables etc
Author:
venkateshamurthy.
  • Field Details

  • Constructor Details

    • RxTry

      public RxTry()
  • Method Details

    • consumeFailure

      public <X1 extends Exception, X2 extends Exception, X3 extends Exception, R> io.vavr.control.Try<R> consumeFailure(io.vavr.control.Try<R> tryer, Class<X1> ex, Consumer<X1> op, Class<X2> ex2, Consumer<X2> op2, Class<X3> ex3, Consumer<X3> op3)
      Consume Failures while executing Try
      Type Parameters:
      X1 - Exception type
      X2 - Exception type 2nd
      X3 - Exception type 3rd
      R - Return type
      Parameters:
      tryer - A Try to be augmented with exception consumer
      ex - Class<Exception> that can be encountered
      op - Consumer that silently accepts the exception
      ex2 - Class<Exception> that can be encountered
      op2 - Consumer that silently accepts the exception
      ex3 - Class<Exception> that can be encountered
      op3 - Consumer that silently accepts the exceptionr
      Returns:
      Try
    • consumeFailure

      public <X1 extends Exception, X2 extends Exception, R> io.vavr.control.Try<R> consumeFailure(io.vavr.control.Try<R> tryer, Class<X1> ex, Consumer<X1> op, Class<X2> ex2, Consumer<X2> op2)
      Consume Failures while executing Try
      Type Parameters:
      X1 - Exception type
      X2 - Exception type 2nd
      R - Return type
      Parameters:
      tryer - A Try to be augmented with exception consumer
      ex - Class<Exception> that can be encountered
      op - Consumer that silently accepts the exception
      ex2 - Class<Exception> that can be encountered
      op2 - Consumer that silently accepts the exception
      Returns:
      Try
    • consumeFailure

      public <X extends Exception, R> io.vavr.control.Try<R> consumeFailure(io.vavr.control.Try<R> tryer, Class<X> ex, Consumer<X> op)
      Consume Failures while executing Try
      Type Parameters:
      X - Exception type
      R - Return type
      Parameters:
      tryer - A Try to be augmented with exception consumer
      ex - Class<Exception> that can be encountered
      op - Consumer that silently accepts the exception
      Returns:
      Try
    • mapException

      public <X extends Exception, R> io.vavr.control.Try<R> mapException(io.vavr.control.Try<R> tryer, Class<X> ex, Supplier<? extends Exception> op)
      Map/Trnsform Failures to desired exception while executing Try
      Type Parameters:
      X - Exception type
      R - Return type
      Parameters:
      tryer - A Try to be augmented with exception consumer
      ex - Class<Exception> that can be encountered
      op - Supplier of a new/different exception in lieu of exception encountered
      Returns:
      Try
    • mapException

      public <X extends Exception, R> io.vavr.control.Try<R> mapException(io.vavr.control.Try<R> tryer, Class<X> ex, UnaryOperator<Exception> op)
      Map/Trnsform Failures to desired exception while executing Try
      Type Parameters:
      X - Exception type
      R - Return type
      Parameters:
      tryer - A Try to be augmented with exception consumer
      ex - Class<Exception> that can be encountered
      op - Transform for the exception to be mapped to another
      Returns:
      Try
    • mapException

      public <X extends Exception, X2 extends Exception, R> io.vavr.control.Try<R> mapException(io.vavr.control.Try<R> tryer, Class<X> ex, UnaryOperator<Exception> op, Class<X2> ex2, UnaryOperator<Exception> op2)
      Map/Trnsform Failures to desired exception while executing Try
      Type Parameters:
      X - Exception type
      X2 - Exception type 2nd
      R - Return type
      Parameters:
      tryer - A Try to be augmented with exception consumer
      ex - Class<Exception> that can be encountered
      op - Transform for the exception to be mapped to another
      ex2 - Class<Exception> that can be encountered
      op2 - Transform for the exception to be mapped to another
      Returns:
      Try
    • mapException

      public <X extends Exception, X2 extends Exception, X3 extends Exception, R> io.vavr.control.Try<R> mapException(io.vavr.control.Try<R> tryer, Class<X> ex, UnaryOperator<Exception> op, Class<X2> ex2, UnaryOperator<Exception> op2, Class<X3> ex3, UnaryOperator<Exception> op3)
      Map/Trnsform Failures to desired exception while executing Try
      Type Parameters:
      X - Exception type
      X2 - Exception type 2nd
      X3 - Exception type 3rd
      R - Return type
      Parameters:
      tryer - A Try to be augmented with exception consumer
      ex - Class<Exception> that can be encountered
      op - Transform for the exception to be mapped to another
      ex2 - Class<Exception> that can be encountered
      op2 - Transform for the exception to be mapped to another
      ex3 - Class<Exception> that can be encountered
      op3 - Transform for the exception to be mapped to another
      Returns:
      Try
    • tryWrap

      public <T, T2, R> io.vavr.control.Try<R> tryWrap(io.github.resilience4j.core.functions.CheckedBiFunction<T,T2,R> checkedBiFunction, T t, T2 t2)
      Wrapping CheckedBiFunction with a Try.
      Type Parameters:
      T - first input type
      T2 - second input type
      R - result
      Parameters:
      checkedBiFunction - the CheckedBiFunction
      t - first input argument
      t2 - second input argument
      Returns:
      Try
    • tryWrap

      public <T, T2, R> io.vavr.control.Try<R> tryWrap(BiFunction<T,T2,R> biFunction, T t, T2 t2)
      Wrapping BiFunction with a Try.
      Type Parameters:
      T - first input type
      T2 - second input type
      R - result
      Parameters:
      biFunction - the BiFunction
      t - first input argument
      t2 - second input argument
      Returns:
      Try
    • tryWrap

      public <T, R> io.vavr.control.Try<R> tryWrap(io.github.resilience4j.core.functions.CheckedFunction<T,R> checkedFunction, T t)
      Wrapping CheckedFunction with a Try.
      Type Parameters:
      T - first input type
      R - result
      Parameters:
      checkedFunction - the CheckedFunction
      t - first input argument
      Returns:
      Try
    • tryWrap

      public <T, R> io.vavr.control.Try<R> tryWrap(Function<T,R> function, T t)
      Wrapping Function with a Try.
      Type Parameters:
      T - first input type
      R - result
      Parameters:
      function - the Function
      t - first input argument
      Returns:
      Try
    • tryWrap

      public <R> io.vavr.control.Try<R> tryWrap(Supplier<R> supplier)
      Wrapping Supplier with a Try
      Type Parameters:
      R - type of result
      Parameters:
      supplier - to be wrapped
      Returns:
      Try wrapping supplier
    • tryWrap

      public <R> io.vavr.control.Try<R> tryWrap(io.github.resilience4j.core.functions.CheckedSupplier<R> checkedSupplier)
      Wrapping CheckedSupplier with a Try
      Type Parameters:
      R - type of result
      Parameters:
      checkedSupplier - to be wrapped
      Returns:
      Try wrapping checkedSupplier
    • tryWrap

      public <R> io.vavr.control.Try<R> tryWrap(Callable<R> callable)
      Wrapping Callable with a Try
      Type Parameters:
      R - type of result
      Parameters:
      callable - to be wrapped
      Returns:
      Try wrapping callable
    • tryWrap

      public io.vavr.control.Try<Void> tryWrap(Runnable runnable)
      Wrapping Runnable with q Try
      Parameters:
      runnable - to be wrapped
      Returns:
      Try wrapping runnable
    • tryWrap

      public io.vavr.control.Try<Void> tryWrap(io.github.resilience4j.core.functions.CheckedRunnable runnable)
      Wrapping CheckedRunnable with q Try
      Parameters:
      runnable - to be wrapped
      Returns:
      Try wrapping runnable