Package org.codehaus.groovy.reflection

# Interface GroovyClassValue<T>

Type Parameters:
  `T` -

All Known Implementing Classes:
  `GroovyClassValueJava7`

public interface GroovyClassValue<T>
Abstraction for Java version dependent ClassValue implementations.

See Also:
  - `ClassValue`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static interface`
  `GroovyClassValue.ComputeValue<T>`

- ## Method Summary

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

- ## Method Details

  - ### get

    T get(Class<?> type)

  - ### remove

    void remove(Class<?> type)

  - ### valuesReclaimable

    default 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(java.lang.Class<?>, T)` so callers can exempt values whose state cannot be rebuilt by recomputation.
    Returns:
      `true` if values may be collected before their key class

  - ### pin

    default void pin(Class<?> type, T value)
    Keeps `value` strongly reachable from its own key's association until `unpin(java.lang.Class<?>, T)` or `remove(java.lang.Class<?>)`. 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`

  - ### unpin

    default void unpin(Class<?> type, T value)
    Reverts `pin(java.lang.Class<?>, T)`: 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