Any class definition may be annotated with @ToString
to let lombok generate an implementation of the toString()
method. By default, it'll print your class name, along with each field, in order, separated by commas.
By setting the includeFieldNames
parameter to true you can add some clarity (but also quite some length) to the output of the toString()
method.
By default, all non-static fields will be printed. If you want to skip some fields, you can name them in the exclude
parameter; each named field will not be printed at all. Alternatively, you can specify exactly which fields you wish to be used by naming them in the of
parameter.
By setting callSuper
to true, you can include the output of the superclass implementation of toString
to the output. Be aware that the default implementation of toString()
in java.lang.Object
is pretty much meaningless, so you probably don't want to do this unless you are extending another class.
Read full article from Project Lombok
No comments:
Post a Comment