boolean hasExcludes = !roleAssignment.getExcludes().isEmpty();
List<Role> roles = new ArrayList<Role>(roleAssignment.getRoles());
RoleComparator comperator = new RoleComparator();
Collections.sort(roles, comperator);
for (Iterator<Role> iterator = roles.iterator(); iterator.hasNext(); ) {
Role role = iterator.next();
builder.append(roleAsSafeHtml(role, true));
if (iterator.hasNext() || hasExcludes) {
builder.append(SafeHtmlUtils.fromString(", "));
}
}
if (hasExcludes) {
List<Role> excludes = new ArrayList<Role>(roleAssignment.getExcludes());
Collections.sort(excludes, comperator);
for (Iterator<Role> iterator = excludes.iterator(); iterator.hasNext(); ) {
Role exclude = iterator.next();
builder.append(roleAsSafeHtml(exclude, false));
if (iterator.hasNext()) {
builder.append(SafeHtmlUtils.fromString(", "));
}
}