WithFinalizer<K extends Object, V extends Object, W extends FinalizerValueWrapper<V>> class abstract

Base class for managing key → value associations backed by a Finalizer.

A value is weakly associated with a key. When the key becomes unreachable and is garbage-collected, the provided onFinalize callback is invoked with the associated value.

Implementations are responsible for:

  • Storing and retrieving wrappers via createWrapper and getWrapper.
  • Maintaining any required internal key → wrapper mapping.

The finalizer is automatically attached and detached as associations are added, replaced, or manually removed.

Constructors

WithFinalizer(FinalizerCallback<V> onFinalize)

Properties

hashCode int
The hash code for this object.
no setterinherited
onFinalize FinalizerCallback<V>
User-provided callback invoked when a key is garbage-collected.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createWrapper(K key, V value) → W
Creates a wrapper for the given key and value.
getWrapper(K key) → W?
Returns the wrapper currently associated with key, or null if no association exists.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFinalizeError(Object error, StackTrace stackTrace) → void
Called when onFinalize throws.
put(K key, V value) → void
Associates value with key, replacing any existing association.
remove(K key) → V?
Removes the association for key, if present.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited