public final class IllegalTypeCheck extends AbstractCheck
Rationale: Helps reduce coupling on concrete classes.
Check has following properties:
format - Pattern for illegal class names.
legalAbstractClassNames - Abstract classes that may be used as types.
illegalClassNames - Classes that should not be used as types in variable declarations, return values or parameters. It is possible to set illegal class names via short or canonical name. Specifying illegal type invokes analyzing imports and Check puts violations at corresponding declarations (of variables, methods or parameters). This helps to avoid ambiguous cases, e.g.:
java.awt.List was set as illegal class name, then, code like:
import java.util.List;<br>
...<br>
List list; //No violation here
will be ok.
validateAbstractClassNames - controls whether to validate abstract class names. Default value is false
ignoredMethodNames - Methods that should not be checked.
memberModifiers - To check only methods and fields with only specified modifiers.
In most cases it's justified to put following classes to illegalClassNames:
as methods that are differ from interface methods are rear used, so in most cases user will benefit from checking for them.
AutomaticBean.OutputStreamOptions| 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 |
|---|
IllegalTypeCheck()
Creates new instance of the check.
|
| Modifier and Type | Method and Description |
|---|---|
void |
beginTree(DetailAST rootAST)
Called before the starting to process a tree.
|
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 |
setFormat(Pattern pattern)
Set the format for the specified regular expression.
|
void |
setIgnoredMethodNames(String... methodNames)
Set the list of ignore method names.
|
void |
setIllegalClassNames(String... classNames)
Set the list of illegal variable types.
|
void |
setLegalAbstractClassNames(String... classNames)
Set the list of legal abstract class names.
|
void |
setMemberModifiers(String modifiers)
Set the list of member modifiers (of methods and fields) which should be checked.
|
void |
setValidateAbstractClassNames(boolean validateAbstractClassNames)
Sets whether to validate abstract class names.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
clearMessages, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setClassLoader, setFileContents, setTabWidth, setTokensgetCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, finishLocalSetup, getConfiguration, setupChildpublic static final String MSG_KEY
public IllegalTypeCheck()
public void setFormat(Pattern pattern)
pattern - a pattern.public void setValidateAbstractClassNames(boolean validateAbstractClassNames)
validateAbstractClassNames - whether abstract class names must be ignored.public int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic void beginTree(DetailAST rootAST)
AbstractCheckbeginTree in class AbstractCheckrootAST - the root of the treepublic int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypespublic void visitToken(DetailAST ast)
AbstractCheckvisitToken in class AbstractCheckast - the token to processpublic void setIllegalClassNames(String... classNames)
classNames - array of illegal variable typespublic void setIgnoredMethodNames(String... methodNames)
methodNames - array of ignored method namespublic void setLegalAbstractClassNames(String... classNames)
classNames - array of legal abstract class namespublic void setMemberModifiers(String modifiers)
modifiers - String contains modifiers.Copyright © 2001-2017. All Rights Reserved.