我有一个方法:
public List<Integer> convertBy(Function<String, List<String>> flines, Function<List<String>, String> join, Function<String, List<Integer>> collectInts) {
return collectInts.apply(join.apply(flines.apply((String) value)));
}//first method
public Integer convertBy(Function<List<String>, String> join, Function<String, List<Integer>> collectInts, Function<List<Integer>, Integer> sum) {
return sum.apply(collectInts.apply(join.apply((List<String>) value)));
}//second method
尽管它们的参数是用不同类型参数化的,但我不能重载第一种方法。我可能会使用不同的界面,Function<T,R>
但不知道哪一个就足够了,因为我浏览了它们的列表并且找不到一个https://docs.oracle.com/javase/8/docs/api/java/ util/function/package-summary.html。
这些函数中的参数是:
flines
- 从给定路径 () 读取文件String
并返回该文件中的行列表 ( List<String>
)
join
- 连接给定的元素List<String>
并返回一个String
collectInts
- 解析给定String
并返回在其中找到的整数列表String
。
sum
- 添加元素List<Integers>
并返回总和
问题:
我可以用第二种方法重载第一种方法吗?
除了功能之外,我还可以使用哪些其他现有功能接口?我认为没有,因为论点和结果的类型总是不同的。