私はこのような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"]
しかし、これはうまくいかないようです。また、このオブジェクトは... 技術的な名前を持っていますか?
EDIT:コードを少し変更し(私の間違い.. val nameを入れるのを忘れていました)、必要な使用例を追加します。
EDIT2:私の主な質問は、 vararg で部分的に関数を適用できることだと思いますか?
EDIT3:エルボウィッチの提案に感謝します。私が思いつく
def createCollectionReaderReadAll(cls: Class[_ <: CollectionReader], ts: TypeSystemDescription, cfg: AnyRef*) =
createCollectionReader(cls, ts,
Seq("IncludeGoldStandardAnnotations", new Boolean("true"), "EndIndex", new Integer("-1")) ++ cfg: _*)
完全に正常に動作します