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
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 -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()Close this object.protected voidClose this closeable as per the contract ofCloseable.close().protected final voidfinal TReturns the result.protected abstract TProduce the final result.static <U,C extends BaseResultProducingCloseable<U>>
U
-
Constructor Details
-
BaseResultProducingCloseable
public BaseResultProducingCloseable()
-
-
Method Details
-
ensureOpen
protected final void ensureOpen() -
getResult
Returns the result.- Throws:
IllegalStateException- If this instance has not been closed yet
-
getResultImpl
Produce the final result. -
close
public final void close()Close this object. Idempotent.- Specified by:
closein interfaceAutoCloseable- Implementation Note:
- Override
closeImpl()instead.
-
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)
-