本文整理汇总了Java中japa.parser.ast.body.BodyDeclaration.getAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java BodyDeclaration.getAnnotations方法的具体用法?Java BodyDeclaration.getAnnotations怎么用?Java BodyDeclaration.getAnnotations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类japa.parser.ast.body.BodyDeclaration
的用法示例。
在下文中一共展示了BodyDeclaration.getAnnotations方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findAnnotation
import japa.parser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
private AnnotationExpr findAnnotation(final BodyDeclaration n, String fullyQualifiedName, boolean foundAnnImport) {
final String simpleName = ClassUtils.getShortClassName(fullyQualifiedName);
final List<AnnotationExpr> annotations = n.getAnnotations() != null ? n.getAnnotations() : new ArrayList<AnnotationExpr>();
for (AnnotationExpr ae : annotations) {
final String name = ae.getName().toString();
if ((simpleName.equals(name) && foundAnnImport)) {
LOG.info("found " + ae + " on " + getTypeOrFieldNameForMsg(n) + ".");
return ae;
}
if (fullyQualifiedName.equals(name)) {
LOG.info("found " + ae + " on " + getTypeOrFieldNameForMsg(n) + ".");
return ae;
}
}
return null;
}
示例2: getTotalLineRegion
import japa.parser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
private static LineRegion getTotalLineRegion( BodyDeclaration decl )
{
LineRegion region = getLineRegion( decl );
if( decl.getJavaDoc( ) != null )
{
region = region.union( getLineRegion( decl.getJavaDoc( ) ) );
}
if( decl.getAnnotations( ) != null )
{
for( AnnotationExpr annotation : decl.getAnnotations( ) )
{
region = region.union( getLineRegion( annotation ) );
}
}
return region;
}
示例3: addAnnotationTo
import japa.parser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
public static void addAnnotationTo(BodyDeclaration aDeclaration, AnnotationExpr aAnnotation) {
if (aDeclaration.getAnnotations() != null) {
aDeclaration.getAnnotations().add(aAnnotation);
} else {
List<AnnotationExpr> theExpressions = new ArrayList<>();
theExpressions.add(aAnnotation);
aDeclaration.setAnnotations(theExpressions);
}
}
示例4: getAnnotation
import japa.parser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
public static AnnotationExpr getAnnotation(BodyDeclaration decl, Class<?> annotationClass) {
for (AnnotationExpr annotation : decl.getAnnotations()) {
if (annotation.getName().equals(annotationClass.getSimpleName()) ||
annotation.getName().equals(annotationClass.getName())) {
return annotation;
}
}
return null;
}
示例5: fullRegion
import japa.parser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
public static LineRegion fullRegion(Node node) {
LineRegion result = region(node);
if (node instanceof BodyDeclaration) {
BodyDeclaration bodyDecl = (BodyDeclaration) node;
if (bodyDecl.getAnnotations() != null) {
for (AnnotationExpr annotation : bodyDecl.getAnnotations()) {
result = result.union(region(annotation));
}
}
if (bodyDecl.getJavaDoc() != null) {
result = result.union(region(bodyDecl.getJavaDoc()));
}
}
return result;
}
示例6: containsAnnotation
import japa.parser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
private boolean containsAnnotation(BodyDeclaration methodDeclaration, String annotation) {
if (methodDeclaration.getAnnotations() != null) {
for (AnnotationExpr annotationExpr : methodDeclaration.getAnnotations()) {
if (annotation.equals(annotationExpr.getName().toString())) {
return true;
}
}
}
return false;
}
示例7: hasAnnotation
import japa.parser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
private static boolean hasAnnotation(BodyDeclaration decl, String anno) {
if (decl.getAnnotations() == null) {
return false;
}
for (AnnotationExpr ae : decl.getAnnotations()) {
if (anno.equals(ae.getName().toString())) {
return true;
}
}
return false;
}
示例8: processAnnotations
import japa.parser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
private void processAnnotations(BodyDeclaration decl) {
if (decl.getAnnotations() != null)
for (AnnotationExpr expr : decl.getAnnotations())
attributes.add(expr.getName().toString());
}