Skip to content
Snippets Groups Projects
Commit a5a1f90d authored by OZGCloud's avatar OZGCloud
Browse files

tiny optimization

parent ae220704
Branches
Tags
No related merge requests found
......@@ -80,9 +80,13 @@ public abstract class UserResourceMapper {
String mapId(UserResource userRes) {
var userRepresentation = userRes.toRepresentation();
var attributes = userRepresentation.getAttributes();
var id = attributes != null ? attributes.get(properties.ldapIdKey()) : null;
return id != null ? id.get(0) : userRepresentation.getId();
return Optional.ofNullable(userRepresentation.getAttributes())
.map(attributes -> attributes.get(properties.ldapIdKey()))
.filter(Objects::nonNull)
.map(id -> id.get(0))
.orElseGet(() -> userRepresentation.getId());
}
String mapEmail(UserResource userRes) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment