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


Java AnnotationExpr类代码示例

本文整理汇总了Java中japa.parser.ast.expr.AnnotationExpr的典型用法代码示例。如果您正苦于以下问题:Java AnnotationExpr类的具体用法?Java AnnotationExpr怎么用?Java AnnotationExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: visit

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的package包/类
@Override
public void visit(MethodDeclaration method, A result) {
    if (CollectionUtils.isEmpty(method.getAnnotations())) {
        return;
    }
    for (AnnotationExpr annotation : method.getAnnotations()) {
        if (!annotation.getClass().equals(NormalAnnotationExpr.class)) {
            continue;
        }
        NormalAnnotationExpr annot = (NormalAnnotationExpr) annotation;
        if (annot.getName().toString().equals(SampleCode.class.getSimpleName())
                && !CollectionUtils.isEmpty(annot.getPairs())) {
            for (MemberValuePair pair : annot.getPairs()) {
                // get the 'api' parameter from the annotation to let us know which api this function belongs to
                if (StringUtils.equals(pair.getName(), "api") && !StringUtils.isBlank(pair.getValue().toString())) {
                    result.put(getCacheRowKey(type, pair.getValue().toString().replace("\"", "")), stripTestPrefix(method.getName()),
                            stripCurlyBrackets(method.getBody().toString()));
                    return;
                }
            }
        }
    }
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:24,代码来源:SampleCodeParser.java

示例2: getAnnotationNodes

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
    final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);

    if (fd != null) {
        final Class<?> fc = ResolverUtil.getType(enclosingClass, fieldName);

        if (isEnum(fc)) {
            final Comment fixme = new BlockComment("\nFIXME:\n" +
                    "Enums must be annotated with the @Enumerated annotation.\n " +
                    "The @Enumerated annotation should set the EnumType.\n" +
                    "If the EnumType is not set, then the Enumerated annotation is defaulted to EnumType.ORDINAL.\n" +
                    "This conversion program cannot tell whether EnumType.ORDINAL is the appropriate EnumType.");
            AnnotationExpr enumerated = new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("value", new NameExpr("EnumType."))));
            enumerated.setComment(fixme);
            return new NodeData(enumerated, new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
                Collections.singletonList(new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), "TemporalType"), false, false)));
        }
    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:EnumeratedResolver.java

示例3: createJoinColumn

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的package包/类
private AnnotationExpr createJoinColumn(FieldDescriptor thisField, FieldDescriptor itemField) {
        final List<MemberValuePair> pairs = new ArrayList<MemberValuePair>();

        pairs.add(new MemberValuePair("name", new StringLiteralExpr(thisField.getColumnName())));
        pairs.add(new MemberValuePair("referencedColumnName", new StringLiteralExpr(itemField.getColumnName())));
        if (!isAnonymousFk(thisField)) {
            pairs.add(new MemberValuePair("insertable", new BooleanLiteralExpr(false)));
            pairs.add(new MemberValuePair("updatable", new BooleanLiteralExpr(false)));
        }

        // Per this page: https://forums.oracle.com/message/3923913
        // the nullable attribute is a hint to the DDL generation, especially on fields like this.
        // Commenting this flag out for now as it's just "noise" in the annotation definitions
//        if (!isNullableFk(thisField)) {
//            pairs.add(new MemberValuePair("nullable", new BooleanLiteralExpr(false)));
//        }
        return new NormalAnnotationExpr(new NameExpr("JoinColumn"), pairs);
    }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:AbstractJoinColumnResolver.java

示例4: getAnnotationNodes

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
    final List<Expression> joinColumns = getJoinColumns(enclosingClass, fieldName, mappedClass);
    if (joinColumns != null && joinColumns.size() > 1) {
        final Comment fixme = new BlockComment("\nFIXME: JPA_CONVERSION\n"
                + "For compound primary keys, make sure the join columns are in the correct order.\n");
        AnnotationExpr
                annotation = new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new ArrayInitializerExpr(joinColumns));
        annotation.setComment(fixme);
        return new NodeData(annotation,
                new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
                Arrays.asList(
                          new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PrimaryKeyJoinColumnResolver.PACKAGE),PrimaryKeyJoinColumnResolver.SIMPLE_NAME), false, false)
                        , new ImportDeclaration(new QualifiedNameExpr(new NameExpr(JoinColumnResolver.PACKAGE),JoinColumnResolver.SIMPLE_NAME), false, false)
                        ));
    }

    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:20,代码来源:JoinColumnsResolver.java

示例5: findAnnotation

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的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;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:AnnotationHelper.java

