Class ContractCompanion<Ct,Id,Data>
- java.lang.Object
-
- com.daml.ledger.javaapi.data.codegen.ContractTypeCompanion<Ct,Id,Data,Data>
-
- com.daml.ledger.javaapi.data.codegen.ContractCompanion<Ct,Id,Data>
-
- Type Parameters:
Ct
- TheContract
subclass generated within the template class.Id
- TheContractId
subclass generated within the template class.Data
- The generatedTemplate
subclass named after the template, whose instances contain only the payload.
- Direct Known Subclasses:
ContractCompanion.WithKey
,ContractCompanion.WithoutKey
public abstract class ContractCompanion<Ct,Id,Data> extends ContractTypeCompanion<Ct,Id,Data,Data>
Metadata and utilities associated with a template as a whole, rather than one single contract made from that template.Application code should not instantiate or subclass; instead, refer to the
COMPANION
field on generatedTemplate
subclasses. Allprotected
members herein are considered part of the INTERNAL API.Every instance is either a
ContractCompanion.WithKey
orContractCompanion.WithoutKey
, depending on whether the template defined akey
type.ContractCompanion.WithKey
defines extra utilities for working with contract keys.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ContractCompanion.FromJson<T>
static class
ContractCompanion.WithKey<Ct,Id,Data,Key>
static class
ContractCompanion.WithoutKey<Ct,Id,Data>
-
Field Summary
Fields Modifier and Type Field Description protected ContractCompanion.FromJson<Data>
fromJson
-
Fields inherited from class com.daml.ledger.javaapi.data.codegen.ContractTypeCompanion
choices, TEMPLATE_ID, TEMPLATE_ID_WITH_PACKAGE_ID
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ContractCompanion(java.lang.String templateClassName, Identifier templateId, java.util.function.Function<java.lang.String,Id> newContractId, java.util.function.Function<DamlRecord,Data> fromValue, ContractCompanion.FromJson<Data> fromJson, java.util.List<Choice<Data,?,?>> choices)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Data
fromJson(java.lang.String json)
static <Data> ValueDecoder<Data>
valueDecoder(ContractCompanion<?,? extends ContractId<Data>,Data> companion)
Static method to generate an implementation ofValueDecoder
of typeData
with metadata from the providedContractCompanion
.-
Methods inherited from class com.daml.ledger.javaapi.data.codegen.ContractTypeCompanion
fromCreatedEvent, toContractId
-
-
-
-
Field Detail
-
fromJson
protected final ContractCompanion.FromJson<Data> fromJson
-
-
Constructor Detail
-
ContractCompanion
protected ContractCompanion(java.lang.String templateClassName, Identifier templateId, java.util.function.Function<java.lang.String,Id> newContractId, java.util.function.Function<DamlRecord,Data> fromValue, ContractCompanion.FromJson<Data> fromJson, java.util.List<Choice<Data,?,?>> choices)
-
-
Method Detail
-
valueDecoder
public static <Data> ValueDecoder<Data> valueDecoder(ContractCompanion<?,? extends ContractId<Data>,Data> companion)
Static method to generate an implementation ofValueDecoder
of typeData
with metadata from the providedContractCompanion
.- Parameters:
companion
- an instance ofContractCompanion
.- Returns:
- The
ValueDecoder
for parsingValue
to get an instance ofData
.
-
fromJson
public Data fromJson(java.lang.String json) throws JsonLfDecoder.Error
- Throws:
JsonLfDecoder.Error
-
-