Class Closer

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public final class Closer
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Helper that holds onto AutoCloseable resources and releases them when its #close method is called.

    Similar to com.google.common.io.Closer but can deal with AutoCloseable, and doesn't throw IOException.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<java.lang.AutoCloseable> list  
    • Constructor Summary

      Constructors 
      Constructor Description
      Closer()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <E extends java.lang.AutoCloseable>
      E
      add​(E e)
      Registers a resource.
      void close()  
      • Methods inherited from class java.lang.Object

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

      • list

        private final java.util.List<java.lang.AutoCloseable> list
    • Constructor Detail

      • Closer

        public Closer()
    • Method Detail

      • add

        public <E extends java.lang.AutoCloseable> E add​(E e)
        Registers a resource.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable