Package com.complexible.common.base

# Class Disposables

java.lang.Object
com.complexible.common.base.Disposables

public final class Disposables extends Object

Since:
  2.0
Version:
  3.0
Author:
  Michael Grove

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static AutoCloseable`
  `asCloseable(Disposable disposable)`
  A utility method to treat a disposable object as an `AutoCloseable`.
  `static AutoDisposable`
  `autoDispose(Disposable theDisposable)`
  `static void`
  `dispose(Disposable theDisposable, Disposable... theOtherDisposables)`
  `static void`
  `dispose(Iterable<? extends Disposable> theDisposables)`
  `static void`
  `disposeIf(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(Object resource)`
  Test / debug method to mark that a particular resource has been released correctly.
  `static void`
  `resetActiveResources(Iterable<Class<?>> ignoredTypes)`
  Clear the active objects tracked by this class.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### 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(Iterable<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(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(Iterable<? extends Disposable> theDisposables)

  - ### disposeIf

    public static void disposeIf(Object theObj)

  - ### disposeQuietly

    public static void disposeQuietly(Disposable theDisposable)

  - ### autoDispose

    public static AutoDisposable autoDispose(Disposable theDisposable)

  - ### asCloseable

    public static 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.