Alpine
Alpine copied to clipboard
Add getTeams() to Principal contract
Rational: Common to ApiKey and UserPrincipal.
OO simplification to avoid this type of ugly code:
final List<Team> teams;
if (principal instanceof UserPrincipal) {
final UserPrincipal userPrincipal = ((UserPrincipal) principal);
teams = userPrincipal.getTeams();
} else {
final ApiKey apiKey = ((ApiKey) principal);
teams = apiKey.getTeams();
}