mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-29 18:17:08 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
48 lines
1.3 KiB
HTML
48 lines
1.3 KiB
HTML
<html>
|
|
<body>
|
|
Reports <code>abstract</code> classes that can be converted to interfaces.
|
|
<p>Using interfaces instead of classes is preferable as Java doesn't support multiple class inheritance,
|
|
while a class can implement multiple interfaces.</p>
|
|
<p>A class may be converted to an interface if it has no superclasses (other
|
|
than Object), has only <code>public static final</code> fields,
|
|
<code>public abstract</code> methods, and <code>public</code> inner classes.
|
|
<!-- tooltip end -->
|
|
|
|
<p>Example:</p>
|
|
<pre><code>
|
|
abstract class Example {
|
|
public static final int MY_CONST = 42;
|
|
public abstract void foo();
|
|
}
|
|
|
|
class Inheritor extends Example {
|
|
@Override
|
|
public void foo() {
|
|
System.out.println(MY_CONST);
|
|
}
|
|
}
|
|
</code></pre>
|
|
|
|
<p>After the quick-fix is applied:</p>
|
|
|
|
<pre><code>
|
|
interface Example {
|
|
int MY_CONST = 42;
|
|
void foo();
|
|
}
|
|
|
|
class Inheritor implements Example {
|
|
@Override
|
|
public void foo() {
|
|
System.out.println(MY_CONST);
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>Configure the inspection:</p>
|
|
<p>
|
|
Use the <b>Report classes containing non-abstract methods when using Java 8</b> option to report only the classes with <code>static</code> methods and non-abstract methods that can be converted to
|
|
<code>default</code> methods (only applicable to language level of 8 or higher).
|
|
<p>
|
|
|
|
</body>
|
|
</html> |