本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.LITERAL_INT属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.LITERAL_INT属性的具体用法?Java TokenTypes.LITERAL_INT怎么用?Java TokenTypes.LITERAL_INT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.LITERAL_INT属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isHashCodeMethod
/**
* Determines if an AST is a valid HashCode method implementation.
*
* @param ast the AST to check
* @return true if the {code ast} is a HashCode method.
*/
private static boolean isHashCodeMethod(DetailAST ast) {
final DetailAST modifiers = ast.getFirstChild();
final AST type = ast.findFirstToken(TokenTypes.TYPE);
final AST methodName = ast.findFirstToken(TokenTypes.IDENT);
final DetailAST parameters = ast.findFirstToken(TokenTypes.PARAMETERS);
return type.getFirstChild().getType() == TokenTypes.LITERAL_INT
&& "hashCode".equals(methodName.getText())
&& modifiers.findFirstToken(TokenTypes.LITERAL_PUBLIC) != null
&& modifiers.findFirstToken(TokenTypes.LITERAL_STATIC) == null
&& parameters.getFirstChild() == null
&& (ast.findFirstToken(TokenTypes.SLIST) != null
|| modifiers.findFirstToken(TokenTypes.LITERAL_NATIVE) != null);
}
示例2: isNumericType
/**
* Determine if a given type is a numeric type.
* @param type code of the type for check.
* @return true if it's a numeric type.
* @see TokenTypes
*/
private static boolean isNumericType(int type) {
return type == TokenTypes.LITERAL_BYTE
|| type == TokenTypes.LITERAL_SHORT
|| type == TokenTypes.LITERAL_INT
|| type == TokenTypes.LITERAL_FLOAT
|| type == TokenTypes.LITERAL_LONG
|| type == TokenTypes.LITERAL_DOUBLE;
}
示例3: isHashCodeMethod
/**
* Determines if an AST is a valid HashCode method implementation.
*
* @param ast the AST to check
* @return true if the {code ast} is a HashCode method.
*/
public static Boolean isHashCodeMethod(DetailAST ast) {
DetailAST modifiers = ast.getFirstChild();
AST type = ast.findFirstToken(TokenTypes.TYPE);
AST methodName = ast.findFirstToken(TokenTypes.IDENT);
DetailAST parameters = ast.findFirstToken(TokenTypes.PARAMETERS);
return type.getFirstChild().getType() == TokenTypes.LITERAL_INT
&& HASH_CODE_METHOD_NAME.equals(methodName.getText())
&& modifiers.branchContains(TokenTypes.LITERAL_PUBLIC)
&& !modifiers.branchContains(TokenTypes.LITERAL_STATIC)
&& parameters.getFirstChild() == null
&& (ast.branchContains(TokenTypes.SLIST)
|| modifiers.branchContains(TokenTypes.LITERAL_NATIVE));
}