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


Java FieldDeclaration.getModifiers方法代码示例

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


在下文中一共展示了FieldDeclaration.getModifiers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 Boolean visit(FieldDeclaration n1, Node arg) {
    FieldDeclaration n2 = (FieldDeclaration) arg;

    // javadoc are checked at CompilationUnit

    if (n1.getModifiers() != n2.getModifiers()) {
        return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
        return Boolean.FALSE;
    }

    if (!nodeEquals(n1.getType(), n2.getType())) {
        return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getVariables(), n2.getVariables())) {
        return Boolean.FALSE;
    }

    return Boolean.TRUE;
}
 
开发者ID:rfw,项目名称:genja,代码行数:24,代码来源:EqualsVisitor.java

示例4: isRootField

import japa.parser.ast.body.FieldDeclaration; //导入方法依赖的package包/类
private static boolean isRootField(FieldDeclaration field) {
    if (field.getVariables().size() != 1
            || !"root"
                    .equals(field.getVariables().get(0).getId().getName())) {
        return false;
    }
    field.getModifiers();

    return ModifierSet.hasModifier(field.getModifiers(),
            ModifierSet.PRIVATE) && hasAnnotation(field, "AutoGenerated");
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:12,代码来源:JavaUtil.java


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