Map<UUID, Role> roleMap = new LinkedHashMap<UUID, Role>();
for(Right right: this.rightSet)
{
if(right.templateId.equals(templateId))
{
Role role = this.roleMap.get(right.roleId);
if(role != null)
roleMap.put(role.getId(), role);
}
}
return roleMap.values().toArray(new Role[0]);
}