Package com.complexible.common.base

# Class AbstractAutoDisposable

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

All Implemented Interfaces:
  `AutoDisposable`, `Disposable`

public abstract class AbstractAutoDisposable extends Object implements AutoDisposable

Author:
  Evren Sirin

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractAutoDisposable()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T extends AutoDisposable>
  T`
  `acquire()`
  Acquires a reference to this object preventing it from being automatically disposed until the reference is released.
  `int`
  `getRefCount()`
  Returns the current reference count.
  `void`
  `release()`
  Releases one of these object's references.
  `<T extends AutoDisposable>
  T`
  `tryAcquire()`
  Tries to acquire a reference to this object.

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

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

  ### Methods inherited from interface com.complexible.common.base.Disposable

  `dispose`

- ## Constructor Details

  - ### AbstractAutoDisposable

    public AbstractAutoDisposable()

- ## Method Details

  - ### acquire

    public <T extends AutoDisposable> T acquire()
    Description copied from interface: `AutoDisposable`
    Acquires a reference to this object preventing it from being automatically disposed until the reference is released.
    Specified by:
      `acquire` in interface `AutoDisposable`
    Type Parameters:
      `T` -
    Returns:
      this object

  - ### tryAcquire

    public <T extends AutoDisposable> T tryAcquire()
    Description copied from interface: `AutoDisposable`
    Tries to acquire a reference to this object. Returns the reference if the number of references to the object is greater than zero at the time of the call. If not, it's possible that the object has already been disposed so `null` is returned instead. Note: this method should be used after the object has been `acquired` for the first time. Before that it always returns `null`. The common use case is that the first `AutoDisposable.acquire()` happens before the object is published and becomes visible to users.
    Specified by:
      `tryAcquire` in interface `AutoDisposable`
    Type Parameters:
      `T` - object type
    Returns:
      this object

  - ### release

    public void release()
    Description copied from interface: `AutoDisposable`
    Releases one of these object's references. If the number of references reaches to or goes below `0`, this object will be `disposed`. So calling this function without any preceding `AutoDisposable.acquire()` calls will cause the dispose function to be called multiple times.
    Specified by:
      `release` in interface `AutoDisposable`

  - ### getRefCount

    public int getRefCount()
    Returns the current reference count.
    Specified by:
      `getRefCount` in interface `AutoDisposable`