Class Unchecked

java.lang.Object
io.smallrye.mutiny.unchecked.Unchecked

public class Unchecked extends Object
Provides wrapper to handle functions / consumers / suppliers that throw checked exceptions.
  • Method Details

    • unchecked

      public static <T, U, R> UncheckedBiFunction<T,U,R> unchecked(BiFunction<T,U,R> function)
      Transforms the given bi-function into a version that can throw exceptions.
      Type Parameters:
      T - the type of the first argument to the function
      U - the type of the second argument to the function
      R - the type of the result of the function
      Parameters:
      function - the function
      Returns:
      the new UncheckedBiFunction
    • unchecked

      public static <T, R> UncheckedFunction<T,R> unchecked(Function<T,R> function)
      Transforms the given function into a version that can throw exceptions.
      Type Parameters:
      T - the type of the argument to the function
      R - the type of the result of the function
      Parameters:
      function - the function
      Returns:
      the new UncheckedFunction
    • unchecked

      public static <T> UncheckedConsumer<T> unchecked(Consumer<T> consumer)
      Transforms the given consumer into a version that can throw exceptions.
      Type Parameters:
      T - the type of the input to the operation
      Parameters:
      consumer - the consumer
      Returns:
      the new UncheckedConsumer
    • unchecked

      public static <T, U> UncheckedBiConsumer<T,U> unchecked(BiConsumer<T,U> consumer)
      Transforms the given bi-consumer into a version that can throw exceptions.
      Type Parameters:
      T - the type of the first argument to the operation
      U - the type of the second argument to the operation
      Parameters:
      consumer - the consumer
      Returns:
      the new UncheckedBiConsumer
    • unchecked

      public static <T> UncheckedSupplier<T> unchecked(Supplier<T> supplier)
      Transforms the given supplier into a version that can throw exceptions.
      Type Parameters:
      T - the type of items supplied by this supplier
      Parameters:
      supplier - the supplier
      Returns:
      the new UncheckedSupplier
    • function

      public static <T, R> Function<T,R> function(UncheckedFunction<T,R> function)
      Transforms the given (unchecked) function into a regular function. If the operation throws an exception, this exception is rethrown, wrapped into a RuntimeException if needed.
      Type Parameters:
      T - the type of the argument to the function
      R - the type of the result of the function
      Parameters:
      function - the function
      Returns:
      a Function executing the UncheckedFunction. If the operation throws an exception, the exception is rethrown, wrapped in a RuntimeException if needed.
    • function

      public static <T, U, R> BiFunction<T,U,R> function(UncheckedBiFunction<T,U,R> function)
      Transforms the given (unchecked) bi-function into a regular bi-function. If the operation throws an exception, this exception is rethrown, wrapped into a RuntimeException if needed.
      Type Parameters:
      T - the type of the first argument to the function
      U - the type of the second argument to the function
      R - the type of the result of the function
      Parameters:
      function - the function
      Returns:
      a BiFunction executing this UncheckedBiFunction. If the operation throws an exception, the exception is rethrown, wrapped in a RuntimeException if needed.
    • consumer

      public static <T, U> BiConsumer<T,U> consumer(UncheckedBiConsumer<T,U> consumer)
      Transforms the given (unchecked) bi-consumer into a regular bi-consumer. If the operation throws an exception, this exception is rethrown, wrapped into a RuntimeException if needed.
      Type Parameters:
      T - the type of the first argument to the operation
      U - the type of the second argument to the operation
      Parameters:
      consumer - the consumer
      Returns:
      a BiConsumer executing this UncheckedBiConsumer. If the operation throws an exception, the exception is rethrown, wrapped in a RuntimeException if needed.
    • consumer

      public static <T> Consumer<T> consumer(UncheckedConsumer<T> consumer)
      Transforms the given (unchecked) consumer into a regular consumer. If the operation throws an exception, this exception is rethrown, wrapped into a RuntimeException if needed.
      Type Parameters:
      T - the type of the first argument to the operation
      Parameters:
      consumer - the consumer
      Returns:
      a Consumer executing this UncheckedConsumer. If the operation throws an exception, the exception is rethrown, wrapped in a RuntimeException if needed.
    • supplier

      public static <T> Supplier<T> supplier(UncheckedSupplier<T> supplier)
      Transforms the given (unchecked) supplier into a regular supplier. If the operation throws an exception, this exception is rethrown, wrapped into a RuntimeException if needed.
      Type Parameters:
      T - the type of items supplied by this supplier
      Parameters:
      supplier - the supplier
      Returns:
      a Supplier executing this UncheckedSupplier. If the operation throws an exception, the exception is rethrown, wrapped in a RuntimeException if needed.