StringBoot-接口多实现-Java中一个类实现多个接口
参考
//https://blog.csdn.net/u014365523/article/details/128233200
//https://blog.csdn.net/royal1235/article/details/125954904
public interface IntergralEventHanldeService {
//指标识别码
List<String> applyToIndicatorIDCodeList();
boolean doHanldeIntegralEvent(String month, String day, String 指标识别码, String 积分行为, String 积分指标名称,
String 积分指标类别, String 积分规则描述, Double 加减分值, Double 触发阈值,
List<Map<String, Object>> integralEventSaveList, String time);
}
@Override
public List<String> applyToIndicatorIDCodeList() {
return Lists.newArrayList(SystemConstants.INTEGRAL_CODE_未按时完成巡检任务);
}
@Override
public boolean doHanldeIntegralEvent(String month, String day, String 指标识别码, String 积分行为,
String 积分指标名称, String 积分指标类别, String 积分规则描述, Double 加减分值, Double 触发阈值,
List<Map<String, Object>> integralEventSaveList, String time) {
//TODO 各自实现
return boolean ;
}
@Autowired
@Qualifier("IntegralEventHandler4未按时完成巡检任务")
//接口实现类加上注解后就可以@Service("IntegralEventHandler4未按时完成巡检任务")
private IntergralEventHanldeService IntegralEventHandler4未按时完成巡检任务;
@Autowired
//接口实现类加上注解后就可以 @Service("IntegralEventHandler4巡检时间过短")
@Qualifier("IntegralEventHandler4巡检时间过短")
private IntergralEventHanldeService IntegralEventHandler4巡检时间过短;
@Autowired
private List<IntergralEventHanldeService> eventHanlderList;
/**
* @param indicatorIDcode 指标识别码
* @return
*/
private IntergralEventHanldeService getRealIntergralEventHanlder(String indicatorIDcode) {
Preconditions.checkArgument(StringUtils.isNotBlank(indicatorIDcode), "指标识别码不能为空");
for (IntergralEventHanldeService service : eventHanlderList) {
List<String> codeList = service.applyToIndicatorIDCodeList();
if (CollectionUtils.isNotEmpty(codeList) && codeList.contains(indicatorIDcode)) {
return service;
}
}
throw new BizzException("没有该指标识别码的实现类" + indicatorIDcode);
}
正文到此结束
- 本文标签: Spring Boot Spring
- 本文链接: https://code.jiangjiesheng.cn/article/33
- 版权声明: 本文由小江同学原创发布,转载请先联系本站长,谢谢。