You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Mitch Claborn <mi...@claborn.net> on 2022/08/30 18:40:43 UTC
Generate setters that return this
The "Generate Getters and Setters" dialog generates setters plain Java
setters with return type "void". Many times I'd like the setter to
return "this" instead. Is there a way to have those generated
automatically?
--
Mitch
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: Generate setters that return this
Posted by Neil C Smith <ne...@apache.org>.
On Tue, 6 Sept 2022 at 18:20, Mitch Claborn <mi...@claborn.net> wrote:
> Yes, I suppose Builder is the more correct term.
No, it isn't. It's a fluent API. A builder might use fluent setters,
but they have uses elsewhere (if you do need mutability).
Personally, I think this might be a good addition - the file you
probably want to look at is at
https://github.com/apache/netbeans/blob/master/java/java.editor/src/org/netbeans/modules/java/editor/codegen/GetterSetterGenerator.java
I'd also like to see an option to leave out the set and get prefixes.
Best decision in records was not to bake that convention into the
language!
Best wishes,
Neil
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
RE: Generate setters that return this
Posted by "Greenberg, Gary" <gg...@visa.com.INVALID>.
Under 'Refactor' menu you can find options to
a) Replace constructor with Builder;
b) Replace constructor with Factory
But I don't think you can generate builders directly.
-----Original Message-----
From: Mitch Claborn <mi...@claborn.net>
Sent: Tuesday, September 6, 2022 10:20 AM
To: users@netbeans.apache.org
Subject: Re: Generate setters that return this
Yes, I suppose Builder is the more correct term. The question is the
same: Is there a way in NetBeans to generate those?
Mitch
On 9/6/22 11:52, Greenberg, Gary wrote:
> I think you are confusing setters with builders.
> Setters do not return anything, but builders do return this.
> Lookup design patterns.
>
> -----Original Message-----
> From: Mitch Claborn <mi...@claborn.net>
> Sent: Tuesday, September 6, 2022 5:49 AM
> To: users@netbeans.apache.org
> Subject: Re: Generate setters that return this
>
> I assume from the lack of response that this is not currently possible and would require development. Does anyone have an idea of how much work would be required to develop this?
>
>
> Mitch
>
> On 8/30/22 13:40, Mitch Claborn wrote:
>> The "Generate Getters and Setters" dialog generates setters plain Java
>> setters with return type "void". Many times I'd like the setter to
>> return "this" instead. Is there a way to have those generated
>> automatically?
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: users-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcwiki.apache.org%2Fconfluence%2Fdisplay%2FNETBEANS%2FMailing%2Blists&data=05%7C01%7Cggreenbe%40visa.com%7C69aeaefe5d984239883d08da902c0e97%7C38305e12e15d4ee888b9c4db1c477d76%7C0%7C0%7C637980816142573703%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=m5q3zwm8CtjXLUVTogvUPQsFIjMsEN0HLD5lTeRURy8%3D&reserved=0
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: users-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcwiki.apache.org%2Fconfluence%2Fdisplay%2FNETBEANS%2FMailing%2Blists&data=05%7C01%7Cggreenbe%40visa.com%7C69aeaefe5d984239883d08da902c0e97%7C38305e12e15d4ee888b9c4db1c477d76%7C0%7C0%7C637980816142573703%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=m5q3zwm8CtjXLUVTogvUPQsFIjMsEN0HLD5lTeRURy8%3D&reserved=0
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcwiki.apache.org%2Fconfluence%2Fdisplay%2FNETBEANS%2FMailing%2Blists&data=05%7C01%7Cggreenbe%40visa.com%7C69aeaefe5d984239883d08da902c0e97%7C38305e12e15d4ee888b9c4db1c477d76%7C0%7C0%7C637980816142573703%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=m5q3zwm8CtjXLUVTogvUPQsFIjMsEN0HLD5lTeRURy8%3D&reserved=0
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: Generate setters that return this
Posted by Mitch Claborn <mi...@claborn.net>.
Yes, I suppose Builder is the more correct term. The question is the
same: Is there a way in NetBeans to generate those?
Mitch
On 9/6/22 11:52, Greenberg, Gary wrote:
> I think you are confusing setters with builders.
> Setters do not return anything, but builders do return this.
> Lookup design patterns.
>
> -----Original Message-----
> From: Mitch Claborn <mi...@claborn.net>
> Sent: Tuesday, September 6, 2022 5:49 AM
> To: users@netbeans.apache.org
> Subject: Re: Generate setters that return this
>
> I assume from the lack of response that this is not currently possible and would require development. Does anyone have an idea of how much work would be required to develop this?
>
>
> Mitch
>
> On 8/30/22 13:40, Mitch Claborn wrote:
>> The "Generate Getters and Setters" dialog generates setters plain Java
>> setters with return type "void". Many times I'd like the setter to
>> return "this" instead. Is there a way to have those generated
>> automatically?
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: users-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcwiki.apache.org%2Fconfluence%2Fdisplay%2FNETBEANS%2FMailing%2Blists&data=05%7C01%7Cggreenbe%40visa.com%7Cd6af7d4be6a24329ebde08da90063d98%7C38305e12e15d4ee888b9c4db1c477d76%7C0%7C0%7C637980653738217386%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1Ejwm399RgNZOE4haI%2FCnRfTp6MH2uJI3hX8hC8L1Z0%3D&reserved=0
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: users-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
RE: Generate setters that return this
Posted by "Greenberg, Gary" <gg...@visa.com.INVALID>.
I think you are confusing setters with builders.
Setters do not return anything, but builders do return this.
Lookup design patterns.
-----Original Message-----
From: Mitch Claborn <mi...@claborn.net>
Sent: Tuesday, September 6, 2022 5:49 AM
To: users@netbeans.apache.org
Subject: Re: Generate setters that return this
I assume from the lack of response that this is not currently possible and would require development. Does anyone have an idea of how much work would be required to develop this?
Mitch
On 8/30/22 13:40, Mitch Claborn wrote:
> The "Generate Getters and Setters" dialog generates setters plain Java
> setters with return type "void". Many times I'd like the setter to
> return "this" instead. Is there a way to have those generated
> automatically?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcwiki.apache.org%2Fconfluence%2Fdisplay%2FNETBEANS%2FMailing%2Blists&data=05%7C01%7Cggreenbe%40visa.com%7Cd6af7d4be6a24329ebde08da90063d98%7C38305e12e15d4ee888b9c4db1c477d76%7C0%7C0%7C637980653738217386%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1Ejwm399RgNZOE4haI%2FCnRfTp6MH2uJI3hX8hC8L1Z0%3D&reserved=0
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: Generate setters that return this
Posted by Mitch Claborn <mi...@claborn.net>.
I assume from the lack of response that this is not currently possible
and would require development. Does anyone have an idea of how much work
would be required to develop this?
Mitch
On 8/30/22 13:40, Mitch Claborn wrote:
> The "Generate Getters and Setters" dialog generates setters plain Java
> setters with return type "void". Many times I'd like the setter to
> return "this" instead. Is there a way to have those generated
> automatically?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists