Java Code Examples for com.github.javaparser.resolution.types.ResolvedReferenceType#getQualifiedName()

The following examples show how to use com.github.javaparser.resolution.types.ResolvedReferenceType#getQualifiedName() . 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: SchemaResolver.java    From flow with Apache License 2.0 5 votes vote down vote up
private Schema createEnumTypeSchema(ResolvedType resolvedType) {
    ResolvedReferenceType type = resolvedType.asReferenceType();
    List<String> entries = type
            .getTypeDeclaration().asEnum().getEnumConstants().stream()
            .map(ResolvedEnumConstantDeclaration::getName)
            .collect(Collectors.toList());
    String qualifiedName = type.getQualifiedName();
    foundTypes.put(qualifiedName, type);
    StringSchema schema = new StringSchema();
    schema.name(qualifiedName);
    schema.setEnum(entries);
    schema.$ref(getFullQualifiedNameRef(qualifiedName));
    return schema;
}
 
Example 2
Source File: OpenApiObjectGenerator.java    From flow with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("squid:S1872")
private List<Schema> parseReferencedTypeAsSchema(
        ResolvedReferenceType resolvedType) {
    List<Schema> results = new ArrayList<>();

    Schema schema = createSingleSchemaFromResolvedType(resolvedType);
    String qualifiedName = resolvedType.getQualifiedName();
    generatedSchema.add(qualifiedName);

    List<ResolvedReferenceType> directAncestors = resolvedType
            .getDirectAncestors().stream()
            .filter(parent -> parent.getTypeDeclaration().isClass()
                    && !Object.class.getName()
                            .equals(parent.getQualifiedName()))
            .collect(Collectors.toList());

    if (directAncestors.isEmpty() || resolvedType.getTypeDeclaration().isEnum()) {
        results.add(schema);
        results.addAll(generatedRelatedSchemas(schema));
    } else {
        ComposedSchema parentSchema = new ComposedSchema();
        parentSchema.name(qualifiedName);
        results.add(parentSchema);
        for (ResolvedReferenceType directAncestor : directAncestors) {
            String ancestorQualifiedName = directAncestor
                    .getQualifiedName();
            String parentRef = schemaResolver
                    .getFullQualifiedNameRef(ancestorQualifiedName);
            parentSchema.addAllOfItem(new ObjectSchema().$ref(parentRef));
            schemaResolver.addFoundTypes(ancestorQualifiedName,
                    directAncestor);
        }
        parentSchema.addAllOfItem(schema);
        results.addAll(generatedRelatedSchemas(parentSchema));
    }
    return results;
}