question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is your feature request related to a problem? Please describe. When creating objects which have multiple properties and constraints, like required values, the builder pattern is helpful so we don’t need a constructor with a lot of parameters.

Describe the solution you’d like The [Builder] attribute should generate a static method Builder() which returns an instance of a generate class SomeClassBuilder which has one method per property (eg, .Name("my name")) and a method build() that creates that runs all the checks and creates the final class calling its constructor. See the lombok documentation for details.

Describe alternatives you’ve considered For now, an alternative is to generate the all args constructor.

Additional context A simple implementation could be shipped without the need of all the caveats and features that the lombok implementation has.

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
CollinAlpertcommented, Jun 27, 2023

I agree with the syntax. However throwing an exception when a user does not call a specific method seems kind of ugly. That should be up to the user to validate. This package deals with compile-time assistance. I don’t feel comfortable generating code which errors at runtime.

0reactions
CollinAlpertcommented, Aug 7, 2023

I have thought about this some more and am not happy with any of the possible solutions I have come up with, which is why I will close this for now and see if I can implement a much simpler form of the builder pattern in the future. I fear that the generated code will need to be made configurable and that will be a lot of work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Builder Magazine: Home Design, Building Materials ...
BUILDER Online provides home builders with home building news, home plans, home design ideas, and building product information, helping them manage their home ......
Read more >
Builder.io - Visual Headless CMS
Build and optimize digital experiences for any tech stack with full control, visually.
Read more >
Builder.ai® - Award Winning App Development Platform
Get your mobile app developed easily. AI makes developing your app on our award-winning platform faster and more cost-effective. See how it works....
Read more >
Builder Definition & Meaning
The meaning of BUILDER is one that builds; especially : one that contracts to build and supervises building operations. How to use builder...
Read more >
Builder
Construction worker, who specializes in building work ; Carpenter, a skilled craftsman who works with wood ; General contractor, that specializes in building...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found