当前位置: 首页>>代码示例>>Java>>正文


Java FieldDeclaration.getAnnotations方法代码示例

本文整理汇总了Java中japa.parser.ast.body.FieldDeclaration.getAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java FieldDeclaration.getAnnotations方法的具体用法?Java FieldDeclaration.getAnnotations怎么用?Java FieldDeclaration.getAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在japa.parser.ast.body.FieldDeclaration的用法示例。


在下文中一共展示了FieldDeclaration.getAnnotations方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deconstructMultiDeclarations

import japa.parser.ast.body.FieldDeclaration; //导入方法依赖的package包/类
/**
 * In Java variables can be defined like the following:
 * int i, j, k;
 *
 * When mapping fields in xml this is not a problem.  However when using annotation on a field,
 * Each field should be defined separately.  This helper will deconstruct these fields such
 * that later AST analysis will not need to account for field defined on a separate line.
 */
public static void deconstructMultiDeclarations(Collection<FieldDeclaration> fields) {

    for (FieldDeclaration field : fields) {

        ClassOrInterfaceDeclaration parent = (ClassOrInterfaceDeclaration) field.getParentNode();

        //these are chained together
        if (field.getVariables().size() > 1) {
            int index = parent.getMembers().indexOf(field);
            parent.getMembers().remove(index);
            List<FieldDeclaration> deconstructed = new ArrayList<FieldDeclaration>();
            for (VariableDeclarator v : field.getVariables()) {
                FieldDeclaration f = new FieldDeclaration(field.getModifiers(), field.getAnnotations(), field.getType(), Collections.singletonList(v));
                f.setJavaDoc(field.getJavaDoc());
                f.setComment(field.getComment());
                f.setParentNode(field.getParentNode());
                deconstructed.add(f);
            }
            parent.getMembers().addAll(index, deconstructed);
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:31,代码来源:ParserUtil.java

示例2: deconstructMultiDeclarations

import japa.parser.ast.body.FieldDeclaration; //导入方法依赖的package包/类
/**
 * In Java variables can be defined like the following:
 * int i, j, k;
 *
 * When mapping fields in xml this is not a problem.  However when using annotation on a field,
 * Each field should be defined separately.  This helper will deconstruct these fields such
 * that later AST analysis will not need to account for field defined on a separate line.
 */
public static void deconstructMultiDeclarations(Collection<FieldDeclaration> fields) {

    for (FieldDeclaration field : fields) {

        ClassOrInterfaceDeclaration parent = (ClassOrInterfaceDeclaration) field.getParentNode();

        //these are chained together
        if (field.getVariables().size() > 1) {
            int index = parent.getMembers().indexOf(field);
            parent.getMembers().remove(index);
            List<FieldDeclaration> deconstructed = new ArrayList<FieldDeclaration>();
            for (VariableDeclarator v : field.getVariables()) {
                FieldDeclaration f = new FieldDeclaration(field.getJavaDoc(), field.getModifiers(), field.getAnnotations(), field.getType(), Collections.singletonList(v));
                f.setComment(field.getComment());
                f.setParentNode(field.getParentNode());
                deconstructed.add(f);
            }
            parent.getMembers().addAll(index, deconstructed);
        }
    }
}
 
开发者ID:kuali,项目名称:rice,代码行数:30,代码来源:ParserUtil.java

示例3: visit

import japa.parser.ast.body.FieldDeclaration; //导入方法依赖的package包/类
public Node visit(FieldDeclaration n, A arg) {
    if (n.getJavaDoc() != null) {
        n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg));
    }
    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);
    }
    n.setType((Type) n.getType().accept(this, arg));
    List<VariableDeclarator> variables = n.getVariables();
    for (int i = 0; i < variables.size(); i++) {
        variables.set(i, (VariableDeclarator) variables.get(i).accept(this, arg));
    }
    removeNulls(variables);
    return n;
}
 
开发者ID:rfw,项目名称:genja,代码行数:20,代码来源:ModifierVisitorAdapter.java

示例4: isClaraField

import japa.parser.ast.body.FieldDeclaration; //导入方法依赖的package包/类
private static boolean isClaraField(FieldDeclaration field, String id,
		String className) {
	if (field.getAnnotations()==null) {
		return false;
	}
	for (AnnotationExpr ann : field.getAnnotations()) {
		if ("UiField".equals(ann.getName().getName())) {
			if (ann instanceof SingleMemberAnnotationExpr) {
				SingleMemberAnnotationExpr smae = (SingleMemberAnnotationExpr)ann;
				if (smae.getMemberValue() instanceof StringLiteralExpr) {
					String v = ((StringLiteralExpr)smae.getMemberValue()).getValue();
					if (id.equals(v)) {
						return true;
					}
				}
			}
		}
	}
	return false;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:21,代码来源:ControllerCode.java

示例5: visit

import japa.parser.ast.body.FieldDeclaration; //导入方法依赖的package包/类
public R visit(FieldDeclaration n, A arg) {
    if (n.getJavaDoc() != null) {
        n.getJavaDoc().accept(this, arg);
    }
    if (n.getAnnotations() != null) {
        for (AnnotationExpr a : n.getAnnotations()) {
            a.accept(this, arg);
        }
    }
    n.getType().accept(this, arg);
    for (VariableDeclarator var : n.getVariables()) {
        var.accept(this, arg);
    }
    return null;
}
 
开发者ID:rfw,项目名称:genja,代码行数:16,代码来源:GenericVisitorAdapter.java

示例6: visit

import japa.parser.ast.body.FieldDeclaration; //导入方法依赖的package包/类
public void visit(FieldDeclaration n, A arg) {
    if (n.getJavaDoc() != null) {
        n.getJavaDoc().accept(this, arg);
    }
    if (n.getAnnotations() != null) {
        for (AnnotationExpr a : n.getAnnotations()) {
            a.accept(this, arg);
        }
    }
    n.getType().accept(this, arg);
    for (VariableDeclarator var : n.getVariables()) {
        var.accept(this, arg);
    }
}
 
开发者ID:rfw,项目名称:genja,代码行数:15,代码来源:VoidVisitorAdapter.java


注:本文中的japa.parser.ast.body.FieldDeclaration.getAnnotations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。