rspec/rules/S2974/java/rule.adoc
2021-04-28 18:08:03 +02:00

33 lines
523 B
Plaintext

Classes with only ``++private++`` constructors should be marked ``++final++`` to prevent any mistaken extension attempts.
== Noncompliant Code Example
----
public class PrivateConstructorClass { // Noncompliant
private PrivateConstructorClass() {
// ...
}
public static int magic(){
return 42;
}
}
----
== Compliant Solution
----
public final class PrivateConstructorClass { // Compliant
private PrivateConstructorClass() {
// ...
}
public static int magic(){
return 42;
}
}
----