-
- All Superinterfaces:
-
AutoCloseable
@Deprecated public interface CloseableScope extends AutoCloseable
Deprecated.UseCloseableScope
from dedicated library instead.Specialization ofAutoCloseable
that throws only unchecked exceptions.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default CloseableScope
andFinally(Runnable action)
Deprecated.Creates extendedCloseableScope
that additionally runs specifiedaction
regardless of exceptions.default CloseableScope
andThen(Runnable action)
Deprecated.Creates extendedCloseableScope
that additionally runs specifiedaction
unless exception is thrown.void
close()
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:
-
close
in interfaceAutoCloseable
-
andThen
default CloseableScope andThen(Runnable action)
Deprecated.Creates extendedCloseableScope
that additionally runs specifiedaction
unless exception is thrown. This is useful for quickly creating outer scopes that add extra operations to some inner scope. Ifclose()
throws,action
does not run.- Parameters:
-
action
- the operation to perform afterclose()
is called - Returns:
-
new
CloseableScope
that, when closed, first closes thisCloseableScope
and then executesaction
- Throws:
-
NullPointerException
- ifaction
isnull
- See Also:
-
andFinally(Runnable)
-
andFinally
default CloseableScope andFinally(Runnable action)
Deprecated.Creates extendedCloseableScope
that additionally runs specifiedaction
regardless of exceptions. This is useful for quickly creating outer scopes that add extra operations to some inner scope. Ifclose()
throws,action
runs anyway as if in try-with-resources block. If bothclose()
} andaction
throw, the exception fromaction
is added to suppressed exception list by callingThrowable.addSuppressed(Throwable)
.- Parameters:
-
action
- the operation to perform afterclose()
is called - Returns:
-
new
CloseableScope
that, when closed, first closes thisCloseableScope
and then executesaction
- Throws:
-
NullPointerException
- ifaction
isnull
- See Also:
-
andThen(Runnable)
-
-