package com.eactive.eai.rms.ext.kakaocard.cm;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class KakaoCardCmServiceFactory {
   
   @Autowired
   private List<KakaoCardCmService> cmServiceList; 
   
   public KakaoCardCmService create(String serviceType) {
      return cmServiceList.stream()
            .filter(service -> service.supportsType(serviceType)).findFirst()
            .orElseThrow(() -> new RuntimeException("No Matched Service With ServiceType: " + serviceType));
   }

}