This question already has an answer here:
I have an interface
public interface LdapConnectionFactory {
LdapConnectionWrapper getConnectionWrapper() throws LDAPException;
}
and the implementation class LdapConnectionFactoryImpl
which implements the getConnectionWrapper()
method.
public class LdapConnectionFactoryImpl implements LdapConnectionFactory {
...
public LdapConnectionWrapper getConnectionWrapper() throws LDAPException {
...
}
}
When I ran checkstyle, it flags the getConnectionWrapper()
as error - Method 'getConnectionWrapper' is not designed for extension - needs to be abstract, final or empty.
Any advice? Thanks.
Checkstyle is throwing this message because you have provided an implementation but have not marked the method as final. You can disable this check via Eclipse Preferences and editing your Checkstyle configuration. The specific rule is Class Design > Design for Extension.
The description for the check is pretty decent, and is as follows:
Checkstyle
is saying that either the class or method should be marked asfinal
since it is non-empty and therefore not designed for being overridden.This is one of the rules of
Checkstyle
that I don't personally agree with and tend to disable.