Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
[#141] if/else instead of ternary op
Browse files Browse the repository at this point in the history
  • Loading branch information
jenarp committed Feb 2, 2022
1 parent a018822 commit 4c6050c
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ public static CustomOAuth2User fromGitHubUser(@NonNull final OAuth2User user,
) {
var externalId = "";
if (StringUtils.hasLength(nameAttribute)) {
externalId = String.valueOf(user.getAttribute("id") == null ? "" : user.getAttribute("id"));
final var id = user.getAttribute("id");
if (id == null) {
externalId = "";
} else {
externalId = String.valueOf(id);
}
}

var name = "";
Expand All @@ -64,9 +69,16 @@ public static CustomOAuth2User fromGitHubUser(@NonNull final OAuth2User user,
}
}

var alias = "";
if (StringUtils.hasLength(aliasAttribute)) {
alias = Optional.ofNullable((String) user.getAttribute(aliasAttribute)).orElse("");
} else {
alias = "";
}

return new CustomOAuth2User(
externalId,
StringUtils.hasLength(aliasAttribute) ? Optional.ofNullable((String) user.getAttribute(aliasAttribute)).orElse("") : "",
alias,
name,
user.getAttributes(),
user.getAuthorities(),
Expand Down

0 comments on commit 4c6050c

Please sign in to comment.