Class Disposables


  • public final class Disposables
    extends java.lang.Object

    Since:
    2.0
    Version:
    3.0
    Author:
    Michael Grove
    • 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)
      • asCloseable

        public static java.lang.AutoCloseable asCloseable​(Disposable disposable)
        A utility method to treat a disposable object as an AutoCloseable. It's particularly useful for passing disposable references to AutoCloser.close(AutoCloseable...) instead of using lambdas, eg. disposable::dispose, since it handles nulls.