Is it possible to exclude the class name from Lombok @ToString?

Annotations class project Lombok , @ToString

, is used to automatically create a method toString()

in the class, he says.

For this class:

@ToString
public class SomeClass {
  String field1="Field #1";
  String field2="Field #2";
}

      

Calling the generated method toString()

will give this result:

  SomeClass(field1="Field #1", field2="Field #2")

Optional annotation elements can be used to include or exclude certain fields, but I want to know that ...

"Is there a way to tell Lombok to exclude the class name from the output?"

Maybe something like:

@ToString(exclude="#classname")
public class SomeClass { ... }

      

+3


source to share


2 answers


Not. There is @ToString

not a single option in the annotation that would allow you to do this.



+2


source


Indeed, lombok does not support this. An umbrella function request for improved toString formatting can be found here:



https://github.com/rzwitserloot/lombok/issues/1297

0


source







All Articles