You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When transpiling from typescript interfaces to java, Jsii creates builder classes for the interface to. We have places in our library where we want to take in an existing pre-built instance of the interface and be able to copy the existing state and make some overrides. Right now it seems the only way is to manually copy all of the existing stateful members of the class into a new builder.
JsiiClassProps newProps = new JsiiClassBuilder()
// call all setting methods to copy state like so .myJsiiInterfaceMember(props.getMyJsiiInterfaceMember())
.build();
versus something like this where the builder can just take the state of the existing inteface object as a common pattern w/ a constructor param
JsiiClassProps newProps = new JsiiClassBuilder(props)
.myJsiiInterfaceMemberToOverride(props.getMyJsiiInterfaceMemberToOverride())
.build();
whereas in typescript this can be easily accomplished already w/ the spread operator on instantiation
Use Case
See description, we regularly need to perform some overrides on an existing base level instance, having to override everything using all of the base level instance member getters is tedious, verbose, and error prone.
Proposed Solution
Have an additional constructor on the builder that takes in an existing instance of the built type T class and creates the initial state of the builder
JsiiClassProps newProps = new JsiiClassBuilder(props)
.myJsiiInterfaceMemberToOverride(props.getMyJsiiInterfaceMemberToOverride())
.build();
Other Information
No response
Acknowledgements
I may be able to implement this feature request
This feature might incur a breaking change
CDK version used
2.162.1
Environment details (OS name and version, etc.)
MacOS
The text was updated successfully, but these errors were encountered:
Describe the feature
When transpiling from typescript interfaces to java, Jsii creates builder classes for the interface to. We have places in our library where we want to take in an existing pre-built instance of the interface and be able to copy the existing state and make some overrides. Right now it seems the only way is to manually copy all of the existing stateful members of the class into a new builder.
versus something like this where the builder can just take the state of the existing inteface object as a common pattern w/ a constructor param
whereas in typescript this can be easily accomplished already w/ the spread operator on instantiation
Use Case
See description, we regularly need to perform some overrides on an existing base level instance, having to override everything using all of the base level instance member getters is tedious, verbose, and error prone.
Proposed Solution
Have an additional constructor on the builder that takes in an existing instance of the built type T class and creates the initial state of the builder
Other Information
No response
Acknowledgements
CDK version used
2.162.1
Environment details (OS name and version, etc.)
MacOS
The text was updated successfully, but these errors were encountered: