Class Unchecked


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T,​U>
      java.util.function.BiConsumer<T,​U>
      consumer​(UncheckedBiConsumer<T,​U> consumer)
      Transforms the given (unchecked) bi-consumer into a regular bi-consumer.
      static <T> java.util.function.Consumer<T> consumer​(UncheckedConsumer<T> consumer)
      Transforms the given (unchecked) consumer into a regular consumer.
      static <T,​U,​R>
      java.util.function.BiFunction<T,​U,​R>
      function​(UncheckedBiFunction<T,​U,​R> function)
      Transforms the given (unchecked) bi-function into a regular bi-function.
      static <T,​R>
      java.util.function.Function<T,​R>
      function​(UncheckedFunction<T,​R> function)
      Transforms the given (unchecked) function into a regular function.
      static <T> java.util.function.Supplier<T> supplier​(UncheckedSupplier<T> supplier)
      Transforms the given (unchecked) supplier into a regular supplier.
      static <T,​U>
      UncheckedBiConsumer<T,​U>
      unchecked​(java.util.function.BiConsumer<T,​U> consumer)
      Transforms the given bi-consumer into a version that can throw exceptions.
      static <T,​U,​R>
      UncheckedBiFunction<T,​U,​R>
      unchecked​(java.util.function.BiFunction<T,​U,​R> function)
      Transforms the given bi-function into a version that can throw exceptions.
      static <T> UncheckedConsumer<T> unchecked​(java.util.function.Consumer<T> consumer)
      Transforms the given consumer into a version that can throw exceptions.
      static <T,​R>
      UncheckedFunction<T,​R>
      unchecked​(java.util.function.Function<T,​R> function)
      Transforms the given function into a version that can throw exceptions.
      static <T> UncheckedSupplier<T> unchecked​(java.util.function.Supplier<T> supplier)
      Transforms the given supplier into a version that can throw exceptions.
      • Methods inherited from class java.lang.Object

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

      • unchecked

        public static <T,​U,​R> UncheckedBiFunction<T,​U,​R> unchecked​(java.util.function.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​(java.util.function.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​(java.util.function.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​(java.util.function.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​(java.util.function.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> java.util.function.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> java.util.function.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> java.util.function.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> java.util.function.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> java.util.function.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.