Package de.aristaflow.adept2.util
Class Cleanup.CollCloseTask<T>
java.lang.Object
de.aristaflow.adept2.util.CleanupTask.AbstractCleanupTask<Exception>
de.aristaflow.adept2.util.Cleanup.CollCloseTask<T>
- Type Parameters:
T- The type of the elements of the collection. This is needed for the conversion before closing.
- All Implemented Interfaces:
CleanupTask<Exception>
public static final class Cleanup.CollCloseTask<T>
extends CleanupTask.AbstractCleanupTask<Exception>
A cleanup task for cleaning up a collection of objects being converted and afterwards being
closed in case the conversion yields a
AutoCloseable. No cleanup will occur for
conversion results being of another type or null.-
Nested Class Summary
Nested classes/interfaces inherited from interface de.aristaflow.adept2.util.CleanupTask
CleanupTask.AbstractCleanupTask<EX extends Exception>, CleanupTask.AtomicCloseTask, CleanupTask.CloseAndResetTask, CleanupTask.MutableCloseTask -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Collection<T>The collection of which to close its elements which are converted toAutoCloseable.Fields inherited from class de.aristaflow.adept2.util.CleanupTask.AbstractCleanupTask
descriptor, logger -
Constructor Summary
ConstructorsConstructorDescriptionCollCloseTask(String descriptor, Collection<T> coll) Creates a newCleanup.CollCloseTaskfor the designatedCollectionand the designated descriptor usingCleanup's default logger.CollCloseTask(String descriptor, Logger logger, Collection<T> coll) Creates a newCleanup.CollCloseTaskfor the designatedCollection, the designated descriptor and the designated logger.CollCloseTask(String descriptor, Logger logger, Collection<T> coll, Function<? super T, AutoCloseable> conversion) Creates a newCleanup.CollCloseTaskfor the designatedCollection, the designated conversion applied to the collection elements before closing them, the designated descriptor and the designated logger. -
Method Summary
Methods inherited from class de.aristaflow.adept2.util.CleanupTask.AbstractCleanupTask
getDescriptor
-
Field Details
-
coll
The collection of which to close its elements which are converted toAutoCloseable.
-
-
Constructor Details
-
CollCloseTask
Creates a newCleanup.CollCloseTaskfor the designatedCollectionand the designated descriptor usingCleanup's default logger.- Parameters:
descriptor- A string that meaningfully describes this task when used for logging etc. ornull.coll- The collection of which toAutoCloseable.close()the elements that areAutoCloseable.
-
CollCloseTask
Creates a newCleanup.CollCloseTaskfor the designatedCollection, the designated descriptor and the designated logger.- Parameters:
descriptor- A string that meaningfully describes this task when used for logging etc. ornull.logger- The logger for messages and/or problems, e. g. unexpected exceptions.coll- The collection of which toAutoCloseable.close()the elements that areAutoCloseable.
-
CollCloseTask
public CollCloseTask(String descriptor, Logger logger, Collection<T> coll, Function<? super T, AutoCloseable> conversion) Creates a newCleanup.CollCloseTaskfor the designatedCollection, the designated conversion applied to the collection elements before closing them, the designated descriptor and the designated logger.- Parameters:
descriptor- A string that meaningfully describes this task when used for logging etc. ornull.logger- The logger for messages and/or problems, e. g. unexpected exceptions.coll- The collection of which toAutoCloseable.close()the elements.conversion- A function to convert the collection elements before closing. This allows to handler instances that are wrapped by a close ignoring wrapper. If this isnull, this simply casts the collection element toAutoCloseableif appropriate and returnsnullif inappropriate.
-
-
Method Details
-
cleanup
Description copied from interface:CleanupTaskPerforms the actual clean-up. This method is only called byCleanupand must NOT be called directly!- Parameters:
explicit- Whether the clean-up was triggered explicitly viaCleanup.clean(). Otherwise it was triggered implicitly as a post-mortem action by the object becoming phantom reachable.- Throws:
Exception
-