I think this is a big NO. Even without entering in the merit of the
antipattern of having many fields constantly at null....
What is the limit/the next thing to exclude?
empty lists? empty strings? flag setted to false?
On 24 March 2018 at 07:43, Lars <northp...@gmail.com> wrote:
> Would love to see a parameter to exclude null fields. Would cut down on
> meaningless noise.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Project Lombok" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to project-lombok+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombok+unsubscribe@googlegroups.com.
Customization #859185 requested of toString behaviour.
I think I have to give up on the dream of some sort of DSL that covers most of this stuff; how the heck would you put 'skip null fields' in a DSL anyway? It'd be as convoluted as regexes are.If it's a flag on toString, it applies to all fields. One way out is to have a @ToString.Exclude and @ToString.Include annotation, where Include can also be put on methods, and IT can contain the noNull stuff too? Ugh, this feels utterly undiscoverable by your average lombok user.
Okay, let's flesh this out some:1. There will be @ToString.Include and @ToString.Exclude annotations.
2. @ToString.Include is like 'of' and exclude is like 'exclude', except.. you can put Include on a method. You can't put exclude on a method.
Problem 2A: What is the 'fieldname' of an @Include on a method? [I'm leaning to the answer: "Name of the method"]
Problem 2B: Should it be configurable? [I'm leaning: no]
Problem 2C: What if an @Include marked method has the same name as a field.. does that imply the field is then excluded unless also tagged with an include annotation, or should we just print both? [I'm leaning: Exclude by default, but I find this one an annoying wart and making the feature more complicated than I'd like]
Problem 2D: A common use case would presumably be to 'replace' a field's toString output with a modified form, and you can use the method to accomplish this. However, if you put @Include on a field, that implies it is the same as @ToString(of="foo"), which means all OTHER fields are NOT included.
Therefore, to have the same behaviour for methods, putting a single @Include on a method then means all fields are excluded by default. However, unlike with of/fields that doesn't sound obvious to me. It also goes counter to common use-cases. That is, I expect that a common use case is that some field needs custom treatment for toString and therefore you want to exclude the field and include the method that returns an alternative string for the field. [Solution: I dunno.. perhaps instead of @ToString.Include we need a @ToString.Also, or a @ToString.Extra, or a @ToString.Replacement, or.... see, I don't like any of this. This is way too complicated!]
3. The Include annotation can offer some standard customizations. For starters, skipNull=true.Problem 3A: Does it need any others right now? Perhaps 'include field name'? [I'm leaning: No, let's start here]
4. If using any @Include or @Exclude, you cannot use 'of' or 'exclude' on the annotation (lombok-generated compiler error).
I think that toString is not too long anyway... so if you have any
specific need you can just implement it.
On 28 March 2018 at 06:57, Reinier Zwitserloot <rein...@gmail.com> wrote:
> Customization #859185 requested of toString behaviour.
>
> I think I have to give up on the dream of some sort of DSL that covers most
> of this stuff; how the heck would you put 'skip null fields' in a DSL
> anyway? It'd be as convoluted as regexes are.
>
> If it's a flag on toString, it applies to all fields. One way out is to have
> a @ToString.Exclude and @ToString.Include annotation, where Include can also
> be put on methods, and IT can contain the noNull stuff too? Ugh, this feels
> utterly undiscoverable by your average lombok user.
>
> On Friday, March 23, 2018 at 10:06:23 PM UTC+1, Maaartin G wrote:
>>
>> On Fri, Mar 23, 2018 at 7:50 PM, Marco Servetto <marco....@gmail.com>
>>> > email to project...@googlegroups.com.
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Project Lombok" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to project...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Project Lombok" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to project...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/1168b7df-a700-40e4-b857-8be7ea9c597a%40googlegroups.com.