From 90db2a3be2345eecc9f6ebfacc55a270705254ff Mon Sep 17 00:00:00 2001 From: Sujin Kim Date: Fri, 22 Nov 2024 02:02:21 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20if-else=EB=AC=B8=20object=20mapping?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shoot/application/ShootService.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/gigedi/dev/domain/shoot/application/ShootService.java b/src/main/java/gigedi/dev/domain/shoot/application/ShootService.java index 32d2336..18d5164 100644 --- a/src/main/java/gigedi/dev/domain/shoot/application/ShootService.java +++ b/src/main/java/gigedi/dev/domain/shoot/application/ShootService.java @@ -1,6 +1,8 @@ package gigedi.dev.domain.shoot.application; import java.util.List; +import java.util.Map; +import java.util.function.Function; import java.util.stream.Collectors; import org.springframework.stereotype.Service; @@ -80,17 +82,21 @@ public List getOurShoot(String tab) { if (tab == null || tab.isBlank()) { tab = YET; } - if (tab.equals(YET)) { - return getShootByStatus(figma, Status.YET); - } else if (tab.equals(DOING)) { - return getShootByStatus(figma, Status.DOING); - } else if (tab.equals(DONE)) { - return getShootByStatus(figma, Status.DONE); - } else if (tab.equals(MENTIONED)) { - return getMentionedShoot(figma); - } else { - throw new CustomException(ErrorCode.INVALID_TAB); - } + + Map>> tabMapping = + Map.of( + YET, f -> getShootByStatus(f, Status.YET), + DOING, f -> getShootByStatus(f, Status.DOING), + DONE, f -> getShootByStatus(f, Status.DONE), + MENTIONED, this::getMentionedShoot); + + return tabMapping + .getOrDefault( + tab, + f -> { + throw new CustomException(ErrorCode.INVALID_TAB); + }) + .apply(figma); } private List getShootByStatus(Figma figma, Status status) {