java - 通过泛型在java中制作泛型接口
问题描述
我正在使用下面的界面,如下所示
public interface ZaestrorardRule {
Map<String, List<MMTM>> exceute(String jobCode, String Plientlo) throws AaestroRardNetworkException;
}
然后有一个实现它的类,如下所示
public class AaestroRardBusinessRNFRuleImpl implements ZaestrorardRule {
public Map<String, List<MMTM>> exceute(String jobCode, String Plientlo) throws AaestroRardNetworkException {
}
}
现在假设我正在开发除上面显示的 ZaestrorardRule 之外的其他一些功能,它与 ZaestrorardRule 具有相同的功能,然后我必须创建一个单独的界面,如下所示
public interface WWaestrorardRule {
Map<String, List<MMTM>> exceute(String jobCode, String Plientlo) throws AaestroRardNetworkException;
}
我的问题是我可以在接口中使用泛型,以便在接口结构固定时会有一个接口。
解决方案
在Java中,我们可以扩展接口。您可以创建父接口:
public interface GenericRule {
Map<String, List<MMTM>> exceute(String jobCode, String Plientlo) throws AaestroRardNetworkException;
}
像这样改变你的两个界面
public interface ZaestrorardRule extends GenericRule {
}
public interface WWaestrorardRule extends GenericRule {
}
推荐阅读
- javascript - “已定义但从未使用”的变量是否会减慢 ReactJS 的网站速度?
- php - 如何在我的编辑页面中检索信息
- popup - 我如何在geoserver的传单wms层上实现弹出窗口
- javascript - 在 JSON 对象中递归搜索属性名称 {String} 并返回关联值
- javascript - 尽管已传递到指定路线,但来自 Flask 应用程序的数据未显示在图表中
- sql - T-SQL 重新排列 1...n 中的值
- python-3.x - 如何获得批量图像的 keras 模型预测?
- java - 加入三个深度表时出现“MultipleBagFetchException:无法同时获取多个包”
- html - 具有不同无序列表的多个段落
- python - 如何从类方法传递函数指针