當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassOrInterfaceDeclaration.getAnnotations方法代碼示例

本文整理匯總了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));
        }
    }
}
 
開發者ID:benas,項目名稱:jql,代碼行數:17,代碼來源:AnnotatedWithCalculator.java

示例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);
}
 
開發者ID:KPull,項目名稱:java-source-transformations,代碼行數:16,代碼來源:RestControllerAnnotationReplacement.java

示例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;
}
 
開發者ID:plum-umd,項目名稱:java-sketch,代碼行數:42,代碼來源:ModifierVisitorAdapter.java


注:本文中的com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.getAnnotations方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。