英文:
How to get data from Contract State form of a state, without casting?
问题
有没有一种方法可以从ContractState表单中检索状态数据,而不需要转换?我尝试了像下面这样使用反射,但它没有返回值(我猜它返回的是状态字段“status”的元数据)。
historyForId的类型是:ArrayList<Map<String, ContractState>>
val temp2 = historyForId.first().get("contractStateData")!!.javaClass.getDeclaredField("status")
英文:
Is there a way to retrieve data from ContractState form of a state data, without casting ? I was trying like this given below using reflections, but it doesnt gave values (I guess it is returning state field "status" 's metadata).
historyForId is of type : ArrayList<Map<String,ContractState>>
val temp2 = historyForId.first().get("contractStateData")!!.javaClass.getDeclaredField("status")
答案1
得分: 1
将答案添加到在 Corda 账本 Slack 上找到的内容。发现该字段的 "isAccessible" 被设置为 false。通过显式将 "isAccessible" 分配为 true,问题得以解决。
英文:
Adding the answer as found on Corda ledger slack. It was found that "isAccessible" for the field was set to false. The issue was resolved by assigning "isAccessible" to true explicitly.
专注分享java语言的经验与见解,让所有开发者获益!
评论