Package: org.codehaus.groovy.reflection

## [Java] Interface GroovyClassValue<T>

-     public interface GroovyClassValue<T>

  Abstraction for Java version dependent ClassValue implementations.

  See Also:
    ClassValue
  Parameters:

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `interface` | `GroovyClassValue.ComputeValue` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public T` | `get(Class<?> type)`
    `` | `public void` | `pin(Class<?> type, T value)` Keeps `value` strongly reachable from its own key's association until unpin or remove.
    `` | `public void` | `remove(Class<?> type)`
    `` | `public void` | `unpin(Class<?> type, T value)` Reverts pin: the association holds `value` reclaimably again.
    `` | `public boolean` | `valuesReclaimable()` Whether an association's value can be collected while its key class is still alive (GROOVY-12281, `-Dgroovy.use.classvalue=soft`).

- - ### Method Detail

    - #### public T get(Class<?> type)

    - #### public void pin(Class<?> type, T value)

      Keeps `value` strongly reachable from its own key's association until unpin or remove. The value then lives exactly as long as `type` — like a plain `java.lang.ClassValue` association: an immortal key retains it, a collectible key releases it together with its loader. Implementations must not root the value globally, which would extend a collectible key's lifetime to the runtime's. No-op unless valuesReclaimable().

      Parameters:
        `type` - the key class
        `value` - the current value for `type`

    - #### public void remove(Class<?> type)

    - #### public void unpin(Class<?> type, T value)

      Reverts pin: the association holds `value` reclaimably again. No-op when `value` is not the currently pinned value, and unless valuesReclaimable().

      Parameters:
        `type` - the key class
        `value` - the value to release

    - #### public boolean valuesReclaimable()

      Whether an association's value can be collected while its key class is still alive (GROOVY-12281, `-Dgroovy.use.classvalue=soft`). The default — a value lives exactly as long as its key class — answers `false`. Implementations answering `true` must honor pin so callers can exempt values whose state cannot be rebuilt by recomputation.

      Returns:
        `true` if values may be collected before their key class