From d6274fdea3dc0b3a6684b6a68a15c8401b4a3823 Mon Sep 17 00:00:00 2001 From: Sergey Nuyanzin Date: Tue, 20 Sep 2022 10:41:11 +0200 Subject: [PATCH] Simplify and optimize ManageDatabase#getTeamNameFromTeamId --- src/main/java/io/aiven/klaw/config/ManageDatabase.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/aiven/klaw/config/ManageDatabase.java b/src/main/java/io/aiven/klaw/config/ManageDatabase.java index 047c239c8b..e9d1132496 100644 --- a/src/main/java/io/aiven/klaw/config/ManageDatabase.java +++ b/src/main/java/io/aiven/klaw/config/ManageDatabase.java @@ -313,12 +313,9 @@ public Integer getTeamIdFromTeamName(int tenantId, String teamName) { } public String getTeamNameFromTeamId(int tenantId, int teamId) { - Optional> 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> getEnvsOfTenantsMap() {