Class BaseResultProducingCloseable<T>

java.lang.Object
net.sourceforge.pmd.util.BaseResultProducingCloseable<T>
Type Parameters:
T - Type of the result
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
GlobalAnalysisListener.ViolationCounterListener, Report.GlobalReportBuilderListener, Report.ReportBuilderListener, ReportStatsListener

public abstract class BaseResultProducingCloseable<T> extends Object implements AutoCloseable
Base class for an autocloseable that produce a result once it has been closed. None of the methods of this class are synchronized.
  • Constructor Details

    • BaseResultProducingCloseable

      public BaseResultProducingCloseable()
  • Method Details

    • ensureOpen

      protected final void ensureOpen()
    • getResult

      public final T getResult()
      Returns the result.
      Throws:
      IllegalStateException - If this instance has not been closed yet
    • getResultImpl

      protected abstract T getResultImpl()
      Produce the final result.
    • close

      public final void close()
      Close this object. Idempotent.
      Specified by:
      close in interface AutoCloseable
      Implementation Note:
      Override closeImpl() instead.
    • closeImpl

      protected void closeImpl()
      Close this closeable as per the contract of Closeable.close(). Called exactly once. By default does nothing.
    • using

      public static <U, C extends BaseResultProducingCloseable<U>> U using(C closeable, Consumer<? super C> it)