本文整理汇总了Java中org.codehaus.groovy.ast.ClassNode.getMethods方法的典型用法代码示例。如果您正苦于以下问题:Java ClassNode.getMethods方法的具体用法?Java ClassNode.getMethods怎么用?Java ClassNode.getMethods使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.ClassNode
的用法示例。
在下文中一共展示了ClassNode.getMethods方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import org.codehaus.groovy.ast.ClassNode; //导入方法依赖的package包/类
@Override
public void call(SourceUnit source) throws CompilationFailedException {
ClassNode scriptClass = AstUtils.getScriptClass(source);
if (scriptClass == null) {
return;
}
for (MethodNode methodNode : scriptClass.getMethods()) {
if (methodNode.getName().equals("main")) {
AstUtils.removeMethod(scriptClass, methodNode);
break;
}
}
}
示例2: hasAtLeastOneAnnotation
import org.codehaus.groovy.ast.ClassNode; //导入方法依赖的package包/类
/**
* Determine if a {@link ClassNode} has one or more of the specified annotations on
* the class or any of its methods. N.B. the type names are not normally fully
* qualified.
* @param node the class to examine
* @param annotations the annotations to look for
* @return {@code true} if at least one of the annotations is found, otherwise
* {@code false}
*/
public static boolean hasAtLeastOneAnnotation(ClassNode node, String... annotations) {
if (hasAtLeastOneAnnotation((AnnotatedNode) node, annotations)) {
return true;
}
for (MethodNode method : node.getMethods()) {
if (hasAtLeastOneAnnotation(method, annotations)) {
return true;
}
}
return false;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:AstUtils.java
示例3: hasAtLeastOneFieldOrMethod
import org.codehaus.groovy.ast.ClassNode; //导入方法依赖的package包/类
/**
* Determine if a {@link ClassNode} has one or more fields of the specified types or
* method returning one or more of the specified types. N.B. the type names are not
* normally fully qualified.
* @param node the class to examine
* @param types the types to look for
* @return {@code true} if at least one of the types is found, otherwise {@code false}
*/
public static boolean hasAtLeastOneFieldOrMethod(ClassNode node, String... types) {
Set<String> typesSet = new HashSet<String>(Arrays.asList(types));
for (FieldNode field : node.getFields()) {
if (typesSet.contains(field.getType().getName())) {
return true;
}
}
for (MethodNode method : node.getMethods()) {
if (typesSet.contains(method.getReturnType().getName())) {
return true;
}
}
return false;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:AstUtils.java