如何在单个集合中表示泛型类型?
public interface Rule<T> {
String execute(T dataProvider);
}
public interface DataProvider {
// No common functions as of now
}
public class RulesExecutor {
private Map<String, List<Rule>> documentToRuleListMap;
public RulesExecutor(Map<String, List<Rule>> documentToRuleListMap) {
this.documentToRuleListMap = documentToRuleListMap;
}
public executeRules(DataProvider dataProvider, String document) {
// some logic here
}
}
是否可以存储RulesExecutor
sconstructor 中显示的地图?
如果不是,那么存储此信息的正确数据结构是什么?