Java Code Examples for com.github.javaparser.ast.NodeList#isEmpty()

The following examples show how to use com.github.javaparser.ast.NodeList#isEmpty() . 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 5 votes vote down vote up
private void printMemberAnnotations(final NodeList<AnnotationExpr> annotations, final Void arg) {
    if (annotations.isEmpty()) {
        return;
    }
    for (final AnnotationExpr a : annotations) {
        a.accept(this, arg);
        printer.println();
    }
}
 
Example 2
Source File: PrettyPrintVisitor.java    From stategen with GNU Affero General Public License v3.0 5 votes vote down vote up
private void printAnnotations(final NodeList<AnnotationExpr> annotations, boolean prefixWithASpace,
                              final Void arg) {
    if (annotations.isEmpty()) {
        return;
    }
    if (prefixWithASpace) {
        printer.print(" ");
    }
    for (AnnotationExpr annotation : annotations) {
        annotation.accept(this, arg);
        printer.print(" ");
    }
}
 
Example 3
Source File: PrettyPrintVisitor.java    From stategen with GNU Affero General Public License v3.0 5 votes vote down vote up
private void printPrePostFixOptionalList(final NodeList<? extends Visitable> args, final Void arg, String prefix, String separator, String postfix) {
    if (!args.isEmpty()) {
        printer.print(prefix);
        for (final Iterator<? extends Visitable> i = args.iterator(); i.hasNext(); ) {
            final Visitable v = i.next();
            v.accept(this, arg);
            if (i.hasNext()) {
                printer.print(separator);
            }
        }
        printer.print(postfix);
    }
}
 
Example 4
Source File: PrettyPrintVisitor.java    From stategen with GNU Affero General Public License v3.0 5 votes vote down vote up
private void printPrePostFixRequiredList(final NodeList<? extends Visitable> args, final Void arg, String prefix, String separator, String postfix) {
    printer.print(prefix);
    if (!args.isEmpty()) {
        for (final Iterator<? extends Visitable> i = args.iterator(); i.hasNext(); ) {
            final Visitable v = i.next();
            v.accept(this, arg);
            if (i.hasNext()) {
                printer.print(separator);
            }
        }
    }
    printer.print(postfix);
}
 
Example 5
Source File: OpenApiObjectGenerator.java    From flow with Apache License 2.0 5 votes vote down vote up
private List<Schema> parseNonEndpointClassAsSchema(
        String fullQualifiedName) {
    TypeDeclaration<?> typeDeclaration = nonEndpointMap.get(fullQualifiedName);
    if (typeDeclaration == null || typeDeclaration.isEnumDeclaration()) {
        return Collections.emptyList();
    }
    List<Schema> result = new ArrayList<>();

    Schema schema = createSingleSchema(fullQualifiedName, typeDeclaration);
    generatedSchema.add(fullQualifiedName);

    NodeList<ClassOrInterfaceType> extendedTypes = null;
    if (typeDeclaration.isClassOrInterfaceDeclaration()) {
        extendedTypes = typeDeclaration.asClassOrInterfaceDeclaration()
                .getExtendedTypes();
    }
    if (extendedTypes == null || extendedTypes.isEmpty()) {
        result.add(schema);
        result.addAll(generatedRelatedSchemas(schema));
    } else {
        ComposedSchema parentSchema = new ComposedSchema();
        parentSchema.setName(fullQualifiedName);
        result.add(parentSchema);
        extendedTypes.forEach(parentType -> {
            ResolvedReferenceType resolvedParentType = parentType.resolve();
            String parentQualifiedName = resolvedParentType
                    .getQualifiedName();
            String parentRef = schemaResolver
                    .getFullQualifiedNameRef(parentQualifiedName);
            parentSchema.addAllOfItem(new ObjectSchema().$ref(parentRef));
            schemaResolver.addFoundTypes(parentQualifiedName,
                    resolvedParentType);
        });
        // The inserting order matters for `allof` property.
        parentSchema.addAllOfItem(schema);
        result.addAll(generatedRelatedSchemas(parentSchema));
    }
    return result;
}