rspec/rules/S4968/java/rule.adoc

29 lines
741 B
Plaintext

When a generic class is declaring wildcard with an upper bound that is ``++final++``, this generic class is not generic at all because it only accepts one and only one type at runtime: the one that is ``++final++``. Instead of using ``++Generics++``, it's simpler to directly use the concrete ``++final++`` class.
== Noncompliant Code Example
----
public static <T extends String> T getMyString() { // Noncompliant; String is a "final" class and so can't be extended
[...]
}
----
== Compliant Solution
----
public static String getMyString() { // Compliant
[...]
}
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]