rspec/rules/S2974/java/rule.adoc

52 lines
831 B
Plaintext

== Why is this an issue?
Classes with only ``++private++`` constructors should be marked ``++final++`` to prevent any mistaken extension attempts.
=== Noncompliant code example
[source,java]
----
public class PrivateConstructorClass { // Noncompliant
private PrivateConstructorClass() {
// ...
}
public static int magic(){
return 42;
}
}
----
=== Compliant solution
[source,java]
----
public final class PrivateConstructorClass { // Compliant
private PrivateConstructorClass() {
// ...
}
public static int magic(){
return 42;
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]