Module io.jenetics.base
Package io.jenetics.internal.util
Interface Lifecycle.ExtendedCloseable<E extends Exception>
- Type Parameters:
E- the exception thrown by theclose()method
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
Lifecycle.IOResources,Lifecycle.IOValue,Lifecycle.Resources,Lifecycle.Value
- Enclosing class:
- Lifecycle
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public static interface Lifecycle.ExtendedCloseable<E extends Exception>
extends AutoCloseable
Extends the
AutoCloseable with methods for wrapping the thrown
exception into unchecked exceptions or ignoring them.-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static <E extends Exception>
Lifecycle.ExtendedCloseable<E>of(Lifecycle.ThrowingRunnable<? extends E> release) Wraps a givenreleasemethod and returns anLifecycle.ExtendedCloseable.static <E extends Exception>
Lifecycle.ExtendedCloseable<E>of(Lifecycle.ThrowingRunnable<? extends E>... releases) Create a newExtendedCloseableobject with the given initial release methods>.static <E extends Exception>
Lifecycle.ExtendedCloseable<E>of(Collection<? extends Lifecycle.ThrowingRunnable<? extends E>> releases) Create a newExtendedCloseableobject with the given initial release methods>.default voidCalls theclose()method and ignores every thrown exception.default voidsilentClose(Throwable previousError) Calls theclose()method and ignores every thrown exception.default voiduncheckedClose(Function<? super E, ? extends RuntimeException> mapper) Calls theclose()method and wraps thrownExceptioninto anRuntimeException, mapped by the givenmapper.
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
E extends Exception
-
uncheckedClose
Calls theclose()method and wraps thrownExceptioninto anRuntimeException, mapped by the givenmapper.- Throws:
RuntimeException- if theclose()method throws anException
-
silentClose
Calls theclose()method and ignores every thrown exception. -
silentClose
Calls theclose()method and ignores every thrown exception. If the givenpreviousErroris non-null, the thrown exception is appended to the list of suppressed exceptions.- Parameters:
previousError- the error, which triggers the close of the givencloseables
-
of
static <E extends Exception> Lifecycle.ExtendedCloseable<E> of(Lifecycle.ThrowingRunnable<? extends E> release) Wraps a givenreleasemethod and returns anLifecycle.ExtendedCloseable.- Parameters:
release- the release method to wrap- Returns:
- a new extended closeable with the given underlying
releasemethod - Throws:
NullPointerException- if the givenreleasemethod isnull
-
of
static <E extends Exception> Lifecycle.ExtendedCloseable<E> of(Collection<? extends Lifecycle.ThrowingRunnable<? extends E>> releases) Create a newExtendedCloseableobject with the given initial release methods>. The given list of objects is closed in reversed order.- Parameters:
releases- the initial release methods- Returns:
- a new closeable object which collects the given
releases - Throws:
NullPointerException- if one of thereleasesisnull- See Also:
-
of
@SafeVarargs static <E extends Exception> Lifecycle.ExtendedCloseable<E> of(Lifecycle.ThrowingRunnable<? extends E>... releases) Create a newExtendedCloseableobject with the given initial release methods>. The given list of objects is closed in reversed order.- Parameters:
releases- the release methods- Returns:
- a new closeable object which collects the given
releases - Throws:
NullPointerException- if one of thereleasesisnull- See Also:
-