com.github.javaparser.ast.expr.NormalAnnotationExpr Java Examples

The following examples show how to use com.github.javaparser.ast.expr.NormalAnnotationExpr. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrettyPrintVisitor.java    From stategen with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void visit(final NormalAnnotationExpr n, final Void arg) {
    printJavaComment(n.getComment(), arg);
    printer.print("@");
    n.getName().accept(this, arg);
    printer.print("(");
    if (n.getPairs() != null) {
        for (final Iterator<MemberValuePair> i = n.getPairs().iterator(); i.hasNext(); ) {
            final MemberValuePair m = i.next();
            m.accept(this, arg);
            if (i.hasNext()) {
                printer.print(", ");
            }
        }
    }
    printer.print(")");
}
 
Example #2
Source File: CDIDependencyInjectionAnnotator.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends NodeWithAnnotations<?>> T withConfigInjection(T node, String configKey) {
    node.addAnnotation(new NormalAnnotationExpr(
            new Name("org.eclipse.microprofile.config.inject.ConfigProperty"),
            NodeList.nodeList(
                    new MemberValuePair("name", new StringLiteralExpr(configKey))
            )
    ));
    return node;
}
 
Example #3
Source File: CDIDependencyInjectionAnnotator.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends NodeWithAnnotations<?>> T withConfigInjection(T node, String configKey, String defaultValue) {
    node.addAnnotation(new NormalAnnotationExpr(
            new Name("org.eclipse.microprofile.config.inject.ConfigProperty"),
            NodeList.nodeList(
                    new MemberValuePair("name", new StringLiteralExpr(configKey)),
                    new MemberValuePair("defaultValue", new StringLiteralExpr(defaultValue))
            )
    ));
    return node;
}
 
Example #4
Source File: GenericControllerParser.java    From JApiDocs with Apache License 2.0 5 votes vote down vote up
@Override
protected void afterHandleMethod(RequestNode requestNode, MethodDeclaration md) {
    md.getAnnotationByName("ApiDoc").ifPresent(an -> {
        if(an instanceof NormalAnnotationExpr){
            ((NormalAnnotationExpr)an).getPairs().forEach(p -> {
                String n = p.getNameAsString();
                if(n.equals("url")){
                    requestNode.setUrl(Utils.removeQuotations(p.getValue().toString()));
                }else if(n.equals("method")){
                    requestNode.addMethod(Utils.removeQuotations(p.getValue().toString()));
                }
            });
        }
    });
}
 
Example #5
Source File: NormalAnnotationExprMerger.java    From dolphin with Apache License 2.0 5 votes vote down vote up
@Override
public NormalAnnotationExpr doMerge(NormalAnnotationExpr first, NormalAnnotationExpr second) {
  NormalAnnotationExpr nae = new NormalAnnotationExpr();

  nae.setPairs(mergeCollections(first.getPairs(),second.getPairs()));
  nae.setName(mergeSingle(first.getName(),second.getName()));

  return nae;
}
 
Example #6
Source File: SpringDependencyInjectionAnnotator.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends NodeWithAnnotations<?>> T withOptionalInjection(T node) {
    node.addAnnotation(new NormalAnnotationExpr(new Name("org.springframework.beans.factory.annotation.Autowired"), NodeList.nodeList(new MemberValuePair("required", new BooleanLiteralExpr(false)))));
    return node;
}
 
Example #7
Source File: SpringDependencyInjectionAnnotator.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends NodeWithAnnotations<?>> T withIncomingMessage(T node, String channel) {
    node.addAnnotation(new NormalAnnotationExpr(new Name("org.springframework.kafka.annotation.KafkaListener"), NodeList.nodeList(new MemberValuePair("topics", new StringLiteralExpr(channel)))));
    return node;
}
 
Example #8
Source File: NormalAnnotationExprMerger.java    From dolphin with Apache License 2.0 4 votes vote down vote up
/**
 * 1. check the name
 * 2. check the member including key and value
 * if their size is not the same and the less one is all matched in the more one return true
 */
@Override
public boolean doIsEquals(NormalAnnotationExpr first, NormalAnnotationExpr second) {

  boolean equals = true;

  if (!first.getName().equals(second.getName())) equals = false;

  if (equals == true) {

    if (first.getPairs() == null) return second.getPairs() == null;

    if (!isSmallerHasEqualsInBigger(first.getPairs(), second.getPairs(), true)) return false;

  }

  return equals;
}
 
Example #9
Source File: TraceVisitor.java    From JCTools with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(NormalAnnotationExpr n, Void arg) {
    out.println("NormalAnnotationExpr: " + (extended ? n : ""));
    super.visit(n, arg);
}