-
Notifications
You must be signed in to change notification settings - Fork 247
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
feat(java): offer Builders for certain Java classes #895
Conversation
Provide a nested `Builder` class with a static `create` factory for all classes that adhere to the following constraints: - The class is not `abstract` - The class has a visible `initializer` (aka `constructor`) - The constructor has exactly one `struct` (aka `datatype`) parameter - The constructor is not variadic Such builders will request the *positional* parameters to be passed directly to the `Builder#create` method and can (at least currently) not be subsequently modified. All parameters from the `struct` are then set direcly on the `Builder` instance. Fixes #488
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just reviewing the target java code.
.../expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Calculator.java
Outdated
Show resolved
Hide resolved
.../expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Calculator.java
Outdated
Show resolved
Hide resolved
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
6c0b798
to
ae65689
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit comment.
return new software.amazon.jsii.tests.calculator.Calculator( | ||
this.props != null ? this.props.build() : null | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more readable but not what I actually meant about multi-line. My apologies for not being explicit and clear. I think it should be split into a local variable assignment followed by passing that local variable in as an argument. This is more of a nit though so I wouldn't block the build on it, it's your call.
Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it! |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Provide a nested
Builder
class with a staticcreate
factory for allclasses that adhere to the following constraints:
abstract
initializer
(akaconstructor
)struct
(akadatatype
) parameterSuch builders will request the positional parameters to be passed
directly to the
Builder#create
method and can (at least currently) notbe subsequently modified. All parameters from the
struct
are then setdirecly on the
Builder
instance. If there are multiplestruct
parameters,all but the first one are handled like other positional parameters.
Fixes #488
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.