package com.sunyard.chsm.sdf.adapter;

import com.sunyard.chsm.enums.ManufacturerModelEnum;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.util.Assert;

import java.util.Objects;

/**
 * @author liulu
 * @since 2024/11/5
 */
public class SdfApiAdapterFactory {


    public static SdfApiAdapter newInstance(String model, String ip, Integer port) {

        Assert.hasText(model, "设备型号不能为空");
        ManufacturerModelEnum modelEnum = ManufacturerModelEnum.of(model);

        if (Objects.isNull(modelEnum) && Objects.equals(BouncyCastleProvider.PROVIDER_NAME, model)) {
            // bc adaptor
            return new BcSdfApiAdaptor();
        }
        switch (modelEnum) {
            case enc001:
                return new SunyardJnaSdfAdaptor(ip, port);
            default:
                throw new UnsupportedOperationException("不支持的设备型号: " + model);
        }
    }





}
