Package de.aristaflow.adept2.util
Class Cleanup.CollectionCloseTask
- java.lang.Object
-
- de.aristaflow.adept2.util.CleanupTask.AbstractCleanupTask<Exception>
-
- de.aristaflow.adept2.util.Cleanup.CollectionCloseTask
-
- All Implemented Interfaces:
CleanupTask<Exception>
public static final class Cleanup.CollectionCloseTask extends CleanupTask.AbstractCleanupTask<Exception>
A cleanup task for cleaning up a collection of objects possibly beingAutoCloseable
. No cleanup will occur for objects which do not implementAutoCloseable
.
-
-
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
Fields Modifier and Type Field Description protected Collection<?>
coll
The collection of which to close its elements which implementAutoCloseable
.-
Fields inherited from class de.aristaflow.adept2.util.CleanupTask.AbstractCleanupTask
descriptor, logger
-
-
Constructor Summary
Constructors Constructor Description CollectionCloseTask(String descriptor, Collection<?> coll)
Creates a newCleanup.CollectionCloseTask
for the designatedCollection
and the designated descriptor usingCleanup's default logger
.CollectionCloseTask(String descriptor, Logger logger, Collection<?> coll)
Creates a newCleanup.CollectionCloseTask
for the designatedCollection
, the designated descriptor and the designated logger.CollectionCloseTask(String descriptor, Logger logger, Collection<?> coll, Function<? super AutoCloseable,AutoCloseable> conversion)
Creates a newCleanup.CollectionCloseTask
for the designatedCollection
, the designated conversion applied to the collection elements before closing them, the designated descriptor and the designated logger.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup(boolean explicit)
Performs the actual clean-up.-
Methods inherited from class de.aristaflow.adept2.util.CleanupTask.AbstractCleanupTask
getDescriptor
-
-
-
-
Field Detail
-
coll
protected final Collection<?> coll
The collection of which to close its elements which implementAutoCloseable
.
-
-
Constructor Detail
-
CollectionCloseTask
public CollectionCloseTask(String descriptor, Collection<?> coll)
Creates a newCleanup.CollectionCloseTask
for the designatedCollection
and 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.
-
CollectionCloseTask
public CollectionCloseTask(String descriptor, Logger logger, Collection<?> coll)
Creates a newCleanup.CollectionCloseTask
for 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.
-
CollectionCloseTask
public CollectionCloseTask(String descriptor, Logger logger, Collection<?> coll, Function<? super AutoCloseable,AutoCloseable> conversion)
Creates a newCleanup.CollectionCloseTask
for 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. This may benull
.
-
-
Method Detail
-
cleanup
public void cleanup(boolean explicit) throws Exception
Description copied from interface:CleanupTask
Performs the actual clean-up. This method is only called byCleanup
and 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
-
-