Getters for Builder
See original GitHub issueI have constructed a Charge builder like below,
ChargeCreateParams.Builder chargeCreateParamsBuilder = new ChargeCreateParams.Builder();
chargeCreateParamsBuilder.setAmount(Long.valueOf("100"));
chargeCreateParamsBuilder.setDescription("desc");
chargeCreateParamsBuilder.setCurrency("USD");
chargeCreateParamsBuilder.putMetadata("CompanyName", "Stripe");
chargeCreateParamsBuilder.putMetadata("Designation", "Remote Dev");
Before building the builder using chargeCreateParamsBuilder.build()
, at some point of time, say for ex, I need to verify whether I had set a meta data in the builder.(another ex, Maybe I might be validating the value set in the builder after some time)
I now need to retrieve all the values set as Meta data in the builder. As of now, I am not able to retrieve the vaules set in the Builder object.
There is no support to retrieve the nodes set in the builder.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Is it strange for a Builder object to have getter methods?
I think there is nothing wrong per se to have getters in your builder class allowing to inspect which data was passed in....
Read more >How to generate getters for lombok Builder? - Stack Overflow
When trying to use a getter on a builder, e.g. MyEntityBuilder.getName() , IDEA states that it "Cannot resolve method".
Read more >@Getter and @Setter - Project Lombok
A default getter simply returns the field, and is named getFoo if the field is called foo (or isFoo if the field's type...
Read more >Lombok Builder with Custom Setter - Baeldung
In this tutorial, we'll take a look at how Lombok's @Builder annotation works and how we can customize it for our specific needs....
Read more >Generate getters in the Builder class · Issue #432 - GitHub
Sometimes there is a need to access to a Builder getter to do extra logic. @Value.Immutable public abstract class Foo { public abstract ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve given this a bit more thought and I think getters directly on builder classes are rather uncommon and a bit of a violation of the single responsibility principle.
In version 13.2.0, we’ve added getters on the resulting parameters classes (i.e. the classes that are returned by the parameters builders). Would that work for your use case, @Thilakeswar? You’d be able to do something like this:
I think this is a reasonable request. No promises as to when we’ll get to it, but let’s keep this open for now.