Using Guava (formerly Google Collections):
Map mappedRoles = Maps.uniqueIndex(yourList, Functions.toStringFunction());
Or, if you want to supply your own method that makes a String
out of the object:
Map mappedRoles = Maps.uniqueIndex(yourList, new Function() {
public String apply(Role from) {
return from.getName(); // or something else
}});