mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
32 lines
1.1 KiB
HTML
32 lines
1.1 KiB
HTML
<html>
|
|
<body>
|
|
Reports usages of concrete classes, rather than interfaces.
|
|
Such declarations may represent a failure of abstraction and may make testing more difficult.
|
|
<p>
|
|
Declarations whose classes come from system or third-party libraries will not be reported by this inspection.
|
|
Casts, instanceofs, and local variables are not reported in <code>equals()</code> method implementations.
|
|
Also, casts are not reported in <code>clone()</code> method implementations.
|
|
</p>
|
|
<p>Example:</p>
|
|
<pre><code>
|
|
interface Entity {}
|
|
class EntityImpl implements Entity {}
|
|
|
|
void processObject(Object obj) {
|
|
// warning: instanceof of the concrete class
|
|
if (obj instanceof EntityImpl) {
|
|
// warning: cast to the concrete class,
|
|
// rather than the interface
|
|
processEntity((EntityImpl)obj);
|
|
}
|
|
}
|
|
// warning: parameter of concrete class
|
|
void processEntity(EntityImpl obj) {
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>
|
|
Use the <b>Ignore abstract class type</b> option to ignore casts to abstract classes.</p>
|
|
<p>Use the subsequent options to control contexts where the problem is reported.</p>
|
|
</body>
|
|
</html> |