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:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault voidKeepsvaluestrongly reachable from its own key's association untilunpin(java.lang.Class<?>, T)orremove(java.lang.Class<?>).voiddefault voidRevertspin(java.lang.Class<?>, T): the association holdsvaluereclaimably again.default booleanWhether an association's value can be collected while its key class is still alive (GROOVY-12281,-Dgroovy.use.classvalue=soft).
-
Method Details
-
get
-
remove
-
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 — answersfalse. Implementations answeringtruemust honorpin(java.lang.Class<?>, T)so callers can exempt values whose state cannot be rebuilt by recomputation.- Returns:
trueif values may be collected before their key class
-
pin
Keepsvaluestrongly reachable from its own key's association untilunpin(java.lang.Class<?>, T)orremove(java.lang.Class<?>). The value then lives exactly as long astype— like a plainjava.lang.ClassValueassociation: 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 unlessvaluesReclaimable().- Parameters:
type- the key classvalue- the current value fortype
-
unpin
Revertspin(java.lang.Class<?>, T): the association holdsvaluereclaimably again. No-op whenvalueis not the currently pinned value, and unlessvaluesReclaimable().- Parameters:
type- the key classvalue- the value to release
-