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

The following examples show how to use com.github.javaparser.ast.expr.ArrayInitializerExpr. 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 ArrayInitializerExpr n, final Void arg) {
    printJavaComment(n.getComment(), arg);
    printer.print("{");
    if (!isNullOrEmpty(n.getValues())) {
        printer.print(" ");
        for (final Iterator<Expression> i = n.getValues().iterator(); i.hasNext(); ) {
            final Expression expr = i.next();
            expr.accept(this, arg);
            if (i.hasNext()) {
                printer.print(", ");
            }
        }
        printer.print(" ");
    }
    printer.print("}");
}
 
Example #2
Source File: RegistryMethodVisitor.java    From gauge-java with Apache License 2.0 6 votes vote down vote up
@Override
public void visit(MethodDeclaration methodDeclaration, Object arg) {
    List<AnnotationExpr> annotations = methodDeclaration.getAnnotations();
    if (annotations.isEmpty()) {
        return;
    }

    for (AnnotationExpr annotationExpr : annotations) {
        if (!(annotationExpr instanceof SingleMemberAnnotationExpr)) {
            continue;
        }
        SingleMemberAnnotationExpr annotation = (SingleMemberAnnotationExpr) annotationExpr;
        if (annotation.getMemberValue() instanceof ArrayInitializerExpr) {
            ArrayInitializerExpr memberValue = (ArrayInitializerExpr) annotation.getMemberValue();
            for (Expression expression : memberValue.getValues()) {
                addStepToRegistry(expression, methodDeclaration, annotation);
            }
        } else {
            addStepToRegistry(annotation.getMemberValue(), methodDeclaration, annotation);
        }
    }
}
 
Example #3
Source File: DependencyInjectionAnnotator.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
/**
 * Annotates given node with set of roles to enforce security
 *
 * @param node  node to be annotated
 * @param roles roles that are allowed
 */
default <T extends NodeWithAnnotations<?>> T withSecurityRoles(T node, String[] roles) {
    if (roles != null && roles.length > 0) {
        List<Expression> rolesExpr = new ArrayList<>();

        for (String role : roles) {
            rolesExpr.add(new StringLiteralExpr(role.trim()));
        }

        node.addAnnotation(new SingleMemberAnnotationExpr(new Name("javax.annotation.security.RolesAllowed"), new ArrayInitializerExpr(NodeList.nodeList(rolesExpr))));
    }
    return node;
}
 
Example #4
Source File: RegistryMethodVisitor.java    From gauge-java with Apache License 2.0 5 votes vote down vote up
private List<String> getAliases(SingleMemberAnnotationExpr annotation) {
    List<String> aliases = new ArrayList<>();
    if (annotation.getMemberValue() instanceof ArrayInitializerExpr) {
        ArrayInitializerExpr memberValue = (ArrayInitializerExpr) annotation.getMemberValue();
        for (Expression expression : memberValue.getValues()) {
            aliases.add(getParameterizedStep(expression));
        }
    }
    return aliases;
}
 
Example #5
Source File: ArrayInitializerExprMerger.java    From dolphin with Apache License 2.0 4 votes vote down vote up
@Override public ArrayInitializerExpr doMerge(ArrayInitializerExpr first, ArrayInitializerExpr second) {
  ArrayInitializerExpr aie = new ArrayInitializerExpr();
  aie.setValues(mergeCollections(first.getValues(),second.getValues()));
  return aie;
}
 
Example #6
Source File: ArrayInitializerExprMerger.java    From dolphin with Apache License 2.0 4 votes vote down vote up
@Override public boolean doIsEquals(ArrayInitializerExpr first, ArrayInitializerExpr second) {
  if(!isEqualsUseMerger(first.getValues(),second.getValues())) return false;

  return true;
}
 
Example #7
Source File: RegistryMethodVisitor.java    From gauge-java with Apache License 2.0 4 votes vote down vote up
private Boolean hasAlias(SingleMemberAnnotationExpr annotation) {
    return annotation.getMemberValue() instanceof ArrayInitializerExpr;
}
 
Example #8
Source File: TraceVisitor.java    From JCTools with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(ArrayInitializerExpr n, Void arg) {
    out.println("ArrayInitializerExpr: " + (extended ? n : ""));
    super.visit(n, arg);
}