package com.eactive.eai.rms.onl.loader.service;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
public class DeployResourceDownloadServiceFactory {

    private final List<DeployResourceDownloadService> serviceList;

    public DeployResourceDownloadService create(String serviceType) {
        return serviceList.stream()
                .filter(service -> service.supportsType(serviceType)).findFirst()
                .orElseThrow(() -> new RuntimeException("No Matched Service With ServiceType: " + serviceType));
    }

}