package com.pj.project4sp.face.factory;


import com.pj.current.config.SystemObject;
import com.pj.project4sp.face.handler.IFaceHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FaceFactory {

    @Autowired
    private List<IFaceHandler> handlers;

    public IFaceHandler handler() {
        String type= SystemObject.config.getFaceType();
        return handlers.stream().filter(h -> h.faceBrand().getType().equals(type))
                .findAny().orElseThrow(() -> new IllegalArgumentException("不支持类型人脸识别：" + type));
    }

}
