Package net.sourceforge.pmd.util
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 Summary
Constructors Constructor Description BaseResultProducingCloseable()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
Close this object.protected void
closeImpl()
Close this closeable as per the contract ofCloseable.close()
.protected void
ensureOpen()
T
getResult()
Returns the result.protected abstract T
getResultImpl()
Produce the final result.static <U,C extends BaseResultProducingCloseable<U>>
Uusing(C closeable, Consumer<? super C> it)
-
-
-
Method Detail
-
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 interfaceAutoCloseable
-
closeImpl
protected void closeImpl()
Close this closeable as per the contract ofCloseable.close()
. Called exactly once. By default does nothing.
-
using
public static <U,C extends BaseResultProducingCloseable<U>> U using(C closeable, Consumer<? super C> it)
-
-