Role constructor
const
Role(
- DesignRole value
Declares the design role of a class or method within a Jetleaf application.
This annotation is intended for design-time metadata and architectural documentation. It can also be used by tooling (e.g., code generators, analyzers) to enforce architectural rules.
Example
@Role(DesignRole.APPLICATION)
class UserService {
Future<User> findById(String id) {
// business logic here
}
}
@Role(DesignRole.APPLICATION)
class UserController {
final UserService service;
UserController(this.service);
@Get('/users/:id')
Future<User> getUser(String id) => service.findById(id);
}
Note:
@Role
is not required for Jetleaf runtime behavior, but it is highly recommended for clarity and tooling support.
Implementation
const Role(this.value);