Class ContractTypeCompanion<Ct,Id,ContractType,Data>
java.lang.Object
com.daml.ledger.javaapi.data.codegen.ContractTypeCompanion<Ct,Id,ContractType,Data>
- Type Parameters:
Ct- The specific type ofContractrepresenting contracts from the ledger. Always a subtype ofContract<Id, Data>.Id- The code-generated class ofContractIds specific to this template or interface. Always a subtype ofContractId<ContractType>.ContractType- The type argument toContractIds of this contract type. This is the same asDatafor templates, but is a pure marker type for interfaces.Data- The "payload" data model for a contract. This is the template payload for templates, and the view type for interfaces.
- Direct Known Subclasses:
ContractCompanion,InterfaceCompanion
The commonality between
ContractCompanion and InterfaceCompanion.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Map<String,Choice<ContractType, ?, ?>> The provides a mapping of choice name to Choice.final Stringfinal Stringfinal PackageVersionfinal IdentifierThe full template ID of the template or interface that defined this companion.final Identifier -
Method Summary
Modifier and TypeMethodDescriptionabstract CtfromCreatedEvent(CreatedEvent event) Tries to parse a contract from an event expected to create aCtcontract.final IdtoContractId(ContractId<ContractType> parameterizedContractId) Convert from a genericContractIdto the specific contract ID subclass generated as part of this companion's template or interface.
-
Field Details
-
PACKAGE
-
PACKAGE_ID
-
PACKAGE_NAME
-
PACKAGE_VERSION
-
TEMPLATE_ID
The full template ID of the template or interface that defined this companion. -
TEMPLATE_ID_WITH_PACKAGE_ID
-
choices
The provides a mapping of choice name to Choice.// if you statically know the name of a choice var c1 = Bar.COMPANION.choices.get("Transfer"); // it is better to retrieve it directly from the generated field var c2 = Bar.CHOICE_Transfer;
-
-
Method Details
-
getTemplateIdWithPackageId
-
fromCreatedEvent
Tries to parse a contract from an event expected to create aCtcontract. This is either theCreatedEvent.getArguments()forContractCompanion, or one ofCreatedEvent.getInterfaceViews()for anInterfaceCompanion.- Parameters:
event- the event to try to parse a contract from- Returns:
- The parsed contract, with payload and metadata, if present.
- Throws:
IllegalArgumentException- when theCreatedEventpayload cannot be parsed asData, or theCreatedEvent.getContractKey()cannot be parsed as a contract key.
-
toContractId
Convert from a genericContractIdto the specific contract ID subclass generated as part of this companion's template or interface. Most applications should not need this function, but if your Daml data types include types likeContractId twheretis any type parameter, that is likely to result in code-generated types likeContractId<t>that need to be passed to this function before e.g.exercise*methods can be used.
-