Class SafeCloseableArray<SCT extends SafeCloseable>

java.lang.Object
io.deephaven.util.SafeCloseableArray<SCT>
All Implemented Interfaces:
SafeCloseable, AutoCloseable

public class SafeCloseableArray<SCT extends SafeCloseable> extends Object implements SafeCloseable
SafeCloseable that will close non-null values inside of an array.

The common use case is to create an array; use the SafeCloseableArray in an ignored try-with-resources variable, and then populate the array within the loop. If you fail before populating the array nothing is closed, if you fail during or after populating the array the created values are closed.

  • Constructor Details

    • SafeCloseableArray

      public SafeCloseableArray(SCT[] entries)
  • Method Details

    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface SafeCloseable
    • close

      public static <SCT extends SafeCloseable> void close(@NotNull @NotNull SCT[] array)
      Close an array of SafeCloseable entries, ignoring null elements and assigning elements to null as they are cleared.
      Parameters:
      array - The array to operate one