我想创建可从Java访问的Kotlin实用程序,该实用程序可将字符串列表转换为Map。到目前为止,我已经写了:Kotlin映射&将字符串数组映射到Map <String,Any!>
class Utils {
companion object {
@JvmStatic fun values(item: GSAItem): Map<String, Object> {
return item.itemDescriptor.propertyNames.map {it -> Map.Entry<String, Any!>(it, item.getPropertyValue(it)) }; }
}
}
但我发现了错误
Error:(16, 74) Kotlin: Unresolved reference: Entry
GSAItem.getPropertyValue是Java方法这需要字符串作为参数并返回对象。之后,我怀疑我需要从Java 8中找到一些等价的collect函数?
什么是KeyStore类? – yole
@yole我猜这是[KeyStore](https://docs.oracle.com/javase/7/docs/api/java/security/KeyStore.html)。 'KeyStore.Entry'是一个标记接口。你的意思是使用'PrivateKeyEntry','SecretKeyEntry'或'TrustedCertificateEntry'来代替吗? – Enrico
哎呀,对不起。我尝试了不同的导入,并最终粘贴了错误的代码。我编辑它以匹配原始版本。 –