Files
openide/java/java-impl/resources/inspectionDescriptions/CallToSimpleSetterInClass.html
2025-02-05 04:43:28 +00:00

40 lines
1.1 KiB
HTML

<html>
<body>
Reports calls to a simple property setter from within the property's class.
<p>
A simple property setter is defined as one which simply assigns the value of its parameter to a field,
and does no other calculations. Such simple setter calls can be safely inlined.
Some coding standards also suggest against the use of simple setters for code clarity reasons.
</p>
<p><b>Example:</b></p>
<pre><code>
class Foo {
private int index;
public Foo(int idx) {
setIndex(idx);
}
public void setIndex(int idx) {
index = idx;
}
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
class Foo {
private int index;
public Foo(int idx) {
index = idx;
}
public void setIndex(int idx) {
index = idx;
}
}
</code></pre>
<!-- tooltip end -->
<p>Use the following options to configure the inspection:</p>
<ul>
<li>Whether to only report setter calls on <code>this</code>, not on objects of the same type passed in as a parameter.</li>
<li>Whether to ignore non-<code>private</code> setters.</li>
</ul>
</body>
</html>