Package com.complexible.common.base
Class Disposables
- java.lang.Object
-
- com.complexible.common.base.Disposables
-
public final class Disposables extends java.lang.Object
- Since:
- 2.0
- Version:
- 3.0
- Author:
- Michael Grove
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.AutoCloseable
asCloseable(Disposable disposable)
A utility method to treat a disposable object as anAutoCloseable
.static AutoDisposable
autoDispose(Disposable theDisposable)
static void
dispose(Disposable theDisposable, Disposable... theOtherDisposables)
static void
dispose(java.lang.Iterable<? extends Disposable> theDisposables)
static void
disposeIf(java.lang.Object theObj)
static void
disposeQuietly(Disposable theDisposable)
static ActiveResources
getActiveResources()
Get the active objects as tracked by this class.static void
logActiveResources()
static <T> T
markCreated(T resource)
Test / debug method for tracking resources to verify that they are released correctly.static void
markReleased(java.lang.Object resource)
Test / debug method to mark that a particular resource has been released correctly.static void
resetActiveResources(java.lang.Iterable<java.lang.Class<?>> ignoredTypes)
Clear the active objects tracked by this class.
-
-
-
Method Detail
-
logActiveResources
public static void logActiveResources()
-
getActiveResources
public static ActiveResources getActiveResources()
Get the active objects as tracked by this class.- Returns:
- a list of the active resources
-
resetActiveResources
public static void resetActiveResources(java.lang.Iterable<java.lang.Class<?>> ignoredTypes)
Clear the active objects tracked by this class.
-
markCreated
public static <T> T markCreated(T resource)
Test / debug method for tracking resources to verify that they are released correctly. Tracking is gated by the "stardog.resources.track" System property.- Parameters:
resource
- to track
-
markReleased
public static void markReleased(java.lang.Object resource)
Test / debug method to mark that a particular resource has been released correctly.- Parameters:
resource
- that was released
-
dispose
public static void dispose(Disposable theDisposable, Disposable... theOtherDisposables)
-
dispose
public static void dispose(java.lang.Iterable<? extends Disposable> theDisposables)
-
disposeIf
public static void disposeIf(java.lang.Object theObj)
-
disposeQuietly
public static void disposeQuietly(Disposable theDisposable)
-
autoDispose
public static AutoDisposable autoDispose(Disposable theDisposable)
-
asCloseable
public static java.lang.AutoCloseable asCloseable(Disposable disposable)
A utility method to treat a disposable object as anAutoCloseable
. It's particularly useful for passing disposable references toAutoCloser.close(AutoCloseable...)
instead of using lambdas, eg. disposable::dispose, since it handles nulls.
-
-