Esempio n. 1
0
 public <T> T findWithRole(String id, Class<T> role) {
   Account account = findById(id);
   if (!role.isAssignableFrom(account.getClass())) {
     throw new NotFoundException();
   }
   return (T) account;
 }
Esempio n. 2
0
 public Collection<Account> withRole(Class<?> role) {
   ArrayList<Account> result = new ArrayList<Account>();
   for (Account account : accounts.values()) {
     if (role.isAssignableFrom(account.getClass())) {
       result.add(account);
     }
   }
   return result;
 }