Package: org.codehaus.groovy.util

## [Java] Class ManagedReference<T>

- org.codehaus.groovy.util.ManagedReference

- All Implemented Interfaces and Traits:
    Finalizable

      public class ManagedReference<T>
      extends Object
      implements Finalizable

  Reference wrapper that couples a referent with a ReferenceManager cleanup lifecycle.

  Type Parameters:
    `T` - the referent type

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ManagedReference(ReferenceType type, ReferenceManager rmanager, T value)` Creates a managed reference using the supplied reference kind and manager.
    `ManagedReference(ReferenceBundle bundle, T value)` Creates a managed reference using the supplied bundle.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public final void` | `clear()` Clears the referent and lets the manager process any queued stale entries.
    `` | `public void` | `finalizeReference()` Performs any cleanup required after the associated reference has been cleared.
    `` | `public final T` | `get()` Returns the current referent.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public ManagedReference(ReferenceType type, ReferenceManager rmanager, T value)

      Creates a managed reference using the supplied reference kind and manager.

      Parameters:
        `type` - the reference implementation to create
        `rmanager` - the manager that processes collected references
        `value` - the referent to store

    - #### public ManagedReference(ReferenceBundle bundle, T value)

      Creates a managed reference using the supplied bundle.

      Parameters:
        `bundle` - the reference bundle describing the type and manager to use
        `value` - the referent to store

  - ### Method Detail

    - #### public final void clear()

      Clears the referent and lets the manager process any queued stale entries.

    - #### public void finalizeReference()

      Performs any cleanup required after the associated reference has been cleared.

    - #### public final T get()

      Returns the current referent.

      Returns:
        the referent, or `null` if it is no longer available