Class AutoClosed<T>

  • Type Parameters:
    T - The type of the arbitrary object which will have an operation invoked on exiting from a try-with-resources block.
    All Implemented Interfaces:
    AutoCloseable

    public final class AutoClosed<T>
    extends Object
    implements AutoCloseable
    An adapter to enable any arbitrary object to be managed by the try-with-resources facility of Java >= 7, i.e. it will have a closing operation invoked when exiting the try-block.
    • Constructor Detail

      • AutoClosed

        public AutoClosed​(T managedObject,
                          Consumer<? super T> closeOperation)