public class ForbidWildcardAsReturnTypeCheck
extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
Joshua Bloch, "Effective Java (2nd edition)" Item 28: page 137 :
"Do not use wildcard types as return types. Rather than providing additional flexibility for your users, it would force them to use wildcard types in client code. Properly used, wildcard types are nearly invisible to users of a class. They cause methods to accept the parameters they should accept and reject those they should reject. If the user of a class has to think about wildcard types, there is probably something wrong with the classâs API."
| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_KEY
Key for error message.
|
| Constructor and Description |
|---|
ForbidWildcardAsReturnTypeCheck() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
getAcceptableTokens() |
int[] |
getDefaultTokens() |
int[] |
getRequiredTokens() |
void |
setAllowReturnWildcardWithExtends(boolean allowReturnWildcardWithExtends)
Setter for allowReturnWildcardWithExtends.
|
void |
setAllowReturnWildcardWithSuper(boolean allowReturnWildcardWithSuper)
Setter for allowReturnWildcardWithSuper.
|
void |
setCheckDeprecatedMethods(boolean checkDeprecatedMethods)
Setter for checkDeprecatedMethods.
|
void |
setCheckOverrideMethods(boolean checkOverrideMethods)
Setter for checkOverrideMethods.
|
void |
setCheckPackageMethods(boolean checkPackageMethods)
Setter for checkPackageMethods.
|
void |
setCheckPrivateMethods(boolean checkPrivateMethods)
Setter for checkPrivateMethods.
|
void |
setCheckProtectedMethods(boolean checkProtectedMethods)
Setter for checkProtectedMethods.
|
void |
setCheckPublicMethods(boolean checkPublicMethods)
Setter for checkPublicMethods.
|
void |
setReturnTypeClassNamesIgnoreRegex(String returnTypeClassNamesIgnoreRegex)
Setter for returnTypeClassNamesIgnoreRegex.
|
void |
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST methodDefAst) |
beginTree, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokensgetCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeveritypublic static final String MSG_KEY
public void setCheckPublicMethods(boolean checkPublicMethods)
checkPublicMethods - New value for the field.public void setCheckProtectedMethods(boolean checkProtectedMethods)
checkProtectedMethods - New value for the field.public void setCheckPackageMethods(boolean checkPackageMethods)
checkPackageMethods - New value for the field.public void setCheckPrivateMethods(boolean checkPrivateMethods)
checkPrivateMethods - New value for the field.public void setCheckOverrideMethods(boolean checkOverrideMethods)
checkOverrideMethods - New value for the field.public void setCheckDeprecatedMethods(boolean checkDeprecatedMethods)
checkDeprecatedMethods - New value for the field.public void setAllowReturnWildcardWithSuper(boolean allowReturnWildcardWithSuper)
allowReturnWildcardWithSuper - New value for the field.public void setAllowReturnWildcardWithExtends(boolean allowReturnWildcardWithExtends)
allowReturnWildcardWithExtends - New value for the field.public void setReturnTypeClassNamesIgnoreRegex(String returnTypeClassNamesIgnoreRegex)
returnTypeClassNamesIgnoreRegex - New value for the field.public int[] getDefaultTokens()
getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getAcceptableTokens()
getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getRequiredTokens()
getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST methodDefAst)
visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheckCopyright © 2017. All rights reserved.