VariableResolver class abstract
Strategy interface used to resolve type variables in generic contexts.
VariableResolver provides a mechanism for resolving type variables (like T, K, V) to concrete types in generic type contexts. This is essential for proper type resolution in generic classes and methods.
Implementations should provide:
- A source object that represents the context of resolution
- Logic to resolve specific type variables to concrete ResolvableType instances
Example Implementation:
class GenericClassResolver implements VariableResolver {
final Map<Object, ResolvableType> _typeMapping;
final Object _source;
GenericClassResolver(this._source, this._typeMapping);
@override
Object getSource() => _source;
@override
ResolvableType? resolveVariable(Object variable) {
return _typeMapping[variable];
}
}
// Usage
final resolver = GenericClassResolver(
myGenericClass,
{typeVariableT: ResolvableType.forClass(String)}
);
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getSource(
) → Object - Returns the source object that provides the context for type variable resolution.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolveVariable(
Object variable) → ResolvableType? - Resolves the specified type variable to a concrete ResolvableType.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited