Skip to content

Feature request: @ToString allows skipping null-value fields #1752

@chriswilty

Description

@chriswilty

It would be nice if I could skip null-valued fields in the generated toString(), e.g. with

@ToString(excludeNulls = true)
class MyClass { ... }

As Optionals are not supported by lombok, I may have one or more fields that are nullable in my DTO, and which do not need to be set during construction.

This is a nice-to-have; it's not the end of the world to need to copy the generated toString and add in my null-exclusion logic, nor indeed to see "fieldName=null" in the toString output, as I only use it for logging. If it's not an easy win, don't worry about it 😁

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions