refactor(core): replace if-else routing chain with switch expression
This commit is contained in:
@@ -59,40 +59,43 @@ public class LegacyEimsConnector {
|
|||||||
|
|
||||||
log.info("\n [Adapter -> Legacy] EIMS 통신 요청 - RoutingType: {}, Interface: {}, Payload: {}", routingType, interfaceId, payload);
|
log.info("\n [Adapter -> Legacy] EIMS 통신 요청 - RoutingType: {}, Interface: {}, Payload: {}", routingType, interfaceId, payload);
|
||||||
|
|
||||||
// 2. 4단계 라우팅 분기 처리
|
// 2. 4단계 라우팅 분기 처리 (Switch Expression 활용)
|
||||||
String legacyResponse = null;
|
String upperRoutingType = routingType != null ? routingType.toUpperCase() : "";
|
||||||
if ("HTTP".equalsIgnoreCase(routingType)) {
|
|
||||||
|
String legacyResponse = switch (upperRoutingType) {
|
||||||
|
case "HTTP" -> {
|
||||||
log.info("[라우팅] EIMS API (HTTP) 통신으로 전달");
|
log.info("[라우팅] EIMS API (HTTP) 통신으로 전달");
|
||||||
legacyResponse = httpEimsSender.send(interfaceId, payload);
|
yield httpEimsSender.send(interfaceId, payload);
|
||||||
}
|
}
|
||||||
else if ("TCP".equalsIgnoreCase(routingType)) {
|
case "TCP" -> {
|
||||||
log.info("[라우팅] EIMS 소켓 (TCP) 통신으로 전달");
|
log.info("[라우팅] EIMS 소켓 (TCP) 통신으로 전달");
|
||||||
legacyResponse = tcpEimsSender.send(interfaceId, payload);
|
yield tcpEimsSender.send(interfaceId, payload);
|
||||||
}
|
}
|
||||||
else if ("JSP_FORM".equalsIgnoreCase(routingType)) {
|
case "JSP_FORM" -> {
|
||||||
log.info("[라우팅] JSP Form 통신으로 전달");
|
log.info("[라우팅] JSP Form 통신으로 전달");
|
||||||
legacyResponse = jspFormEimsSender.send(interfaceId, payload);
|
yield jspFormEimsSender.send(interfaceId, payload);
|
||||||
}
|
}
|
||||||
else if ("JSP_JSON".equalsIgnoreCase(routingType)) {
|
case "JSP_JSON" -> {
|
||||||
log.info("[라우팅] JSP JSON 통신으로 전달");
|
log.info("[라우팅] JSP JSON 통신으로 전달");
|
||||||
legacyResponse = jspJsonEimsSender.send(interfaceId, payload);
|
yield jspJsonEimsSender.send(interfaceId, payload);
|
||||||
}
|
}
|
||||||
else if ("MCI_STRING".equalsIgnoreCase(routingType)) {
|
case "MCI_STRING" -> {
|
||||||
log.info("[라우팅] 실시간 AI 요청 -> MCI 연계 어댑터(String)를 통해 EIMS 전달");
|
log.info("[라우팅] 실시간 AI 요청 -> MCI 연계 어댑터(String)를 통해 EIMS 전달");
|
||||||
legacyResponse = mciStringEimsSender.send(interfaceId, payload);
|
yield mciStringEimsSender.send(interfaceId, payload);
|
||||||
}
|
}
|
||||||
else if ("MCI".equalsIgnoreCase(routingType)) {
|
case "MCI" -> {
|
||||||
log.info("[라우팅] 실시간 AI 요청 -> MCI 연계 어댑터를 통해 EIMS 전달");
|
log.info("[라우팅] 실시간 AI 요청 -> MCI 연계 어댑터를 통해 EIMS 전달");
|
||||||
legacyResponse = mciEimsSender.send(interfaceId, payload);
|
yield mciEimsSender.send(interfaceId, payload);
|
||||||
}
|
}
|
||||||
else if ("EAI".equalsIgnoreCase(routingType)) {
|
case "EAI" -> {
|
||||||
log.info("[라우팅] 비동기/대용량 요청 -> EAI 연계 어댑터를 통해 EIMS 전달");
|
log.info("[라우팅] 비동기/대용량 요청 -> EAI 연계 어댑터를 통해 EIMS 전달");
|
||||||
legacyResponse = eaiEimsSender.send(interfaceId, payload);
|
yield eaiEimsSender.send(interfaceId, payload);
|
||||||
}
|
}
|
||||||
else {
|
default -> {
|
||||||
log.error("[라우팅] 알 수 없는 라우팅 타입: {}", routingType);
|
log.error("[라우팅] 알 수 없는 라우팅 타입: {}", routingType);
|
||||||
throw new IllegalArgumentException("지원하지 않는 라우팅 타입입니다: " + routingType);
|
throw new IllegalArgumentException("지원하지 않는 라우팅 타입입니다: " + routingType);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
log.info("\n [Legacy -> Adapter] EIMS 통신 응답 수신: {}", legacyResponse);
|
log.info("\n [Legacy -> Adapter] EIMS 통신 응답 수신: {}", legacyResponse);
|
||||||
return legacyResponse;
|
return legacyResponse;
|
||||||
|
|||||||
Reference in New Issue
Block a user