getDirectAnnotations<A> method
Gets all annotations of a specific type.
Type Parameters:
A
: The annotation type to filter for
Returns:
- A list of all matching annotation instances
- Empty list if none found
Note: Useful for repeatable annotations that may appear multiple times.
Example:
final routes = method.getDirectAnnotations<Route>();
for (final route in routes) {
print('Route path: ${route.path}');
}
Implementation
List<A> getDirectAnnotations<A>() {
checkAccess('getDirectAnnotations', DomainPermission.READ_ANNOTATIONS);
final annotations = getAllDirectAnnotations();
return annotations.where((a) => a.getClass().getType() == A).map((a) => a.getInstance<A>()).toList();
}