123456789101112131415161718192021 |
- package com.gzlh.camera.factory;
- import com.gzlh.camera.handler.ICameraHandler;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.List;
- @Service
- public class CameraFactory {
- @Autowired
- private List<ICameraHandler>handlers;
- public ICameraHandler handler(int code){
- return handlers.stream().filter(h->h.brandType().getCode()==code)
- .findAny().orElseThrow(()->new IllegalArgumentException("不支持交互"));
- }
- }
|