mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-06 08:00:18 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
46 lines
1.6 KiB
HTML
46 lines
1.6 KiB
HTML
<html>
|
|
<body>
|
|
Reports methods overriding superclass methods but are not annotated with <code>@java.lang.Override</code>.
|
|
<p>
|
|
Annotating methods with <code>@java.lang.Override</code> improves code readability since it shows the intent.
|
|
In addition, the compiler emits an error when a signature of the overridden method doesn't match the superclass method.
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
class X {
|
|
public String toString() {
|
|
return "hello world";
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
class X {
|
|
@Override
|
|
public String toString() {
|
|
return "hello world";
|
|
}
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>Configure the inspection:</p>
|
|
<ul>
|
|
<li>
|
|
Use the <b>Ignore 'equals()', 'hashCode()' and 'toString()'</b> option to ignore these
|
|
<code>java.lang.Object</code> methods: <code>equals()</code>, <code>hashCode()</code>, and
|
|
<code>toString()</code>. The risk that these methods will disappear and
|
|
your code won't be compiling anymore due to the <code>@Override</code>
|
|
annotation is relatively small.
|
|
</li>
|
|
<li>
|
|
Use the <b>Ignore methods in anonymous classes</b> option to ignore methods
|
|
in anonymous classes.
|
|
</li>
|
|
<li>
|
|
Disable the <b>Highlight method when its overriding methods do not all have the '@Override' annotation</b> option to only
|
|
warn on the methods missing an <code>@Override</code> annotation, and not on overridden methods where one or more descendants are
|
|
missing an <code>@Override</code> annotation.
|
|
</li>
|
|
</ul>
|
|
</body>
|
|
</html>
|