findMixins<I> method
Finds mixins applied to a class, returning them as typed Class instances.
Type Parameters:
I
: The expected type of the mixins.
Parameters:
parentClass
: The class whose mixins should be located.declared
: Whether to include inherited mixins (default:true
).
Returns:
- A list of Class<I> instances.
Example
class Example with MixinA, MixinB {}
final exampleClass = await loader.loadClass<Example>('com.example.Example');
final mixins = loader.findMixins<MixinA>(exampleClass);
Implementation
@override
List<Class<I>> findMixins<I>(Class parentClass, [bool declared = true]) {
_checkClosed();
final clazz = Class<I>();
final cacheKey = "${_buildCacheKey(parentClass)}:${_buildCacheKey(clazz)}:mixins:$declared";
// Check cache first
final cached = _mixinCache[cacheKey];
if (cached != null) {
_hitCount++;
return List.from(cached);
}
_missCount++;
// Compute classes
final classes = _computeMixins(parentClass, declared, clazz);
// Cache result
_mixinCache[cacheKey] = classes;
return List.from(classes.toSet().toList());
}