Class RepositoryUtils

    • Method Detail

      • runIgnoring

        public static <T> T runIgnoring​(Callable<T> callable,
                                        T fallback)
        Run ignoring any throwable. If an exception occurs, the fallback value is returned.
        Type Parameters:
        T - the return type
        Parameters:
        callable - the function to be executed
        fallback - the fallback value
        Returns:
        the t
      • unthrow

        public static <T> T unthrow​(Callable<T> supplier)
        Converts any exception thrown by the supplier to an UndeclaredThrowableException.
        Type Parameters:
        T - the return value
        Parameters:
        supplier - the supplier
        Returns:
        the t
      • rethrow

        public static <T,​E extends Throwable> T rethrow​(Class<E> rethrown,
                                                              Callable<T> supplier)
                                                       throws E extends Throwable
        Catches UndeclaredThrowableExceptions and unwraps any underlying exception of the given type.
        Type Parameters:
        T - the return type
        E - the type of exception that is unwrapped
        Parameters:
        rethrown - the type of exception that is rethrown
        supplier - the supplier
        Returns:
        the result from invoking the supplier
        Throws:
        E - the exception type
        E extends Throwable
      • rethrow

        public static <T,​E1 extends Throwable,​E2 extends Throwable> T rethrow​(Class<E1> rethrown1,
                                                                                          Class<E2> rethrown2,
                                                                                          Callable<T> function)
                                                                                   throws E1 extends Throwable,
                                                                                          E2 extends Throwable
        Catches UndeclaredThrowableExceptions and unwraps any underlying exception of the given type.
        Type Parameters:
        T - the return type
        E1 - the first exception type
        E2 - the second exception type
        Parameters:
        rethrown1 - the class of the first rethrown exception type
        rethrown2 - the class of the second rethrown exception type
        function - the function to be executed
        Returns:
        the result from invoking the supplier
        Throws:
        E1 - the e1
        E2 - the e2
        E1 extends Throwable