noexception
HomeJavadocSources
com.machinezoo.noexception

Class CheckedExceptionHandler

NoException » API Reference » com.machinezoo.noexception



  • public abstract class CheckedExceptionHandler
    extends Object
    Represents downgrading policy for checked exceptions. The exception policy is akin to a reusable catch block that catches checked exception and throws an unchecked one. Method handle(Exception) defines downgrading mechanism, typically by wrapping the checked exception in an unchecked one, but there are special cases like Exceptions.sneak(), which downgrade only method signature without altering the exception itself. Methods of this class apply the exception policy to functional interfaces (usually lambdas) by wrapping them in a try-catch block. See noexception tutorial.
    Typical usage: Exceptions.sneak().get(() -> my_throwing_lambda)
    CheckedExceptionHandler does not stop propagation of any exceptions (checked or unchecked). ExceptionHandler is used for that purpose. The two classes can be used together by first downgrading checked exceptions with CheckedExceptionHandler and then applying exception handling policy with ExceptionHandler.
    Combined usage: Exceptions.log().get(Exceptions.sneak().supplier(() -> my_throwing_lambda)).orElse(fallback)
    All wrapping methods surround the functional interface with a try-catch block. Only checked exceptions are handled. Unchecked exceptions are propagated to caller. If the functional interface throws checked exception, the exception is caught and passed to handle(Exception), which converts it to an unchecked exception, which is then thrown.
    Wrapping methods for all standard functional interfaces are provided. Simple interfaces have short method names, like runnable(ThrowingRunnable) or supplier(ThrowingSupplier). Interfaces with longer names have methods that follow fromX naming pattern, for example fromUnaryOperator(ThrowingUnaryOperator). Parameterless functional interfaces can be called directly by methods run(ThrowingRunnable), get(ThrowingSupplier), and the various getAsX variants. All methods take throwing versions of standard functional interfaces, for example ThrowingRunnable or ThrowingSupplier.
    See Also:
    Tutorial, handle(Exception), Exceptions, ExceptionHandler
    • Constructor Detail

      • CheckedExceptionHandler

        protected CheckedExceptionHandler()
        Initialize new CheckedExceptionHandler.
    • Method Detail

      • handle

        public abstract RuntimeException handle(Exception exception)
        Convert checked exception into an unchecked one. This method must be defined in a derived class. Several implementations are provided by methods on Exceptions class. All other methods of the CheckedExceptionHandler call this method, but it can be also called directly.
        This method represents reusable catch block that handles all checked exceptions in the same way. When invoked, it must somehow convert the checked exception into an unchecked one, usually by wrapping it. Caller is then expected to throw the returned exception. There can be special cases like Exceptions.sneak(), which don't return at all.
        Callers should not pass in RuntimeException or other unchecked exceptions. This method might erroneously wrap such exceptions as if they are checked exceptions. Methods of this class never pass unchecked exceptions to this method.
        Parameters:
        exception - checked exception to convert
        Returns:
        converted unchecked exception
        Throws:
        NullPointerException - if exception is null
        See Also:
        Tutorial, Exceptions
      • runnable

        public final Runnable runnable(ThrowingRunnable runnable)
        Remove checked exceptions from method signature of Runnable.
        If runnable throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null runnable is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingRunnable(Exceptions.sneak().runnable(() -> my_throwing_lambda))
        Parameters:
        runnable - the ThrowingRunnable to be converted, usually a lambda
        Returns:
        converted Runnable free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • supplier

        public final <T> Supplier<T> supplier(ThrowingSupplier<T> supplier)
        Remove checked exceptions from method signature of Supplier.
        If supplier throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null supplier is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingSupplier(Exceptions.sneak().supplier(() -> my_throwing_lambda))
        Parameters:
        supplier - the ThrowingSupplier to be converted, usually a lambda
        Returns:
        converted Supplier free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromIntSupplier

        public final IntSupplier fromIntSupplier(ThrowingIntSupplier supplier)
        Remove checked exceptions from method signature of IntSupplier.
        If supplier throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null supplier is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingIntSupplier(Exceptions.sneak().fromIntSupplier(() -> my_throwing_lambda))
        Parameters:
        supplier - the ThrowingIntSupplier to be converted, usually a lambda
        Returns:
        converted IntSupplier free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromLongSupplier

        public final LongSupplier fromLongSupplier(ThrowingLongSupplier supplier)
        Remove checked exceptions from method signature of LongSupplier.
        If supplier throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null supplier is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingLongSupplier(Exceptions.sneak().fromLongSupplier(() -> my_throwing_lambda))
        Parameters:
        supplier - the ThrowingLongSupplier to be converted, usually a lambda
        Returns:
        converted LongSupplier free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromDoubleSupplier

        public final DoubleSupplier fromDoubleSupplier(ThrowingDoubleSupplier supplier)
        Remove checked exceptions from method signature of DoubleSupplier.
        If supplier throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null supplier is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingDoubleSupplier(Exceptions.sneak().fromDoubleSupplier(() -> my_throwing_lambda))
        Parameters:
        supplier - the ThrowingDoubleSupplier to be converted, usually a lambda
        Returns:
        converted DoubleSupplier free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromBooleanSupplier

        public final BooleanSupplier fromBooleanSupplier(ThrowingBooleanSupplier supplier)
        Remove checked exceptions from method signature of BooleanSupplier.
        If supplier throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null supplier is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingBooleanSupplier(Exceptions.sneak().fromBooleanSupplier(() -> my_throwing_lambda))
        Parameters:
        supplier - the ThrowingBooleanSupplier to be converted, usually a lambda
        Returns:
        converted BooleanSupplier free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • consumer

        public final <T> Consumer<T> consumer(ThrowingConsumer<T> consumer)
        Remove checked exceptions from method signature of Consumer.
        If consumer throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null consumer is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingConsumer(Exceptions.sneak().consumer(t -> my_throwing_lambda))
        Parameters:
        consumer - the ThrowingConsumer to be converted, usually a lambda
        Returns:
        converted Consumer free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromIntConsumer

        public final IntConsumer fromIntConsumer(ThrowingIntConsumer consumer)
        Remove checked exceptions from method signature of IntConsumer.
        If consumer throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null consumer is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingIntConsumer(Exceptions.sneak().fromIntConsumer(v -> my_throwing_lambda))
        Parameters:
        consumer - the ThrowingIntConsumer to be converted, usually a lambda
        Returns:
        converted IntConsumer free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromLongConsumer

        public final LongConsumer fromLongConsumer(ThrowingLongConsumer consumer)
        Remove checked exceptions from method signature of LongConsumer.
        If consumer throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null consumer is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingLongConsumer(Exceptions.sneak().fromLongConsumer(v -> my_throwing_lambda))
        Parameters:
        consumer - the ThrowingLongConsumer to be converted, usually a lambda
        Returns:
        converted LongConsumer free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromDoubleConsumer

        public final DoubleConsumer fromDoubleConsumer(ThrowingDoubleConsumer consumer)
        Remove checked exceptions from method signature of DoubleConsumer.
        If consumer throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null consumer is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingDoubleConsumer(Exceptions.sneak().fromDoubleConsumer(v -> my_throwing_lambda))
        Parameters:
        consumer - the ThrowingDoubleConsumer to be converted, usually a lambda
        Returns:
        converted DoubleConsumer free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromBiConsumer

        public final <T,U> BiConsumer<T,U> fromBiConsumer(ThrowingBiConsumer<T,U> consumer)
        Remove checked exceptions from method signature of BiConsumer.
        If consumer throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null consumer is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingBiConsumer(Exceptions.sneak().fromBiConsumer((t, u) -> my_throwing_lambda))
        Parameters:
        consumer - the ThrowingBiConsumer to be converted, usually a lambda
        Returns:
        converted BiConsumer free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromObjIntConsumer

        public final <T> ObjIntConsumer<T> fromObjIntConsumer(ThrowingObjIntConsumer<T> consumer)
        Remove checked exceptions from method signature of ObjIntConsumer.
        If consumer throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null consumer is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingObjIntConsumer(Exceptions.sneak().fromObjIntConsumer((t, v) -> my_throwing_lambda))
        Parameters:
        consumer - the ThrowingObjIntConsumer to be converted, usually a lambda
        Returns:
        converted ObjIntConsumer free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromObjLongConsumer

        public final <T> ObjLongConsumer<T> fromObjLongConsumer(ThrowingObjLongConsumer<T> consumer)
        Remove checked exceptions from method signature of ObjLongConsumer.
        If consumer throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null consumer is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingObjLongConsumer(Exceptions.sneak().fromObjLongConsumer((t, v) -> my_throwing_lambda))
        Parameters:
        consumer - the ThrowingObjLongConsumer to be converted, usually a lambda
        Returns:
        converted ObjLongConsumer free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromObjDoubleConsumer

        public final <T> ObjDoubleConsumer<T> fromObjDoubleConsumer(ThrowingObjDoubleConsumer<T> consumer)
        Remove checked exceptions from method signature of ObjDoubleConsumer.
        If consumer throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null consumer is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingObjDoubleConsumer(Exceptions.sneak().fromObjDoubleConsumer((t, v) -> my_throwing_lambda))
        Parameters:
        consumer - the ThrowingObjDoubleConsumer to be converted, usually a lambda
        Returns:
        converted ObjDoubleConsumer free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • predicate

        public final <T> Predicate<T> predicate(ThrowingPredicate<T> predicate)
        Remove checked exceptions from method signature of Predicate.
        If predicate throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null predicate is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingPredicate(Exceptions.sneak().predicate(t -> my_throwing_lambda))
        Parameters:
        predicate - the ThrowingPredicate to be converted, usually a lambda
        Returns:
        converted Predicate free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromIntPredicate

        public final IntPredicate fromIntPredicate(ThrowingIntPredicate predicate)
        Remove checked exceptions from method signature of IntPredicate.
        If predicate throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null predicate is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingIntPredicate(Exceptions.sneak().fromIntPredicate(v -> my_throwing_lambda))
        Parameters:
        predicate - the ThrowingIntPredicate to be converted, usually a lambda
        Returns:
        converted IntPredicate free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromLongPredicate

        public final LongPredicate fromLongPredicate(ThrowingLongPredicate predicate)
        Remove checked exceptions from method signature of LongPredicate.
        If predicate throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null predicate is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingLongPredicate(Exceptions.sneak().fromLongPredicate(v -> my_throwing_lambda))
        Parameters:
        predicate - the ThrowingLongPredicate to be converted, usually a lambda
        Returns:
        converted LongPredicate free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromDoublePredicate

        public final DoublePredicate fromDoublePredicate(ThrowingDoublePredicate predicate)
        Remove checked exceptions from method signature of DoublePredicate.
        If predicate throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null predicate is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingDoublePredicate(Exceptions.sneak().fromDoublePredicate(v -> my_throwing_lambda))
        Parameters:
        predicate - the ThrowingDoublePredicate to be converted, usually a lambda
        Returns:
        converted DoublePredicate free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromBiPredicate

        public final <T,U> BiPredicate<T,U> fromBiPredicate(ThrowingBiPredicate<T,U> predicate)
        Remove checked exceptions from method signature of BiPredicate.
        If predicate throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null predicate is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingBiPredicate(Exceptions.sneak().fromBiPredicate((t, u) -> my_throwing_lambda))
        Parameters:
        predicate - the ThrowingBiPredicate to be converted, usually a lambda
        Returns:
        converted BiPredicate free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • function

        public final <T,R> Function<T,R> function(ThrowingFunction<T,R> function)
        Remove checked exceptions from method signature of Function.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingFunction(Exceptions.sneak().function(t -> my_throwing_lambda))
        Parameters:
        function - the ThrowingFunction to be converted, usually a lambda
        Returns:
        converted Function free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromToIntFunction

        public final <T> ToIntFunction<T> fromToIntFunction(ThrowingToIntFunction<T> function)
        Remove checked exceptions from method signature of ToIntFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingToIntFunction(Exceptions.sneak().fromToIntFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingToIntFunction to be converted, usually a lambda
        Returns:
        converted ToIntFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromIntFunction

        public final <R> IntFunction<R> fromIntFunction(ThrowingIntFunction<R> function)
        Remove checked exceptions from method signature of IntFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingIntFunction(Exceptions.sneak().fromIntFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingIntFunction to be converted, usually a lambda
        Returns:
        converted IntFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromIntToLongFunction

        public final IntToLongFunction fromIntToLongFunction(ThrowingIntToLongFunction function)
        Remove checked exceptions from method signature of IntToLongFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingIntToLongFunction(Exceptions.sneak().fromIntToLongFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingIntToLongFunction to be converted, usually a lambda
        Returns:
        converted IntToLongFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromIntToDoubleFunction

        public final IntToDoubleFunction fromIntToDoubleFunction(ThrowingIntToDoubleFunction function)
        Remove checked exceptions from method signature of IntToDoubleFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingIntToDoubleFunction(Exceptions.sneak().fromIntToDoubleFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingIntToDoubleFunction to be converted, usually a lambda
        Returns:
        converted IntToDoubleFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromToLongFunction

        public final <T> ToLongFunction<T> fromToLongFunction(ThrowingToLongFunction<T> function)
        Remove checked exceptions from method signature of ToLongFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingToLongFunction(Exceptions.sneak().fromToLongFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingToLongFunction to be converted, usually a lambda
        Returns:
        converted ToLongFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromLongFunction

        public final <R> LongFunction<R> fromLongFunction(ThrowingLongFunction<R> function)
        Remove checked exceptions from method signature of LongFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingLongFunction(Exceptions.sneak().fromLongFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingLongFunction to be converted, usually a lambda
        Returns:
        converted LongFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromLongToIntFunction

        public final LongToIntFunction fromLongToIntFunction(ThrowingLongToIntFunction function)
        Remove checked exceptions from method signature of LongToIntFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingLongToIntFunction(Exceptions.sneak().fromLongToIntFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingLongToIntFunction to be converted, usually a lambda
        Returns:
        converted LongToIntFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromLongToDoubleFunction

        public final LongToDoubleFunction fromLongToDoubleFunction(ThrowingLongToDoubleFunction function)
        Remove checked exceptions from method signature of LongToDoubleFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingLongToDoubleFunction(Exceptions.sneak().fromLongToDoubleFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingLongToDoubleFunction to be converted, usually a lambda
        Returns:
        converted LongToDoubleFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromToDoubleFunction

        public final <T> ToDoubleFunction<T> fromToDoubleFunction(ThrowingToDoubleFunction<T> function)
        Remove checked exceptions from method signature of ToDoubleFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingToDoubleFunction(Exceptions.sneak().fromToDoubleFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingToDoubleFunction to be converted, usually a lambda
        Returns:
        converted ToDoubleFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromDoubleFunction

        public final <R> DoubleFunction<R> fromDoubleFunction(ThrowingDoubleFunction<R> function)
        Remove checked exceptions from method signature of DoubleFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingDoubleFunction(Exceptions.sneak().fromDoubleFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingDoubleFunction to be converted, usually a lambda
        Returns:
        converted DoubleFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromDoubleToIntFunction

        public final DoubleToIntFunction fromDoubleToIntFunction(ThrowingDoubleToIntFunction function)
        Remove checked exceptions from method signature of DoubleToIntFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingDoubleToIntFunction(Exceptions.sneak().fromDoubleToIntFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingDoubleToIntFunction to be converted, usually a lambda
        Returns:
        converted DoubleToIntFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromDoubleToLongFunction

        public final DoubleToLongFunction fromDoubleToLongFunction(ThrowingDoubleToLongFunction function)
        Remove checked exceptions from method signature of DoubleToLongFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingDoubleToLongFunction(Exceptions.sneak().fromDoubleToLongFunction(v -> my_throwing_lambda))
        Parameters:
        function - the ThrowingDoubleToLongFunction to be converted, usually a lambda
        Returns:
        converted DoubleToLongFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromUnaryOperator

        public final <T> UnaryOperator<T> fromUnaryOperator(ThrowingUnaryOperator<T> operator)
        Remove checked exceptions from method signature of UnaryOperator.
        If operator throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null operator is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingUnaryOperator(Exceptions.sneak().fromUnaryOperator(o -> my_throwing_lambda))
        Parameters:
        operator - the ThrowingUnaryOperator to be converted, usually a lambda
        Returns:
        converted UnaryOperator free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromIntUnaryOperator

        public final IntUnaryOperator fromIntUnaryOperator(ThrowingIntUnaryOperator operator)
        Remove checked exceptions from method signature of IntUnaryOperator.
        If operator throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null operator is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingIntUnaryOperator(Exceptions.sneak().fromIntUnaryOperator(o -> my_throwing_lambda))
        Parameters:
        operator - the ThrowingIntUnaryOperator to be converted, usually a lambda
        Returns:
        converted IntUnaryOperator free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromLongUnaryOperator

        public final LongUnaryOperator fromLongUnaryOperator(ThrowingLongUnaryOperator operator)
        Remove checked exceptions from method signature of LongUnaryOperator.
        If operator throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null operator is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingLongUnaryOperator(Exceptions.sneak().fromLongUnaryOperator(o -> my_throwing_lambda))
        Parameters:
        operator - the ThrowingLongUnaryOperator to be converted, usually a lambda
        Returns:
        converted LongUnaryOperator free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromDoubleUnaryOperator

        public final DoubleUnaryOperator fromDoubleUnaryOperator(ThrowingDoubleUnaryOperator operator)
        Remove checked exceptions from method signature of DoubleUnaryOperator.
        If operator throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null operator is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingDoubleUnaryOperator(Exceptions.sneak().fromDoubleUnaryOperator(o -> my_throwing_lambda))
        Parameters:
        operator - the ThrowingDoubleUnaryOperator to be converted, usually a lambda
        Returns:
        converted DoubleUnaryOperator free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromBiFunction

        public final <T,U,R> BiFunction<T,U,R> fromBiFunction(ThrowingBiFunction<T,U,R> function)
        Remove checked exceptions from method signature of BiFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingBiFunction(Exceptions.sneak().fromBiFunction((t, u) -> my_throwing_lambda))
        Parameters:
        function - the ThrowingBiFunction to be converted, usually a lambda
        Returns:
        converted BiFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromToIntBiFunction

        public final <T,U> ToIntBiFunction<T,U> fromToIntBiFunction(ThrowingToIntBiFunction<T,U> function)
        Remove checked exceptions from method signature of ToIntBiFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingToIntBiFunction(Exceptions.sneak().fromToIntBiFunction((t, u) -> my_throwing_lambda))
        Parameters:
        function - the ThrowingToIntBiFunction to be converted, usually a lambda
        Returns:
        converted ToIntBiFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromToLongBiFunction

        public final <T,U> ToLongBiFunction<T,U> fromToLongBiFunction(ThrowingToLongBiFunction<T,U> function)
        Remove checked exceptions from method signature of ToLongBiFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingToLongBiFunction(Exceptions.sneak().fromToLongBiFunction((t, u) -> my_throwing_lambda))
        Parameters:
        function - the ThrowingToLongBiFunction to be converted, usually a lambda
        Returns:
        converted ToLongBiFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromToDoubleBiFunction

        public final <T,U> ToDoubleBiFunction<T,U> fromToDoubleBiFunction(ThrowingToDoubleBiFunction<T,U> function)
        Remove checked exceptions from method signature of ToDoubleBiFunction.
        If function throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null function is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingToDoubleBiFunction(Exceptions.sneak().fromToDoubleBiFunction((t, u) -> my_throwing_lambda))
        Parameters:
        function - the ThrowingToDoubleBiFunction to be converted, usually a lambda
        Returns:
        converted ToDoubleBiFunction free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromBinaryOperator

        public final <T> BinaryOperator<T> fromBinaryOperator(ThrowingBinaryOperator<T> operator)
        Remove checked exceptions from method signature of BinaryOperator.
        If operator throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null operator is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingBinaryOperator(Exceptions.sneak().fromBinaryOperator((l, r) -> my_throwing_lambda))
        Parameters:
        operator - the ThrowingBinaryOperator to be converted, usually a lambda
        Returns:
        converted BinaryOperator free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromIntBinaryOperator

        public final IntBinaryOperator fromIntBinaryOperator(ThrowingIntBinaryOperator operator)
        Remove checked exceptions from method signature of IntBinaryOperator.
        If operator throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null operator is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingIntBinaryOperator(Exceptions.sneak().fromIntBinaryOperator((l, r) -> my_throwing_lambda))
        Parameters:
        operator - the ThrowingIntBinaryOperator to be converted, usually a lambda
        Returns:
        converted IntBinaryOperator free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromLongBinaryOperator

        public final LongBinaryOperator fromLongBinaryOperator(ThrowingLongBinaryOperator operator)
        Remove checked exceptions from method signature of LongBinaryOperator.
        If operator throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null operator is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingLongBinaryOperator(Exceptions.sneak().fromLongBinaryOperator((l, r) -> my_throwing_lambda))
        Parameters:
        operator - the ThrowingLongBinaryOperator to be converted, usually a lambda
        Returns:
        converted LongBinaryOperator free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • fromDoubleBinaryOperator

        public final DoubleBinaryOperator fromDoubleBinaryOperator(ThrowingDoubleBinaryOperator operator)
        Remove checked exceptions from method signature of DoubleBinaryOperator.
        If operator throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null operator is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingDoubleBinaryOperator(Exceptions.sneak().fromDoubleBinaryOperator((l, r) -> my_throwing_lambda))
        Parameters:
        operator - the ThrowingDoubleBinaryOperator to be converted, usually a lambda
        Returns:
        converted DoubleBinaryOperator free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • comparator

        public final <T> Comparator<T> comparator(ThrowingComparator<T> comparator)
        Remove checked exceptions from method signature of Comparator.
        If comparator throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Null comparator is silently wrapped and causes NullPointerException when executed.
        Typical usage: methodTakingComparator(Exceptions.sneak().comparator((l, r) -> my_throwing_lambda))
        Parameters:
        comparator - the ThrowingComparator to be converted, usually a lambda
        Returns:
        converted Comparator free of checked exceptions
        See Also:
        Tutorial, Exceptions
      • run

        public final void run(ThrowingRunnable runnable)
        Filter out checked exceptions while running Runnable.
        If runnable throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.
        Typical usage: Exceptions.sneak().run(() -> my_throwing_lambda))
        Parameters:
        runnable - the ThrowingRunnable to be converted, usually a lambda
        Throws:
        NullPointerException - if runnable is null
        See Also:
        Tutorial, Exceptions
      • get

        public final <T> T get(ThrowingSupplier<T> supplier)
        Filter out checked exceptions while running Supplier.
        If supplier throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.
        Typical usage: Exceptions.sneak().get(() -> my_throwing_lambda))
        Parameters:
        supplier - the ThrowingSupplier to be converted, usually a lambda
        Returns:
        value returned from supplier
        Throws:
        NullPointerException - if supplier is null
        See Also:
        Tutorial, Exceptions
      • getAsInt

        public final int getAsInt(ThrowingIntSupplier supplier)
        Filter out checked exceptions while running IntSupplier.
        If supplier throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.
        Typical usage: Exceptions.sneak().getAsInt(() -> my_throwing_lambda))
        Parameters:
        supplier - the ThrowingIntSupplier to be converted, usually a lambda
        Returns:
        value returned from supplier
        Throws:
        NullPointerException - if supplier is null
        See Also:
        Tutorial, Exceptions
      • getAsLong

        public final long getAsLong(ThrowingLongSupplier supplier)
        Filter out checked exceptions while running LongSupplier.
        If supplier throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.
        Typical usage: Exceptions.sneak().getAsLong(() -> my_throwing_lambda))
        Parameters:
        supplier - the ThrowingLongSupplier to be converted, usually a lambda
        Returns:
        value returned from supplier
        Throws:
        NullPointerException - if supplier is null
        See Also:
        Tutorial, Exceptions
      • getAsDouble

        public final double getAsDouble(ThrowingDoubleSupplier supplier)
        Filter out checked exceptions while running DoubleSupplier.
        If supplier throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.
        Typical usage: Exceptions.sneak().getAsDouble(() -> my_throwing_lambda))
        Parameters:
        supplier - the ThrowingDoubleSupplier to be converted, usually a lambda
        Returns:
        value returned from supplier
        Throws:
        NullPointerException - if supplier is null
        See Also:
        Tutorial, Exceptions
      • getAsBoolean

        public final boolean getAsBoolean(ThrowingBooleanSupplier supplier)
        Filter out checked exceptions while running BooleanSupplier.
        If supplier throws a checked exception, the exception is caught and passed to handle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.
        Typical usage: Exceptions.sneak().getAsBoolean(() -> my_throwing_lambda))
        Parameters:
        supplier - the ThrowingBooleanSupplier to be converted, usually a lambda
        Returns:
        value returned from supplier
        Throws:
        NullPointerException - if supplier is null
        See Also:
        Tutorial, Exceptions