- if (userRole.getScope() != null) {
- if (userRole.getScope().contains(",")) {
- String[] multipleScopes = userRole.getScope().split(",");
- for (int i = 0; i < multipleScopes.length; i++) {
- scopes.add(multipleScopes[i].replace("[", "").replace("]", "").replace("\"", "").trim());
- }
- } else {
- if (!"".equals(userRole.getScope())) {
- scopes.add(userRole.getScope().replace("[", "").replace("]", "").replace("\"", "").trim());
- }
- }
- }
+ scopes.addAll(Stream.of(userRole.getScope().split(","))
+ .map(String::new)
+ .collect(Collectors.toSet())
+ );