Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-reflective abstractions for Java codegen Contracts #13724

Merged
merged 29 commits into from
May 6, 2022
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
72ae4dc
shift some generated Contract code to a handwritten superclass
S11001001 Apr 27, 2022
5d43d23
support contracts with keys as well
S11001001 Apr 27, 2022
f6aada1
companion types for templates and contracts
S11001001 Apr 27, 2022
99837d0
simplify the key-dependent generator branches
S11001001 Apr 27, 2022
32b2b85
reformulate ContractCompanion so generated code doesn't have to subclass
S11001001 Apr 27, 2022
d11ccd8
generate a `COMPANION` for each template
S11001001 Apr 27, 2022
da92178
missing @FunctionalInterface
S11001001 Apr 28, 2022
70cb4c8
slightly smaller companion constructor
S11001001 Apr 28, 2022
2ea9e9d
optional newlines for a nicer constructor call
S11001001 Apr 28, 2022
4a02c9b
fromIdAndRecord is a static forwarder
S11001001 Apr 28, 2022
ca8fb95
encapsulate the idea of a static forwarder to companion
S11001001 Apr 28, 2022
173b87a
replace fromCreatedEvent with a forwarder
S11001001 Apr 28, 2022
23cccf8
reformulate companion forwarder without generating patterns
S11001001 Apr 28, 2022
6430ef0
deprecated fromIdAndRecord is a companion forwarder
S11001001 Apr 28, 2022
d6059cd
small reformat
S11001001 Apr 28, 2022
345fde8
remove magic strings TEMPLATE_ID and COMPANION
S11001001 Apr 28, 2022
5b2ba1c
Merge commit '615d2e62068c0213b8c43f2a73f7ef2ead23744f' into 13471-ja…
S11001001 Apr 28, 2022
8f2f077
simpler super constructor derivation
S11001001 Apr 29, 2022
c458134
reformat
S11001001 Apr 29, 2022
67672f7
link Contract to its companion
S11001001 Apr 29, 2022
a18e73d
do not generate toString for Contract
S11001001 Apr 29, 2022
4694cef
note on getCompanion type
S11001001 Apr 29, 2022
2af8bd0
use the companion in some ledger reading tests
S11001001 Apr 29, 2022
789183e
test the companion's fromCreatedEvent and Contract's toString
S11001001 Apr 29, 2022
77f7df3
document changes in template Java codegen
S11001001 Apr 29, 2022
dce512e
add changelog
S11001001 Apr 29, 2022
d8836b2
rewrite changelog
S11001001 May 6, 2022
6b53ca1
Merge commit '1b4f9bb2f8f6fb6139d694764f039e9c37d26978' into 13471-ja…
S11001001 May 6, 2022
0de313e
remove unused abstract method; note deprecation times
S11001001 May 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simpler super constructor derivation
  • Loading branch information
S11001001 committed Apr 29, 2022
commit 8f2f0777ebec322b0a6a192e5798447f19dbc845
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@ object ContractClass {
.addParameter(setOfStrings, signatoriesFieldName)
.addParameter(setOfStrings, observersFieldName)

val (superCtor, superCtorKeyArgs) = contractKeyClassName.cata(
_ => ("super($L, $L, $L, $L, $L, $L)", Seq(contractKeyFieldName)),
("super($L, $L, $L, $L, $L)", Seq.empty),
)
val superCtorKeyArgs = contractKeyClassName.map(_ => contractKeyFieldName).toList
constructorBuilder.addStatement(
superCtor,
Seq(idFieldName, dataFieldName, agreementFieldName) ++ superCtorKeyArgs ++ Seq(
signatoriesFieldName,
observersFieldName,
): _*
"super($L)",
CodeBlock.join(
(Seq(idFieldName, dataFieldName, agreementFieldName) ++ superCtorKeyArgs ++ Seq(
signatoriesFieldName,
observersFieldName,
)).map(CodeBlock.of("$L", _)).asJava,
",$W",
),
)

val constructor = constructorBuilder.build()
Expand Down