本文整理匯總了Java中com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.getAnnotations方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassOrInterfaceDeclaration.getAnnotations方法的具體用法?Java ClassOrInterfaceDeclaration.getAnnotations怎麽用?Java ClassOrInterfaceDeclaration.getAnnotations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
的用法示例。
在下文中一共展示了ClassOrInterfaceDeclaration.getAnnotations方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculate
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
public void calculate(ClassOrInterfaceDeclaration classOrInterfaceDeclaration, CompilationUnit compilationUnit) {
List<AnnotationExpr> annotations = classOrInterfaceDeclaration.getAnnotations();
for (AnnotationExpr annotation : annotations) {
String annotationName = annotation.getNameAsString();
String annotationPackageName = annotation
.findCompilationUnit()
.flatMap(CompilationUnit::getPackageDeclaration)
.flatMap(pkg -> Optional.of(pkg.getNameAsString())).orElse("???");
if (typeDao.exist(annotationName, annotationPackageName)) { // JDK annotations are not indexed
int annotationId = typeDao.getId(annotationName, annotationPackageName);
int typeId = typeDao.getId(classOrInterfaceDeclaration.getNameAsString(), compilationUnit.getPackageDeclaration().get().getNameAsString());
annotatedWithDao.save(new AnnotatedWith(typeId, annotationId));
}
}
}
示例2: visit
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override
public void visit(ClassOrInterfaceDeclaration typeDeclaration, EligibilityResult result) {
if (!foundTopClass && (typeDeclaration.getModifiers() & ModifierSet.PUBLIC) != 0x00) {
List<AnnotationExpr> annotations = typeDeclaration.getAnnotations();
boolean classHasControllerAnnotation = annotations.stream().filter(annotation -> annotation.getName().getName().equals("Controller")).findAny().isPresent();
if (!classHasControllerAnnotation) {
result.setEligible(false);
return;
} else {
foundTopClass = true;
classToRemoveAnnotationFrom = typeDeclaration;
}
}
super.visit(typeDeclaration, result);
}
示例3: visit
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override public Node visit(final ClassOrInterfaceDeclaration n, final A arg) {
if (n.getJavaDoc() != null) {
n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg));
}
final List<AnnotationExpr> annotations = n.getAnnotations();
if (annotations != null) {
for (int i = 0; i < annotations.size(); i++) {
annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
}
removeNulls(annotations);
}
final List<TypeParameter> typeParameters = n.getTypeParameters();
if (typeParameters != null) {
for (int i = 0; i < typeParameters.size(); i++) {
typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg));
}
removeNulls(typeParameters);
}
final List<ClassOrInterfaceType> extendz = n.getExtends();
if (extendz != null) {
for (int i = 0; i < extendz.size(); i++) {
extendz.set(i, (ClassOrInterfaceType) extendz.get(i).accept(this, arg));
}
removeNulls(extendz);
}
final List<ClassOrInterfaceType> implementz = n.getImplements();
if (implementz != null) {
for (int i = 0; i < implementz.size(); i++) {
implementz.set(i, (ClassOrInterfaceType) implementz.get(i).accept(this, arg));
}
removeNulls(implementz);
}
final List<BodyDeclaration> members = n.getMembers();
if (members != null) {
for (int i = 0; i < members.size(); i++) {
members.set(i, (BodyDeclaration) members.get(i).accept(this, arg));
}
removeNulls(members);
}
return n;
}