findAllConstraints method
Retrieves all constraints applied to a class.
Parameters:
parentClass
: The class whose constraints should be found.declared
: Whether to include inherited constraints (default:true
).
Returns:
- A list of Class instances representing all constraints.
Example
final exampleClass = await loader.loadClass<MyClass>('com.example.MyClass');
final constraints = loader.findAllConstraints(exampleClass);
Implementation
@override
List<Class> findAllConstraints(Class parentClass, [bool declared = true]) {
_checkClosed();
final cacheKey = "${_buildCacheKey(parentClass)}:constraints:$declared";
// Check cache first
final cached = _constraintCache[cacheKey];
if (cached != null) {
_hitCount++;
return List.from(cached);
}
_missCount++;
// Compute classes
final classes = _computeAllConstraints(parentClass, declared);
// Cache result
_constraintCache[cacheKey] = classes;
return List.from(classes.toSet().toList());
}