本文整理汇总了Java中com.github.javaparser.ast.body.BodyDeclaration.getAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java BodyDeclaration.getAnnotations方法的具体用法?Java BodyDeclaration.getAnnotations怎么用?Java BodyDeclaration.getAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.body.BodyDeclaration
的用法示例。
在下文中一共展示了BodyDeclaration.getAnnotations方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createOrFindAnnotation
import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
protected NormalAnnotationExpr createOrFindAnnotation(BodyDeclaration<?> getter, String fullAnnotationName) {
String name = AbstractGenerator.finalName(fullAnnotationName);
//importIf(fullAnnotationName);
for(AnnotationExpr annotationExpr : getter.getAnnotations()) {
String annName = annotationExpr.getName().asString();
if(annName.equals(fullAnnotationName) || name.equals(annName)) {
return (NormalAnnotationExpr) annotationExpr;
}
}
importIf(fullAnnotationName);
String pkg = AbstractGenerator.packageName(fullAnnotationName);
NodeList<MemberValuePair> nodes = NodeList.nodeList();
//Name nm = new Name(new Name(pkg), name);
NormalAnnotationExpr ax = new NormalAnnotationExpr(new Name(name), nodes);
getter.addAnnotation(ax);
return ax;
}
示例2: createOrFindMarkerAnnotation
import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
protected MarkerAnnotationExpr createOrFindMarkerAnnotation(BodyDeclaration<?> getter, String fullAnnotationName) {
String name = AbstractGenerator.finalName(fullAnnotationName);
importIf(fullAnnotationName);
//getUnit().addImport(fullAnnotationName);
for(AnnotationExpr annotationExpr : getter.getAnnotations()) {
String annName = annotationExpr.getName().asString();
if(annName.equals(fullAnnotationName) || name.equals(annName)) {
return (MarkerAnnotationExpr) annotationExpr;
}
}
String pkg = AbstractGenerator.packageName(fullAnnotationName);
NodeList<MemberValuePair> nodes = NodeList.nodeList();
//Name nm = new Name(new Name(pkg), name);
MarkerAnnotationExpr ax = new MarkerAnnotationExpr(new Name(name));
getter.addAnnotation(ax);
return ax;
}
示例3: findAnnotation
import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
@Nullable
protected NormalAnnotationExpr findAnnotation(BodyDeclaration<?> method, String fullAnnotationName) {
String name = AbstractGenerator.finalName(fullAnnotationName);
//importIf(fullAnnotationName);
for(AnnotationExpr annotationExpr : method.getAnnotations()) {
String annName = annotationExpr.getName().asString();
if(annName.equals(fullAnnotationName) || name.equals(annName)) {
return (NormalAnnotationExpr) annotationExpr;
}
}
return null;
}