Class RereadableContentBuilder.RcbCleanup

java.lang.Object
de.aristaflow.adept2.util.CleanupTask.AbstractCleanupTask<IOException>
de.aristaflow.adept2.util.io.RereadableContentBuilder.RcbCleanup
All Implemented Interfaces:
CleanupTask<IOException>
Enclosing class:
RereadableContentBuilder

protected static final class RereadableContentBuilder.RcbCleanup extends CleanupTask.AbstractCleanupTask<IOException>
The CleanupTask doing the clean-up (RereadableContentBuilder.close()) independently from the RereadableContentBuilder. This allows to use it as post-mortem action of the RereadableContentBuilder.
This will close the output if not done yet and delete the temporary file if present and no RereadableContent has been built.
  • Field Details

    • state

      protected final de.aristaflow.adept2.util.io.RereadableContentBuilder.RcbState state
      The state of the RereadableContentBuilder containing all mutable fields required for clean-up.
  • Constructor Details

    • RcbCleanup

      protected RcbCleanup(de.aristaflow.adept2.util.io.RereadableContentBuilder.RcbState state)
      Creates a new clean-up for closing as post-mortem action of a RereadableContentBuilder. Also used for RereadableContentBuilder.close() explicit clean-up.
      Parameters:
      state - The state of the RereadableContentBuilder containing all mutable fields required for clean-up.
  • Method Details

    • cleanup

      public void cleanup(boolean explicit) throws IOException
      Closes the output stream and deletes the temporary file if no RereadableContent has been built. This also resets the RereadableContentBuilder.state appropriately.
      Parameters:
      explicit - Whether the clean-up was triggered explicitly via Cleanup.clean(). Otherwise it was triggered implicitly as a post-mortem action by the object becoming phantom reachable.
      Throws:
      IOException - If closing or deleting fails, an IOException will be thrown.