public final class IllegalThrowsCheck extends AbstractCheck
Throwing java.lang.Error or java.lang.RuntimeException is almost never acceptable.
Check has following properties:illegalClassNames - throw class names to reject.
ignoredMethodNames - names of methods to ignore.
ignoreOverriddenMethods - ignore checking overridden methods (marked with Override or java.lang.Override annotation) default value is true.
Modifier and Type | Field and Description |
---|---|
private java.util.Set<java.lang.String> |
ignoredMethodNames
Methods which should be ignored.
|
private boolean |
ignoreOverriddenMethods
Property for ignoring overridden methods.
|
private java.util.Set<java.lang.String> |
illegalClassNames
Illegal class names.
|
static java.lang.String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
Constructor and Description |
---|
IllegalThrowsCheck() |
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.
|
private boolean |
isIgnorableMethod(DetailAST methodDef)
Checks if current method is ignorable due to Check's properties.
|
void |
setIgnoredMethodNames(java.lang.String... methodNames)
Set the list of ignore method names.
|
void |
setIgnoreOverriddenMethods(boolean ignoreOverriddenMethods)
Sets ignoreOverriddenMethods property value.
|
void |
setIllegalClassNames(java.lang.String... classNames)
Set the list of illegal classes.
|
private boolean |
shouldIgnoreMethod(java.lang.String name)
Check if the method is specified in the ignore method list.
|
void |
visitToken(DetailAST detailAST)
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 java.lang.String MSG_KEY
private final java.util.Set<java.lang.String> ignoredMethodNames
private final java.util.Set<java.lang.String> illegalClassNames
private boolean ignoreOverriddenMethods
public void setIllegalClassNames(java.lang.String... classNames)
classNames
- array of illegal exception classespublic int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public void visitToken(DetailAST detailAST)
AbstractCheck
visitToken
in class AbstractCheck
detailAST
- the token to processprivate boolean isIgnorableMethod(DetailAST methodDef)
methodDef
- METHOD_DEF
private boolean shouldIgnoreMethod(java.lang.String name)
name
- the name to checkpublic void setIgnoredMethodNames(java.lang.String... methodNames)
methodNames
- array of ignored method namespublic void setIgnoreOverriddenMethods(boolean ignoreOverriddenMethods)
ignoreOverriddenMethods
- Check's property.