-
- All Superinterfaces:
-
AutoCloseable
@Deprecated public interface CloseableScope extends AutoCloseable
Deprecated.UseCloseableScopefrom dedicated library instead.Specialization ofAutoCloseablethat throws only unchecked exceptions.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default CloseableScopeandFinally(Runnable action)Deprecated.Creates extendedCloseableScopethat additionally runs specifiedactionregardless of exceptions.default CloseableScopeandThen(Runnable action)Deprecated.Creates extendedCloseableScopethat additionally runs specifiedactionunless exception is thrown.voidclose()Deprecated.Closes this scope or other closeable resource.
-
-
-
Method Detail
-
close
void close()
Deprecated.Closes this scope or other closeable resource. This is a specialization ofAutoCloseable.close()that throws only unchecked exceptions.- Specified by:
-
closein interfaceAutoCloseable
-
andThen
default CloseableScope andThen(Runnable action)
Deprecated.Creates extendedCloseableScopethat additionally runs specifiedactionunless exception is thrown. This is useful for quickly creating outer scopes that add extra operations to some inner scope. Ifclose()throws,actiondoes not run.- Parameters:
-
action- the operation to perform afterclose()is called - Returns:
-
new
CloseableScopethat, when closed, first closes thisCloseableScopeand then executesaction - Throws:
-
NullPointerException- ifactionisnull - See Also:
-
andFinally(Runnable)
-
andFinally
default CloseableScope andFinally(Runnable action)
Deprecated.Creates extendedCloseableScopethat additionally runs specifiedactionregardless of exceptions. This is useful for quickly creating outer scopes that add extra operations to some inner scope. Ifclose()throws,actionruns anyway as if in try-with-resources block. If bothclose()} andactionthrow, the exception fromactionis added to suppressed exception list by callingThrowable.addSuppressed(Throwable).- Parameters:
-
action- the operation to perform afterclose()is called - Returns:
-
new
CloseableScopethat, when closed, first closes thisCloseableScopeand then executesaction - Throws:
-
NullPointerException- ifactionisnull - See Also:
-
andThen(Runnable)
-
-