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

feat(java): offer Builders for certain Java classes #895

Merged
merged 5 commits into from
Oct 29, 2019

Conversation

RomainMuller
Copy link
Contributor

@RomainMuller RomainMuller commented Oct 18, 2019

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 non-protected initializer (aka constructor)
  • The constructor has at least one struct (aka datatype) parameter

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. If there are multiple struct 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.

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@bmaizels bmaizels left a 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.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@RomainMuller RomainMuller marked this pull request as ready for review October 29, 2019 14:04
@RomainMuller RomainMuller requested a review from a team as a code owner October 29, 2019 14:04
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@RomainMuller RomainMuller force-pushed the rmuller/java-builder-improvements branch from 6c0b798 to ae65689 Compare October 29, 2019 14:16
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@bmaizels bmaizels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit comment.

Comment on lines +249 to +251
return new software.amazon.jsii.tests.calculator.Calculator(
this.props != null ? this.props.build() : null
);
Copy link
Contributor

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.

@mergify
Copy link
Contributor

mergify bot commented Oct 29, 2019

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Oct 29, 2019
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit f9c1335 into master Oct 29, 2019
@mergify mergify bot deleted the rmuller/java-builder-improvements branch October 29, 2019 16:25
@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

java: Improve use of Builder pattern
3 participants