I found with no succes the simple way to use lombok @toString with the skip null field behaviour.
I think create my own toString function for all function using the aspect programmation. Like that i can chek all null field and skip that.
But it is the good practice, or lombok @toString has one option to do that simply?
Best Regards
If you want to skip some fields, you can annotate these fields with @ToString. Exclude . Alternatively, you can specify exactly which fields you wish to be used by using @ToString(onlyExplicitlyIncluded = true) , then marking each field you want to include with @ToString.
The @ToString annotation generates an implementation for the toString() method where the class name, along with each field in order — separated by commas — is printed. By default, the field names will be printed. Passing includeFieldNames=false to the annotation will print the field values but not the field names.
The Lombok @ToString annotation generates an implementation for the toString method and by default, it'll print your class name, along with each field, in order, separated by commas. By default non-static fields are excluded in generated toString() .
Yes, @Data implies @EqualsAndHashCode and @ToString .
It's an open issue on Lombok, so it's not part of implementation yet. see #1297.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With