Class IoTools.Quiet<C extends AutoCloseable>

    • Field Detail

      • logger

        protected final Logger logger
        The logger to which to log an occurred exception or null to wrap the exception as RuntimeException.
    • Constructor Detail

      • Quiet

        protected Quiet​(C wrapped,
                        Logger logger)
        Creates a new unconditional closeable wrapping the designated AutoCloseable logging or wrapping any exception from AutoCloseable.close().
        Parameters:
        wrapped - The wrapped AutoCloseable.
        logger - The logger to which to log an occurred exception or null to wrap the exception as RuntimeException.
      • Quiet

        protected Quiet​(Supplier<Boolean> condition,
                        C wrapped,
                        Logger logger)
        Creates a new conditional closeable wrapping the designated AutoCloseable logging or wrapping any exception from AutoCloseable.close().
        Parameters:
        condition - The optional condition allowing for conditional closing or null for unconditional closing.
        wrapped - The wrapped AutoCloseable.
        logger - The logger to which to log an occurred exception or null to wrap the exception as RuntimeException.
    • Method Detail

      • close

        public void close()
        Closes the wrapped AutoCloseable (depending on the condition) and logs any Exception.