Hi all,
Issue:
I am trying to specifically retrieve the return type of a choice defined in DAML files in the form of a corresponding java type.
Steps done:
Looking at
codegen java
and the DAML to LF conversion process in the docs
data conversion : How Daml Types are Translated to Daml-LF — Daml SDK 2.2.0 documentation
template to api commands conversion : How Daml Types are Translated to Protobuf — Daml SDK 2.2.0 documentation
It seems that the conversion of choices results in the creation of a transaction in Java/Protobuf, therefore not including the return type of a choice in protobuf/java equivalent.
Alternative currently working on:
Something I was thinking of doing was to parse the .daml files, extract the corresponding return type via pattern matching from the strings and pattern match it to determine what it’s corresponding data type is in Java (Given that all the templates and used data types are defined during java codegen
)
However this would require manually defining all the available string patterns for DAML types and what their corresponding java type is.
Specific Questions:
I was wondering if either
- There is a current solution to extract the choice return types and return their corresponding Java data type.
- There is a daml file parser which can map the DAML choice return type into an easily accessible format (such as JSON) and if there is a daml to java mapping library that allows us to use that extracted return type string and identify the corresponding java data type (if not in the specific java data type, at least the wrapper method with a generic data type, such as a tuple, list or the corresponding wrapper class for Either a/Optional a etc.)
Thank you!