|
Lombok - v0.10.8 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Target(value=TYPE) @Retention(value=SOURCE) public @interface ToString
Generates an implementation for the toString
method inherited by all objects.
If the method already exists, then ToString
will not generate any method, and instead warns
that it's doing nothing at all. The parameter list and return type are not relevant when deciding to skip generation of
the method; any method named toString
will make ToString
not generate anything.
By default, all fields that are non-static are used in the toString generation. You can exclude fields by specifying them
in the exclude
parameter. You can also explicitly specify the fields that
are to be used by specifying them in the of
parameter.
Array fields are handled by way of Arrays.deepToString(Object[])
where necessary.
The downside is that arrays with circular references (arrays that contain themselves,
possibly indirectly) results in calls to toString
throwing a
StackOverflowError
. However, the implementations for java's own ArrayList
suffer
from the same flaw.
The toString
method that is generated will print the class name as well as each field (both the name
and the value). You can optionally choose to suppress the printing of the field name, by setting the
includeFieldNames
flag to false.
You can also choose to include the result of toString
in your class's superclass by setting the
callSuper
to true.
Optional Element Summary | |
---|---|
boolean |
callSuper
Include the result of the superclass's implementation of toString in the output. |
boolean |
doNotUseGetters
Normally, if getters are available, those are called. |
String[] |
exclude
Any fields listed here will not be printed in the generated toString implementation. |
boolean |
includeFieldNames
Include the name of each field when printing it. |
String[] |
of
If present, explicitly lists the fields that are to be printed. |
public abstract boolean includeFieldNames
public abstract String[] exclude
toString
implementation.
Mutually exclusive with of()
.
public abstract String[] of
Mutually exclusive with exclude()
.
public abstract boolean callSuper
toString
in the output.
default: false
public abstract boolean doNotUseGetters
true
.
default: false
|
Lombok - v0.10.8 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |