java 函数中的函数_从Java函数中部分应用函数

我有这样的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: _*)工作得很好

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值