示例6: getTotalLineRegion

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的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;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:17,代码来源:BuilderGenerator.java

示例7: visit

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的package包/类
public R visit(AnnotationDeclaration 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);
        }
    }
    if (n.getMembers() != null) {
        for (BodyDeclaration member : n.getMembers()) {
            member.accept(this, arg);
        }
    }
    return null;
}
 
开发者ID:rfw,项目名称:genja,代码行数:17,代码来源:GenericVisitorAdapter.java

示例8: visit

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的package包/类
public void visit(ConstructorDeclaration 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);
        }
    }
    if (n.getTypeParameters() != null) {
        for (TypeParameter t : n.getTypeParameters()) {
            t.accept(this, arg);
        }
    }
    if (n.getParameters() != null) {
        for (Parameter p : n.getParameters()) {
            p.accept(this, arg);
        }
    }
    if (n.getThrows() != null) {
        for (NameExpr name : n.getThrows()) {
            name.accept(this, arg);
        }
    }
    n.getBlock().accept(this, arg);
}
 
开发者ID:rfw,项目名称:genja,代码行数:27,代码来源:VoidVisitorAdapter.java

示例9: visit

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的package包/类
public Node visit(AnnotationDeclaration 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);
    }
    List<BodyDeclaration> members = n.getMembers();
    if (members != null) {
        for (int i = 0; i < members.size(); i++) {
            members.set(i, (BodyDeclaration) members.get(i).accept(this, arg));
        }
        removeNulls(members);
    }
    return n;
}
 
开发者ID:rfw,项目名称:genja,代码行数:21,代码来源:ModifierVisitorAdapter.java

示例10: addAttachSkeleton

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的package包/类
private void addAttachSkeleton() {
	List<Parameter> params = Collections.emptyList();
	MethodDeclaration method = new MethodDeclaration(
			ModifierSet.PUBLIC, new VoidType(), "attach", params);
	AnnotationExpr override = new MarkerAnnotationExpr(new NameExpr("Override"));
	method.setAnnotations(Collections.singletonList(override));
	
	BlockStmt block = new BlockStmt();
	Expression e = new MethodCallExpr(new SuperExpr(), "attach");
	List<Statement> sts = Collections.singletonList((Statement)new ExpressionStmt(e));
	block.setStmts(sts);
	method.setBody(block);
	
	if (getType().getMembers()==null) {
		getType().setMembers(new LinkedList<BodyDeclaration>());
	}
	getType().getMembers().add(method);
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:19,代码来源:ControllerCode.java

示例11: addOnBecomingVisibleMethod

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的package包/类
@SuppressWarnings("unused")
private void addOnBecomingVisibleMethod() {
	List<Parameter> params = Collections.emptyList();
	MethodDeclaration method = new MethodDeclaration(
			ModifierSet.PUBLIC, new VoidType(), "onBecomingVisible", params);
	AnnotationExpr override = new MarkerAnnotationExpr(new NameExpr("Override"));
	method.setAnnotations(Collections.singletonList(override));
	
	BlockStmt block = new BlockStmt();
	Expression e = new MethodCallExpr(new SuperExpr(), "onBecomingVisible");
	List<Statement> sts = Collections.singletonList((Statement)new ExpressionStmt(e));
	block.setStmts(sts);
	method.setBody(block);
	
	if (getType().getMembers()==null) {
		getType().setMembers(new LinkedList<BodyDeclaration>());
	}
	getType().getMembers().add(method);
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:20,代码来源:ControllerCode.java

示例12: isClaraHandler

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的package包/类
private static boolean isClaraHandler(MethodDeclaration method, String id,
		String className) {
	if (method.getAnnotations()==null) {
		return false;
	}
	for (AnnotationExpr ann : method.getAnnotations()) {
		if ("UiHandler".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 hasOneParamWithType(method, className);
					}
				}
			}
		}
	}
	return false;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:21,代码来源:ControllerCode.java

示例13: isClaraField

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的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

示例14: addAnnotationTo

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的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);
    }
}
 
开发者ID:mirkosertic,项目名称:ERDesignerNG,代码行数:10,代码来源:OpenXavaASTHelper.java

示例15: getAnnotationNodes

import japa.parser.ast.expr.AnnotationExpr; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
    final List<Expression> joinColumns = getJoinColumns(enclosingClass, fieldName, mappedClass);
    if (joinColumns != null && joinColumns.size() == 1) {
        return new NodeData((AnnotationExpr) joinColumns.get(0),
                new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
    }

    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:11,代码来源:JoinColumnResolver.java


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