Files
openide/java/java-impl/resources/inspectionDescriptions/FieldNotUsedInToString.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

38 lines
1.2 KiB
HTML

<html>
<body>
Reports fields that are not used in the <code>toString()</code> method of a class.
<p>Helps discover fields added after the <code>toString()</code> method was last updated.
The quick-fix regenerates the <code>toString()</code> method.</p>
<p>
In the <b>Generate | toString()</b> dialog, it is possible to exclude fields from this check.
This inspection will also check for problems with getter methods if the <em>Enable getters in code generation</em> option is enabled there.
<p>Example:</p>
<pre><code>
<b>public class</b> Relevant {
<b>private</b> String name; // not used in toString()
<b>private int</b> index;
<b>private int</b> length;
@Override
<b>public</b> String toString() {
<b>return</b> "Relevant{" + "index=" + index +
", length=" + length + '}';
}
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
<b>public class</b> Relevant {
<b>private</b> String name;
<b>private int</b> index;
<b>private int</b> length;
@Override
<b>public</b> String toString() {
<b>return</b> "Relevant{" + "name='" + name + '\'' +
", index=" + index + ", length=" + length + '}';
}
}
</code></pre>
</body>
</html>