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