findAllInterfaceArguments method
Finds all interface arguments of the specified class with caching.
{@template class_loader_find_interface_arguments} Parameters:
parentClass
: The class to find interface arguments fordeclared
: Whether to include inherited interface arguments (default: true)
Returns:
- List of interface arguments
- Empty list if no interface arguments are found
- Cached results for subsequent calls
Example
final listClass = await loader.loadClass<List>('dart:core/list.dart.List');
final interfaceArgs = await loader.findInterfaceArguments(listClass);
// Returns: [Iterable, Collection, etc.]
// Direct interface arguments only
final directInterfaceArgs = await loader.findInterfaceArguments(listClass, false);
Caching Behavior
- Separate caches for transitive and direct interface queries
- Cache keys include the transitive flag for proper segregation
- Automatic cache invalidation on class hierarchy changes {@endtemplate}
Implementation
@override
List<Class> findAllInterfaceArguments(Class parentClass, [bool declared = true]) {
_checkClosed();
final cacheKey = "${_buildCacheKey(parentClass)}:interfaceArguments:$declared";
// Check cache first
final cached = _interfaceArgumentCache[cacheKey];
if (cached != null) {
_hitCount++;
return List.from(cached);
}
_missCount++;
// Compute classes
final classes = _computeAllInterfaceArguments(parentClass, declared);
// Cache result
_interfaceArgumentCache[cacheKey] = classes;
return List.from(classes.toSet().toList());
}