Skip to content

Commit

Permalink
Merge pull request #40 from aiven/getTeamNameFromTeamId
Browse files Browse the repository at this point in the history
Simplify and optimize ManageDatabase#getTeamNameFromTeamId
  • Loading branch information
jlprat authored Sep 26, 2022
2 parents 7253d06 + d6274fd commit 57f008d
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 57f008d

Please sign in to comment.