本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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");
}