Class TryAndLog


  • public class TryAndLog
    extends java.lang.Object
    Static methods to build a try/catch chain.
    Since:
    0.2
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Try tryAndLog​(java.lang.Runnable runnable)
      Executes runnable and returns Try for further processing.
      static Try tryAndLog​(java.lang.Runnable runnable, org.slf4j.Logger logger)
      Executes runnable and returns Try for further processing.
      static <T> TryWithResult<T> tryAndLogWithResult​(java.util.function.Supplier<T> supplier)
      Executes supplier and returns TryWithResult to build a try/catch chain.
      static <T> TryWithResult<T> tryAndLogWithResult​(java.util.function.Supplier<T> supplier, org.slf4j.Logger logger)
      Executes supplier and returns TryWithResult to build a try/catch chain.
      • Methods inherited from class java.lang.Object

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

      • tryAndLogWithResult

        public static <T> TryWithResult<T> tryAndLogWithResult​(java.util.function.Supplier<T> supplier)
        Executes supplier and returns TryWithResult to build a try/catch chain.
        Type Parameters:
        T - The type of the supplied value
        Parameters:
        supplier - The supplier to be executed
        Returns:
        TryWithResult for further processing
      • tryAndLogWithResult

        public static <T> TryWithResult<T> tryAndLogWithResult​(java.util.function.Supplier<T> supplier,
                                                               org.slf4j.Logger logger)
        Executes supplier and returns TryWithResult to build a try/catch chain.
        Type Parameters:
        T - The type of the supplied value
        Parameters:
        supplier - The supplier to be executed
        logger - The logger to be used for logging the exception message
        Returns:
        TryWithResult for further processing
      • tryAndLog

        public static Try tryAndLog​(java.lang.Runnable runnable)
        Executes runnable and returns Try for further processing.
        Parameters:
        runnable - The runnable to be executed
        Returns:
        TryWithResult for further processing
      • tryAndLog

        public static Try tryAndLog​(java.lang.Runnable runnable,
                                    org.slf4j.Logger logger)
        Executes runnable and returns Try for further processing.
        Parameters:
        runnable - The runnable to be executed
        logger - The logger to be used for logging the exception message
        Returns:
        TryWithResult for further processing