I'm trying to build a generic repository around Corda's vault. It should look something like this:
class VaultRepository<out T : ContractState>(private val services: CordaRPCOps) {
fun getUnconsumedStateByExternalId(externalId: String): T {
return services.vaultQuery<T>(...).states.single().state.data
}
}
But I get this error:
Cannot use 'T' as reified type parameter
I could use another vaultQuery
function, which takes a Class<T>
instead as a parameter, but I need to be able to get it from VaultRepository<T>
first.
Is there a way to get T from a classes generic type parameter list?