我有这样的Java功能
public static CollectionReader createCollectionReader(
Class extends CollectionReader> readerClass, TypeSystemDescription typeSystem,
Object... configurationData)我想从中做一个部分应用函数,并为Object ...部分指定一些参数。我不确定这是否可能。我试过了
val partiallyApply = createCollectionReader(_:Class[_ <: collectionreader _:typesystemdescription>
"IncludeGoldStandardAnnotations", new Boolean("true"),
"EndIndex", new Integer("-1"), _:_*) // Doesn't work并希望它被用作
val reader = partiallyApply(classOf[someReader], someType:TypeSystemDescription,
"other", "configurationData", "beside", "those_four_that_already_applied_too"]但这似乎并不奏效。另外,这个对象是否有一个技术名称?
编辑:有点改变代码(我的错误..我忘了把val的名字放在里面),并添加我想要的用法的例子。
编辑2:我认为我的主要问题是可以对可变参数进行部分应用功能?
编辑3:感谢elbowich的建议。我想出了
def createCollectionReaderReadAll(cls: Class[_ <: collectionreader ts: typesystemdescription cfg: anyref>
createCollectionReader(cls, ts,
Seq("IncludeGoldStandardAnnotations", new Boolean("true"), "EndIndex", new Integer("-1")) ++ cfg: _*)工作得很好