Skip to content

Commit

Permalink
Simplify and optimize ManageDatabase#getTeamNameFromTeamId
Browse files Browse the repository at this point in the history
  • Loading branch information
snuyanzin committed Sep 20, 2022
1 parent 90dbaa8 commit d6274fd
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/main/java/io/aiven/klaw/config/ManageDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,9 @@ public Integer getTeamIdFromTeamName(int tenantId, String teamName) {
}

public String getTeamNameFromTeamId(int tenantId, int teamId) {
Optional<Map.Entry<Integer, String>> optionalTeam =
teamIdAndNamePerTenant.get(tenantId).entrySet().stream()
.filter(a -> a.getKey() == teamId)
.findFirst();
if (optionalTeam.isPresent()) return optionalTeam.get().getValue();
else return ""; // unknown team
return teamIdAndNamePerTenant
.getOrDefault(tenantId, Collections.emptyMap())
.getOrDefault(teamId, ""); // empty string in case of unknown team
}

public Map<Integer, List<String>> getEnvsOfTenantsMap() {
Expand Down

0 comments on commit d6274fd

Please sign in to comment.