public class DesignForExtensionCheck extends AbstractCheck
Nothing wrong could be with founded classes this Check make sence only for library project (not a application projects) who care about ideal OOP design to make sure clas work in all cases even misusage. Even in library projects this Check most likely find classes that are not required to check. User need to use suppressions extensively to got a benefit from this Check and avoid false positives.
ATTENTION: Only user can deside whether class is designed for extension or not. Check just show all possible. If smth inappropriate is found please use supporession.
More specifically, it enforces a programming style where superclasses provide empty "hooks" that can be implemented by subclasses.
The exact rule is that non-private, non-static methods in non-final classes (or classes that do not only have private constructors) must either be
This protects superclasses against being broken by subclasses. The downside is that subclasses are limited in their flexibility, in particular they cannot prevent execution of code in the superclass, but that also means that subclasses can't forget to call their super method.
Modifier and Type | Field and Description |
---|---|
static String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
Constructor and Description |
---|
DesignForExtensionCheck() |
Modifier and Type | Method and Description |
---|---|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
beginTree, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public static final String MSG_KEY
public DesignForExtensionCheck()
public int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public void visitToken(DetailAST ast)
AbstractCheck
visitToken
in class AbstractCheck
ast
- the token to processCopyright © 2001–2016. All rights reserved.